pub struct Matrix { /* private fields */ }Expand description
Sparse Matrix
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub fn from_entries(entries: Vec<(usize, usize, Complex64)>) -> Matrix
pub fn from_entries(entries: Vec<(usize, usize, Complex64)>) -> Matrix
Create a new Matrix from a vector of (row, col, val) entries.
Sourcepub fn add_element(&mut self, row: usize, col: usize, val: Complex64)
pub fn add_element(&mut self, row: usize, col: usize, val: Complex64)
Add an element at location (row, col) with value val.
Sourcepub fn add_elements(&mut self, elements: Vec<(usize, usize, Complex64)>)
pub fn add_elements(&mut self, elements: Vec<(usize, usize, Complex64)>)
Add elements correspoding to each triplet (row, col, val)
Rows and columns are usize, and vals are Complex64.
Sourcepub fn make(&mut self, row: usize, col: usize) -> Eindex
pub fn make(&mut self, row: usize, col: usize) -> Eindex
Create a zero-valued element at (row, col),
or return existing Element index if present
Sourcepub fn vecmul(&self, x: &Vec<Complex64>) -> Result<Vec<Complex64>, &'static str>
pub fn vecmul(&self, x: &Vec<Complex64>) -> Result<Vec<Complex64>, &'static str>
Multiply by Vec
pub fn res( &self, x: &Vec<Complex64>, rhs: &Vec<Complex64>, ) -> Result<Vec<Complex64>, &'static str>
Sourcepub fn get_elem(&self, row: usize, col: usize) -> Option<Eindex>
pub fn get_elem(&self, row: usize, col: usize) -> Option<Eindex>
Returns the Element-index at (row, col) if present, or None if not.
Sourcepub fn get(&self, row: usize, col: usize) -> Option<Complex64>
pub fn get(&self, row: usize, col: usize) -> Option<Complex64>
Returns the Element-value at (row, col) if present, or None if not.
Sourcepub fn solve(
&mut self,
rhs: &[Complex64],
) -> Result<Vec<Complex64>, &'static str>
pub fn solve( &mut self, rhs: &[Complex64], ) -> Result<Vec<Complex64>, &'static str>
Solve the system Ax=b, where:
Aisselfbis argumentrhsxis the return value.
Returns a Result containing the Vec<Complex64> representing x if successful.
Returns an Err if unsuccessful.
Performs LU factorization, forward and backward substitution.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more