Open
Description
Today I wanted to do some logical operations on matrices of booleans. Ideally, it would be as simple as calling m1 | m2 & m3
for example. My concrete use case is building the union of masks and I'm currently doing the following (with some additional asserts on sizes):
/// Merge multiple sparse matrices into one combining all sparsely selected pixels.
pub fn merge(matrices: &[DMatrix<bool>]) -> DMatrix<bool> {
let mut merged = matrices[0].clone();
for mat in matrices.iter().skip(1) {
for (b_merged, b) in merged.iter_mut().zip(mat) {
*b_merged |= b;
}
}
merged
}