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;