An abstraction layer for sparse21 that adds support for complex sparse matrices.
In this implementation, a complex number is represented as a tuple of
Where the first element is the real part and the second is the imaginary part, as shown bellow:
let complex_number: (f64, f64) = (1.0 , 1.0); // 1 + j1
The use of
f64 is a limitation of sparse21.
Lets consider the complex linear system bellow:
We can solve this system as follows:
use sparse_complex::ComplexMatrix; let mut a = ComplexMatrix::new(); a.add_element(0, 0, (1., 1.)); a.add_element(1, 1, (1., 1.)); let b = [(1., 0.), (0., 1.)]; let solution = a.solve(&b); assert_eq!(solution.unwrap(), vec![(0.5, -0.5), (0.5, 0.5)]);
The solution of this system is:
sparse_complex crate is tested for rustc 1.50 and greater.
The complex matrix struct