opensrdk_linear_algebra/matrix/ge/operations/
adjoint.rs1use crate::matrix::ge::Matrix;
2use crate::number::c64;
3use rayon::prelude::*;
4
5impl Matrix<c64> {
6 pub fn adjoint(&self) -> Matrix<c64> {
7 let elems = (0..self.rows)
8 .into_par_iter()
9 .flat_map(|i| (0..self.cols).into_par_iter().map(move |j| (i, j)))
10 .map(|(i, j)| self[(i, j)].conj())
11 .collect();
12
13 Matrix::<c64>::from(self.cols, elems).unwrap()
14 }
15}
16
17#[cfg(test)]
18mod tests {
19 use crate::*;
20 #[test]
21 fn it_works() {
22 let mut a = Matrix::<c64>::new(2, 3);
23 a[(1, 2)] = c64::new(2.0, 3.0);
24 let b = a.adjoint();
25
26 assert_eq!(b[(2, 1)], c64::new(2.0, -3.0))
27 }
28}