opensrdk_linear_algebra/matrix/ge/operators/neg.rs
1use crate::{ge::Matrix, Number};
2use std::ops::Neg;
3
4impl<T> Neg for Matrix<T>
5where
6 T: Number,
7{
8 type Output = Self;
9
10 fn neg(self) -> Self::Output {
11 self * (-T::one())
12 }
13}
14
15#[cfg(test)]
16mod tests {
17 use crate::*;
18 #[test]
19 fn it_works() {
20 let a = -mat!(
21 1.0, 2.0;
22 3.0, 4.0
23 );
24 assert_eq!(a[(0, 0)], -1.0);
25 }
26}