pub struct Matrix { /* private fields */ }
Expand description
Sparse Matrix
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub fn from_entries(entries: Vec<(usize, usize, f64)>) -> Matrix
pub fn from_entries(entries: Vec<(usize, usize, f64)>) -> Matrix
Create a new Matrix
from a vector of (row, col, val) entries
.
Sourcepub fn add_element(&mut self, row: usize, col: usize, val: f64)
pub fn add_element(&mut self, row: usize, col: usize, val: f64)
Add an element at location (row, col)
with value val
.
Sourcepub fn add_elements(&mut self, elements: Vec<(usize, usize, f64)>)
pub fn add_elements(&mut self, elements: Vec<(usize, usize, f64)>)
Add elements correspoding to each triplet (row, col, val)
Rows and columns are usize
, and vals
are f64
.
Sourcepub fn get(&self, row: usize, col: usize) -> Option<f64>
pub fn get(&self, row: usize, col: usize) -> Option<f64>
Returns the Element-value at (row, col)
if present, or None if not.
Sourcepub fn solve(&mut self, rhs: Vec<f64>) -> Result<Vec<f64>, &'static str>
pub fn solve(&mut self, rhs: Vec<f64>) -> Result<Vec<f64>, &'static str>
Solve the system Ax=b
, where:
A
isself
b
is argumentrhs
x
is the return value.
Returns a Result
containing the Vec<f64>
representing x
if successful.
Returns an Err
if unsuccessful.
Performs LU factorization, forward and backward substitution.
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