diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index f748ced..180650a 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -314,6 +314,8 @@ impl IndexMut<(usize, usize)> for Matrix { } } +// --- Row Iterator Helper --- + /// Represents an immutable view of a single row in the matrix. pub struct MatrixRow<'a, T> { matrix: &'a Matrix, @@ -328,10 +330,12 @@ impl<'a, T> MatrixRow<'a, T> { /// Returns an iterator over all elements in this row. pub fn iter(&self) -> impl Iterator { - (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. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Axis { @@ -363,6 +367,8 @@ impl Broadcastable for Matrix { } } +// --- Element-wise Comparisons --- + /// Generates element-wise eq, lt, le, gt and ge methods /// where the rhs can be a `Matrix` or a scalar T. macro_rules! impl_elementwise_cmp { @@ -612,11 +618,15 @@ impl Not for &Matrix { } } +// --- Type Aliases --- pub type FloatMatrix = Matrix; pub type BoolMatrix = Matrix; pub type IntMatrix = Matrix; pub type StringMatrix = Matrix; + +// --- Unit Tests --- + #[cfg(test)] mod tests { use crate::matrix::BoolOps;