Matrix

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, Complex64)>) -> 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: Complex64)

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

Source

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.

Source

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

Source

pub fn reset(&mut self)

Reset all Elements to zero value.

Source

pub fn update(&mut self, ei: Eindex, val: Complex64)

Update Element ei by val

Source

pub fn vecmul(&self, x: &Vec<Complex64>) -> Result<Vec<Complex64>, &'static str>

Multiply by Vec

Source

pub fn res( &self, x: &Vec<Complex64>, rhs: &Vec<Complex64>, ) -> Result<Vec<Complex64>, &'static str>

Source

pub fn get_elem(&self, row: usize, col: usize) -> Option<Eindex>

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

Source

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

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

Source

pub fn solve( &mut self, rhs: &[Complex64], ) -> Result<Vec<Complex64>, &'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<Complex64> representing x if successful. Returns an Err if unsuccessful.

Performs LU factorization, forward and backward substitution.

Trait Implementations§

Source§

impl Debug for Matrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Index<Eindex> for Matrix

Source§

type Output = Element

The returned type after indexing.
Source§

fn index(&self, index: Eindex) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Eindex> for Matrix

Source§

fn index_mut(&mut self, index: Eindex) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

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.