From b17863dcdcfaefa9c32fae1bfb4109f2043468dd Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 3 May 2025 01:18:24 +0100 Subject: [PATCH] Organize code structure by adding section comments --- src/matrix/mat.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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;