Struct sparse_complex::ComplexMatrix [−][src]
The complex matrix struct
Implementations
impl ComplexMatrix
[src]
pub fn new() -> Self
[src]
Create a new, initially empty ComplexMatrix
use sparse_complex::ComplexMatrix; let mut m = ComplexMatrix::new();
pub fn from_entries(entries: Vec<(usize, usize, (f64, f64))>) -> Self
[src]
Create a new ComplexMatrix
from a vector of (row, col, (real, imag))
entries.
use sparse_complex::ComplexMatrix; let entries = vec![(0, 0, (1., 1.)), (1, 1, (1., 1.))]; let mut m = ComplexMatrix::from_entries(entries);
pub fn add_element(&mut self, row: usize, col: usize, value: (f64, f64))
[src]
Add or set an element at location (row, col)
with value (real, imag)
.
pub fn add_elements(&mut self, entries: Vec<(usize, usize, (f64, f64))>)
[src]
Add elements correspoding to each triplet (row, col, (real, imag))
.
pub fn get(&self, row: usize, col: usize) -> Option<(f64, f64)>
[src]
Returns the Element-value at (row, col)
if present, or None if not.
use sparse_complex::ComplexMatrix; let entries = vec![(0, 0, (1., -1.)), (1, 1, (-1., 1.))]; let mut m = ComplexMatrix::from_entries(entries); assert_eq!(m.get(2,1), None); assert_eq!(m.get(0,0), Some((1., -1.))); assert_eq!(m.get(1,1), Some((-1., 1.)));
pub fn solve(
&mut self,
b: &[(f64, f64)]
) -> Result<Vec<(f64, f64)>, &'static str>
[src]
&mut self,
b: &[(f64, f64)]
) -> Result<Vec<(f64, f64)>, &'static str>
Solve the system Ax=b
, where:
A
is a complex matrixb
is a complex vectorx
is the return value.
Returns a Result
containing the vector with (real, imag)
solutions.
Returns an Err
if unsuccessful.
This solution use the LU factorization implemented by sparse21.
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)]);
Trait Implementations
impl Clone for ComplexMatrix
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ComplexMatrix
[src]
impl Default for ComplexMatrix
[src]
impl PartialEq<ComplexMatrix> for ComplexMatrix
[src]
Auto Trait Implementations
impl RefUnwindSafe for ComplexMatrix
impl Send for ComplexMatrix
impl Sync for ComplexMatrix
impl Unpin for ComplexMatrix
impl UnwindSafe for ComplexMatrix
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,