Struct Matrix

Source
pub struct Matrix { /* private fields */ }
Expand description

Sparse Matrix

Implementations§

Source§

impl Matrix

Source

pub fn new() -> Matrix

Create a new, initially empty Matrix

Source

pub fn from_entries(entries: Vec<(usize, usize, f64)>) -> Matrix

Create a new Matrix from a vector of (row, col, val) entries.

Source

pub fn identity(n: usize) -> Matrix

Create an n*n identity Matrix

Source

pub fn add_element(&mut self, row: usize, col: usize, val: f64)

Add an element at location (row, col) with value val.

Source

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.

Source

pub fn get(&self, row: usize, col: usize) -> Option<f64>

Returns the Element-value at (row, col) if present, or None if not.

Source

pub fn solve(&mut self, rhs: Vec<f64>) -> Result<Vec<f64>, &'static str>

Solve the system Ax=b, where:

  • A is self
  • b is argument rhs
  • 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.