An abstraction layer for sparse21 that adds support for complex sparse matrices.
In this implementation, a complex number is represented as a tuple of f64
.
Where the first element is the real part and the second is the imaginary part, as shown bellow:
rust
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:
```rust use sparse_complex::ComplexMatrix;
let mut a = ComplexMatrix::new(); a.addelement(0, 0, (1., 1.)); a.addelement(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:
The sparse_complex
crate is tested for rustc 1.50 and greater.
MIT License. See LICENSE.