mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:00:01 +00:00
Merge pull request #31 from Magnus167/bugfix/not_operator
Implement logical NOT for references to boolean matrices
This commit is contained in:
commit
d2d4764c17
@ -364,6 +364,21 @@ impl Not for Matrix<bool> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// implement for &Matrix<bool>
|
||||||
|
impl<'a> Not for &'a Matrix<bool> {
|
||||||
|
type Output = Matrix<bool>;
|
||||||
|
|
||||||
|
fn not(self) -> Matrix<bool> {
|
||||||
|
// 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<f64>;
|
pub type FloatMatrix = Matrix<f64>;
|
||||||
pub type BoolMatrix = Matrix<bool>;
|
pub type BoolMatrix = Matrix<bool>;
|
||||||
pub type IntMatrix = Matrix<i32>;
|
pub type IntMatrix = Matrix<i32>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user