mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:19:59 +00:00
Organize code structure by adding section comments
This commit is contained in:
parent
ac0eed2d56
commit
b17863dcdc
@ -314,6 +314,8 @@ impl<T> IndexMut<(usize, usize)> for Matrix<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Row Iterator Helper ---
|
||||||
|
|
||||||
/// Represents an immutable view of a single row in the matrix.
|
/// Represents an immutable view of a single row in the matrix.
|
||||||
pub struct MatrixRow<'a, T> {
|
pub struct MatrixRow<'a, T> {
|
||||||
matrix: &'a Matrix<T>,
|
matrix: &'a Matrix<T>,
|
||||||
@ -328,10 +330,12 @@ impl<'a, T> MatrixRow<'a, T> {
|
|||||||
|
|
||||||
/// Returns an iterator over all elements in this row.
|
/// Returns an iterator over all elements in this row.
|
||||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||||
(0..self.matrix.cols).map(move |c| &self.matrix[(self.row, c)])
|
(0..self.matrix.cols).map(move |c| self.get(c))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Reduction Axis Enum ---
|
||||||
|
|
||||||
/// Specifies the axis along which to perform a reduction operation.
|
/// Specifies the axis along which to perform a reduction operation.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum Axis {
|
pub enum Axis {
|
||||||
@ -363,6 +367,8 @@ impl<T: Clone> Broadcastable<T> for Matrix<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Element-wise Comparisons ---
|
||||||
|
|
||||||
/// Generates element-wise eq, lt, le, gt and ge methods
|
/// Generates element-wise eq, lt, le, gt and ge methods
|
||||||
/// where the rhs can be a `Matrix<T>` or a scalar T.
|
/// where the rhs can be a `Matrix<T>` or a scalar T.
|
||||||
macro_rules! impl_elementwise_cmp {
|
macro_rules! impl_elementwise_cmp {
|
||||||
@ -612,11 +618,15 @@ impl Not for &Matrix<bool> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Type Aliases ---
|
||||||
pub type FloatMatrix = Matrix<f64>;
|
pub type FloatMatrix = Matrix<f64>;
|
||||||
pub type BoolMatrix = Matrix<bool>;
|
pub type BoolMatrix = Matrix<bool>;
|
||||||
pub type IntMatrix = Matrix<i32>;
|
pub type IntMatrix = Matrix<i32>;
|
||||||
pub type StringMatrix = Matrix<String>;
|
pub type StringMatrix = Matrix<String>;
|
||||||
|
|
||||||
|
|
||||||
|
// --- Unit Tests ---
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::matrix::BoolOps;
|
use crate::matrix::BoolOps;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user