From e2e349fec5ca0fb9ba7d6fed3e3b09a44a7e357a Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Fri, 2 May 2025 23:30:23 +0100 Subject: [PATCH] Implement logical NOT for references to boolean matrices --- src/matrix/mat.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 02a042b..b3d93b6 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -364,6 +364,21 @@ impl Not for Matrix { } } +// implement for &Matrix +impl<'a> Not for &'a Matrix { + type Output = Matrix; + + fn not(self) -> Matrix { + // Invert each boolean element in the matrix + let data = self.data.iter().map(|&v| !v).collect(); + Matrix { + rows: self.rows, + cols: self.cols, + data, + } + } +} + pub type FloatMatrix = Matrix; pub type BoolMatrix = Matrix; pub type IntMatrix = Matrix;