array_matrix/matrix/conj.rs
1use num_complex::{Complex};
2use num_traits::Float;
3
4use crate::{matrix_init, Matrix};
5
6pub trait MConj: Matrix
7where
8 Self::Output: Matrix
9{
10 type Output;
11
12 /// Returns the complex-conjugate matrix
13 ///
14 /// A*
15 ///
16 /// # Examples
17 ///
18 /// ```rust
19 /// let a = [
20 /// [Complex::new(1.0, 1.0), Complex::new(2.0, -1.0)],
21 /// [Complex::new(3.0, 1.0), Complex::new(4.0, -1.0)]
22 /// ];
23 /// let a_ = [
24 /// [a[0][0].conj(), a[0][1].conj()],
25 /// [a[1][0].conj(), a[1][1].conj()]
26 /// ];
27 /// assert_eq!(a.conj(), a_);
28 /// ```
29 fn conj(&self) -> Self::Output;
30}
31
32impl<F: Float, const L: usize, const H: usize> MConj for [[Complex<F>; L]; H]
33where
34 Self: Matrix
35{
36 type Output = Self;
37 fn conj(&self) -> Self::Output
38 {
39 matrix_init(|r, c| self[r][c].conj())
40 }
41}