From ea8e1c847151483c46bc13ec9298d868e805abeb Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Thu, 24 Apr 2025 23:19:02 +0100 Subject: [PATCH 01/13] Implement element-wise equality comparison for matrices --- src/matrix/mat.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 5670267..c04873c 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -184,6 +184,32 @@ impl<'a, T> MatrixRow<'a, T> { } } +// PartialEq for element-wise comparison +impl Matrix { + /// Performs element-wise equality comparison with another matrix. + /// Returns a new `Matrix` where each element is the result of comparing the corresponding elements. + /// Panics if the matrices have different dimensions. + pub fn eq_elementwise(&self, rhs: &Matrix) -> BoolMatrix { + assert_eq!( + self.rows, rhs.rows, + "Matrices must have the same number of rows for element-wise comparison" + ); + assert_eq!( + self.cols, rhs.cols, + "Matrices must have the same number of columns for element-wise comparison" + ); + + let data = self + .data + .iter() + .zip(rhs.data.iter()) + .map(|(a, b)| a == b) // Use T::PartialEq::eq + .collect(); + + BoolMatrix::from_vec(data, self.rows, self.cols) + } +} + /// Generates element-wise arithmetic implementations for matrices. macro_rules! impl_elementwise_op { ($OpTrait:ident, $method:ident, $op:tt) => { @@ -1161,8 +1187,7 @@ mod tests { assert!((div[(0, 1)] - 3.0 / 2.5).abs() < 1e-9); // 1.2 assert!((div[(1, 1)] - 4.0 / 3.5).abs() < 1e-9); // 1.14... } - - + fn create_test_matrix_i32() -> Matrix { Matrix::from_cols(vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]]) } From 601c1c58d05353433e8ad17169df7681640c8484 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Thu, 24 Apr 2025 23:33:04 +0100 Subject: [PATCH 02/13] Refactor element-wise comparison implementation for matrices --- src/matrix/mat.rs | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index c04873c..2e9d5a6 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -184,30 +184,27 @@ impl<'a, T> MatrixRow<'a, T> { } } -// PartialEq for element-wise comparison -impl Matrix { - /// Performs element-wise equality comparison with another matrix. - /// Returns a new `Matrix` where each element is the result of comparing the corresponding elements. - /// Panics if the matrices have different dimensions. - pub fn eq_elementwise(&self, rhs: &Matrix) -> BoolMatrix { - assert_eq!( - self.rows, rhs.rows, - "Matrices must have the same number of rows for element-wise comparison" - ); - assert_eq!( - self.cols, rhs.cols, - "Matrices must have the same number of columns for element-wise comparison" - ); +macro_rules! impl_cmp { + ($name:ident, $op:tt) => { + pub fn $name(&self, rhs: &Matrix) -> BoolMatrix { + assert_eq!(self.rows, rhs.rows, "…"); + assert_eq!(self.cols, rhs.cols, "…"); - let data = self - .data - .iter() - .zip(rhs.data.iter()) - .map(|(a, b)| a == b) // Use T::PartialEq::eq - .collect(); + let data = self.data.iter() + .zip(rhs.data.iter()) + .map(|(a, b)| a $op b) + .collect(); - BoolMatrix::from_vec(data, self.rows, self.cols) - } + BoolMatrix::from_vec(data, self.rows, self.cols) + } + }; +} + +impl Matrix { + impl_cmp!(lt_elementwise, <); + impl_cmp!(le_elementwise, <=); + impl_cmp!(gt_elementwise, >); + impl_cmp!(ge_elementwise, >=); } /// Generates element-wise arithmetic implementations for matrices. From 21fc4a724139882f9ecb7a30fc379259a7bea4b1 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Thu, 24 Apr 2025 23:39:34 +0100 Subject: [PATCH 03/13] Refactor element-wise comparison implementation for matrices --- src/matrix/mat.rs | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 2e9d5a6..6006340 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -184,27 +184,37 @@ impl<'a, T> MatrixRow<'a, T> { } } -macro_rules! impl_cmp { - ($name:ident, $op:tt) => { - pub fn $name(&self, rhs: &Matrix) -> BoolMatrix { - assert_eq!(self.rows, rhs.rows, "…"); - assert_eq!(self.cols, rhs.cols, "…"); - - let data = self.data.iter() - .zip(rhs.data.iter()) - .map(|(a, b)| a $op b) - .collect(); - - BoolMatrix::from_vec(data, self.rows, self.cols) +/// Implements element‐wise eq, lt, le, gt and ge for `Matrix`. +macro_rules! impl_elementwise_cmp { + ( + $( $method:ident => $op:tt ),* $(,)? + ) => { + impl Matrix { + $( + #[doc = concat!("Element‐wise comparison `x ", stringify!($op), " y`.")] + pub fn $method(&self, rhs: &Matrix) -> BoolMatrix { + assert_eq!(self.rows, rhs.rows, "row count mismatch"); + assert_eq!(self.cols, rhs.cols, "col count mismatch"); + let data = self + .data + .iter() + .zip(&rhs.data) + .map(|(a, b)| a $op b) + .collect(); + BoolMatrix::from_vec(data, self.rows, self.cols) + } + )* } }; } -impl Matrix { - impl_cmp!(lt_elementwise, <); - impl_cmp!(le_elementwise, <=); - impl_cmp!(gt_elementwise, >); - impl_cmp!(ge_elementwise, >=); +// Invoke it for all five operations: +impl_elementwise_cmp! { + eq_elementwise => ==, + lt_elementwise => <, + le_elementwise => <=, + gt_elementwise => >, + ge_elementwise => >=, } /// Generates element-wise arithmetic implementations for matrices. From 56bb579530ac9011f08846e0d0d127c94735ac04 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Thu, 24 Apr 2025 23:50:20 +0100 Subject: [PATCH 04/13] Implement broadcasting trait for matrices and enhance element-wise comparison methods --- src/matrix/mat.rs | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 6006340..400facc 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -183,24 +183,52 @@ impl<'a, T> MatrixRow<'a, T> { (0..self.matrix.cols).map(move |c| &self.matrix[(self.row, c)]) } } +/// A trait to turn either a Matrix or a scalar T into a Vec of +/// length rows*cols (broadcasting the scalar). +pub trait Broadcastable { + fn to_vec(&self, rows: usize, cols: usize) -> Vec; +} -/// Implements element‐wise eq, lt, le, gt and ge for `Matrix`. +impl Broadcastable for T { + fn to_vec(&self, rows: usize, cols: usize) -> Vec { + vec![self.clone(); rows * cols] + } +} + +impl Broadcastable for Matrix { + fn to_vec(&self, rows: usize, cols: usize) -> Vec { + assert_eq!(self.rows, rows, "row count mismatch"); + assert_eq!(self.cols, cols, "col count mismatch"); + self.data.clone() + } +} + +/// 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 { ( $( $method:ident => $op:tt ),* $(,)? ) => { - impl Matrix { + impl Matrix { $( - #[doc = concat!("Element‐wise comparison `x ", stringify!($op), " y`.")] - pub fn $method(&self, rhs: &Matrix) -> BoolMatrix { - assert_eq!(self.rows, rhs.rows, "row count mismatch"); - assert_eq!(self.cols, rhs.cols, "col count mismatch"); + #[doc = concat!("Element-wise comparison `self ", stringify!($op), " rhs`,\n\ + where `rhs` may be a Matrix or a scalar T.")] + pub fn $method(&self, rhs: Rhs) -> BoolMatrix + where + Rhs: Broadcastable, + { + // Prepare broadcasted rhs-data + let rhs_data = rhs.to_vec(self.rows, self.cols); + + // Pairwise compare let data = self .data .iter() - .zip(&rhs.data) + .cloned() + .zip(rhs_data.into_iter()) .map(|(a, b)| a $op b) .collect(); + BoolMatrix::from_vec(data, self.rows, self.cols) } )* @@ -208,7 +236,7 @@ macro_rules! impl_elementwise_cmp { }; } -// Invoke it for all five operations: +// Instantiate element-wise comparison implementations for matrices. impl_elementwise_cmp! { eq_elementwise => ==, lt_elementwise => <, From cf5ae8550eaa9632f215c902313e9a3125212e5e Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 00:22:08 +0100 Subject: [PATCH 05/13] Refactor Matrix implementation to require Clone trait and reorder methods for clarity --- src/matrix/mat.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 400facc..6378172 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -8,7 +8,7 @@ pub struct Matrix { data: Vec, } -impl Matrix { +impl Matrix { /// Build from columns (each inner Vec is one column) pub fn from_cols(cols_data: Vec>) -> Self { let cols = cols_data.len(); @@ -38,13 +38,22 @@ impl Matrix { Matrix { rows, cols, data } } - pub fn rows(&self) -> usize { - self.rows - } pub fn data(&self) -> &[T] { &self.data } + pub fn data_mut(&mut self) -> &mut [T] { + &mut self.data + } + + pub fn as_vec(&self) -> Vec { + self.data.clone() + } + + pub fn rows(&self) -> usize { + self.rows + } + pub fn cols(&self) -> usize { self.cols } From ebfd63d9dbad50478d9942bffe38fc941329e803 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 00:22:25 +0100 Subject: [PATCH 06/13] Add tests for broadcastable operations and fix comment formatting --- src/matrix/mat.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 6378172..5a003d4 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -192,7 +192,7 @@ impl<'a, T> MatrixRow<'a, T> { (0..self.matrix.cols).map(move |c| &self.matrix[(self.row, c)]) } } -/// A trait to turn either a Matrix or a scalar T into a Vec of +/// A trait to turn either a Matrix or a scalar T into a Vec of /// length rows*cols (broadcasting the scalar). pub trait Broadcastable { fn to_vec(&self, rows: usize, cols: usize) -> Vec; @@ -346,6 +346,8 @@ pub enum Axis { #[cfg(test)] mod tests { + use crate::matrix::BoolOps; + use super::{BoolMatrix, FloatMatrix, Matrix, StringMatrix}; // Helper function to create a basic Matrix for testing @@ -1301,5 +1303,31 @@ mod tests { assert_eq!(matrix2.column(1), initial_col0_data_m2.as_slice()); assert_eq!(matrix2.data(), &[4, 5, 6, 1, 2, 3, 7, 8, 9]); } - // Axis enum doesn't have logic, no tests needed directly, but its presence is verified by compilation. + + // Test broadcastable operations + #[test] + fn test_comparision_broadcast() { + let matrix = create_test_matrix(); + // test all > 0 + let result = matrix.gt_elementwise(0).as_vec(); + let expected = vec![true; result.len()]; + assert_eq!(result, expected); + + let ma = create_test_matrix(); + let mb = create_test_matrix(); + + let result = ma.eq_elementwise(mb); + assert!(result.all()); + + let result = matrix.lt_elementwise(1e10 as i32).all(); + assert!(result); + + for i in 0..matrix.rows() { + for j in 0..matrix.cols() { + let vx = matrix[(i, j)]; + let c = &(matrix.le_elementwise(vx)) & &(matrix.ge_elementwise(vx)); + assert_eq!(c.count(), 1); + } + } + } } From 6804e7ca5a73e5f3e6271d1e4fa9b5e9e0230acc Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:42:38 +0100 Subject: [PATCH 07/13] Add unit test for mutable data access in Matrix --- src/matrix/mat.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 5a003d4..20ff191 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -613,6 +613,22 @@ mod tests { assert_eq!(rows[1], vec![2, 4, 6, 8]); } + // test data_mut + #[test] + fn test_data_mut() { + let mut matrix = create_test_matrix(); // 3x3 + // 1 4 7 + // 2 5 8 + // 3 6 9 + + let data_mut = matrix.data_mut(); + data_mut[0] = 10; + data_mut[1] = 20; + + assert_eq!(matrix[(0, 0)], 10); + assert_eq!(matrix[(1, 0)], 20); + } + #[test] fn test_matrix_row_get_and_iter() { let matrix = create_test_matrix_2x4(); // 2x4 From 9b96dad9564836f131a86233b6ba84744264088a Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:45:18 +0100 Subject: [PATCH 08/13] Refactor Axis enum definition: move to appropriate location and remove duplicate --- src/matrix/mat.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 20ff191..284be31 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -192,6 +192,16 @@ impl<'a, T> MatrixRow<'a, T> { (0..self.matrix.cols).map(move |c| &self.matrix[(self.row, c)]) } } + +/// Specifies the axis along which to perform a reduction operation. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Axis { + /// Apply reduction along columns (vertical axis). + Col, + /// Apply reduction along rows (horizontal axis). + Row, +} + /// A trait to turn either a Matrix or a scalar T into a Vec of /// length rows*cols (broadcasting the scalar). pub trait Broadcastable { @@ -335,14 +345,6 @@ impl Not for Matrix { } } -/// Specifies the axis along which to perform a reduction operation. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Axis { - /// Apply reduction along columns (vertical axis). - Col, - /// Apply reduction along rows (horizontal axis). - Row, -} #[cfg(test)] mod tests { From 2ff4a993460c1a4b4a2e9c08c1e17f0e61a6d004 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:45:56 +0100 Subject: [PATCH 09/13] Reorganize type aliases for matrix types: move to appropriate location for clarity --- src/matrix/mat.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 284be31..95f0ac7 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -297,11 +297,6 @@ impl_elementwise_op!(Sub, sub, -); impl_elementwise_op!(Mul, mul, *); impl_elementwise_op!(Div, div, /); -pub type FloatMatrix = Matrix; -pub type BoolMatrix = Matrix; -pub type IntMatrix = Matrix; -pub type StringMatrix = Matrix; - /// Generates element-wise bitwise operations for boolean matrices. macro_rules! impl_bitwise_op { ($OpTrait:ident, $method:ident, $op:tt) => { @@ -345,6 +340,10 @@ impl Not for Matrix { } } +pub type FloatMatrix = Matrix; +pub type BoolMatrix = Matrix; +pub type IntMatrix = Matrix; +pub type StringMatrix = Matrix; #[cfg(test)] mod tests { From d6ccf88829e825f8d80acf7ae4db22fc10914278 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:48:12 +0100 Subject: [PATCH 10/13] Update coverage thresholds in codecov.yml: increase project target to 95% and adjust patch target to 50% --- codecov.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/codecov.yml b/codecov.yml index 85e9c12..aea0fce 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,17 +1,17 @@ coverage: status: - # Project coverage status: require ≥ 90% overall, allow up to 2% drop + # Project coverage status: require >= 90% overall, allow up to 2% drop project: default: - target: 90% # overall coverage goal - threshold: 2% # tolerable drop below target before failing - base: auto # compare against default branch + target: 95% # overall coverage goal + threshold: 2% # tolerable drop below target before failing + base: auto # compare against default branch only_pulls: true # enforce on PRs only - # Patch coverage status: require ≥ 95% on new/changed lines, zero tolerance + # Patch coverage status: require >= 95% on new/changed lines, zero tolerance patch: default: - target: 95% # coverage goal for new or changed code - threshold: 0% # no uncovered lines allowed - base: auto # diff against default branch + target: 50% # coverage goal for new or changed code + threshold: 0% # no uncovered lines allowed + base: auto # diff against default branch only_pulls: true From d0b9ab0716c00f34aef6adbcd8a1e6b6fe4535fb Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:49:43 +0100 Subject: [PATCH 11/13] Implement element-wise arithmetic operations for matrices with scalars and add corresponding unit tests --- src/matrix/mat.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 95f0ac7..9f0cb09 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -297,6 +297,30 @@ impl_elementwise_op!(Sub, sub, -); impl_elementwise_op!(Mul, mul, *); impl_elementwise_op!(Div, div, /); +/// Generates element-wise arithmetic implementations for matrices with scalars. +macro_rules! impl_elementwise_op_scalar { + ($OpTrait:ident, $method:ident, $op:tt) => { + impl<'a, T> std::ops::$OpTrait for &'a Matrix + where + T: Clone + std::ops::$OpTrait, + { + type Output = Matrix; + + fn $method(self, rhs: T) -> Matrix { + // Apply the operation element-wise and collect into a new matrix + let data = self.data.iter().cloned().map(|a| a $op rhs.clone()).collect(); + Matrix { rows: self.rows, cols: self.cols, data } + } + } + }; +} + +// Instantiate element-wise addition, subtraction, multiplication, and division +impl_elementwise_op_scalar!(Add, add, +); +impl_elementwise_op_scalar!(Sub, sub, -); +impl_elementwise_op_scalar!(Mul, mul, *); +impl_elementwise_op_scalar!(Div, div, /); + /// Generates element-wise bitwise operations for boolean matrices. macro_rules! impl_bitwise_op { ($OpTrait:ident, $method:ident, $op:tt) => { @@ -1347,4 +1371,25 @@ mod tests { } } } + + #[test] + fn test_arithmetic_broadcast() { + let matrix = create_test_matrix(); + let result = &matrix + 1; + for i in 0..matrix.rows() { + for j in 0..matrix.cols() { + assert_eq!(result[(i, j)], matrix[(i, j)] + 1); + } + } + + // test mul and div + let result = &matrix * 2; + let result2 = &matrix / 2; + for i in 0..matrix.rows() { + for j in 0..matrix.cols() { + assert_eq!(result[(i, j)], matrix[(i, j)] * 2); + assert_eq!(result2[(i, j)], matrix[(i, j)] / 2); + } + } + } } From 8ed8cecd0e8ddddf8f1f86af83a858f4ab03f633 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:54:02 +0100 Subject: [PATCH 12/13] Update documentation build and test commands to include release flag for improved performance --- .github/workflows/docs-and-testcov.yml | 2 +- .github/workflows/run-unit-tests.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs-and-testcov.yml b/.github/workflows/docs-and-testcov.yml index 6234d13..70cd1fe 100644 --- a/.github/workflows/docs-and-testcov.yml +++ b/.github/workflows/docs-and-testcov.yml @@ -30,7 +30,7 @@ jobs: override: true - name: Build documentation - run: cargo doc --no-deps + run: cargo doc --no-deps --release - name: Prepare documentation for Pages run: | diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 5e941d8..ba90e9e 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -21,9 +21,9 @@ jobs: - name: Generate code coverage run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info - name: Run doc-tests - run: cargo test --doc --all-features --workspace + run: cargo test --doc --all-features --workspace --release - name: Test docs generation - run: cargo doc --no-deps + run: cargo doc --no-deps --release - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: From 1865e909560172074403bfbe49aaeb53e6cd189d Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:54:13 +0100 Subject: [PATCH 13/13] Improve documentation formatting for Broadcastable trait and element-wise comparison methods --- src/matrix/mat.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 9f0cb09..02a042b 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -202,8 +202,8 @@ pub enum Axis { Row, } -/// A trait to turn either a Matrix or a scalar T into a Vec of -/// length rows*cols (broadcasting the scalar). +/// A trait to turn either a `Matrix` or a scalar T into a `Vec` of +/// length `rows*cols` (broadcasting the scalar). pub trait Broadcastable { fn to_vec(&self, rows: usize, cols: usize) -> Vec; } @@ -223,7 +223,7 @@ impl Broadcastable for Matrix { } /// Generates element-wise eq, lt, le, gt and ge methods -/// where the rhs can be a Matrix or a scalar T. +/// where the rhs can be a `Matrix` or a scalar T. macro_rules! impl_elementwise_cmp { ( $( $method:ident => $op:tt ),* $(,)? @@ -231,7 +231,7 @@ macro_rules! impl_elementwise_cmp { impl Matrix { $( #[doc = concat!("Element-wise comparison `self ", stringify!($op), " rhs`,\n\ - where `rhs` may be a Matrix or a scalar T.")] + where `rhs` may be a `Matrix` or a scalar T.")] pub fn $method(&self, rhs: Rhs) -> BoolMatrix where Rhs: Broadcastable,