Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created October 18, 2019 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/b4909a7244c30cfc22bff252687978c2 to your computer and use it in GitHub Desktop.
Save rust-play/b4909a7244c30cfc22bff252687978c2 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
pub fn component_min<R2, C2, SB>(&self, rhs: &Matrix<N, R2, C2, SB>) -> Matrix<N, R, C, S>
where
N: Signed,
R2: Dim, C2: Dim,
DefaultAllocator: Allocator<N, R, C>,
{
let mut res = self.clone_owned();
for j in 0 .. res.ncols() {
for i in 0 .. res.nrows() {
unsafe {
res.get_unchecked_mut((i, j)).min(*rhs.get_unchecked((i, j)));
}
}
}
res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment