FixedKluMatrix

Struct FixedKluMatrix 

Source
pub struct FixedKluMatrix<I: KluIndex, D: KluData> { /* private fields */ }
Expand description

A compressed column form SparsMatrix whose shape is fixed

Implementations§

Source§

impl<I: KluIndex, D: KluData> FixedKluMatrix<I, D>

Source

pub fn into_alloc(self) -> Vec<D>

Obtain the allocation of the matrix data This function can be used with [from_raw] and KluMatrixSpec::reinit to reuse a matrix allocation.

§Safety

This function invalidates any pointers into the matrix

Source

pub fn new_with_alloc(spec: Rc<KluMatrixSpec<I>>, alloc: Vec<D>) -> Option<Self>

Constructs a new matrix for the provided KluMatrixSpec<I>. alloc is used to store the data. If not enough space is available alloc is resized as required.

The matrix is always intially filled with zeros no matter the previous content of alloc

§Returns

the constructed matrix if the matrix is not empty. If the matrix is empty None is retruned instead

Source

pub fn new(spec: Rc<KluMatrixSpec<I>>) -> Option<Self>

Constructs a new matrix for the provided KluMatrixSpec<I> by allocating space where the data can be stored.

The matrix is intially filled with zeros.

§Returns

the constructed matrix if the matrix is not empty. If the matrix is empty None is retruned instead

Source

pub fn data(&self) -> &[Cell<D>]

Source

pub fn data_ptr(&self) -> *mut D

Returns a pointer to the matrix data

§Safety

The returned pointer must never be dereferenced. Turing this data into any reference always causes undefined behaviour

This pointer point to data inside an UnsafeCell so you should use std::ptr methods to access it or turn it into &Cell<D> or &UnsafeCell<D>

Source

pub fn write_all(&self, val: D)

Source

pub fn write_zero(&self)

Source

pub fn lu_factorize(&mut self, refactor_threshold: Option<f64>) -> bool

Perform lu_factorization of the matrix using KLU If the matrix was already factorized previously and refactor_threshold is given, it is first attempted to refactorize the matrix. If this fails (either due to an KLU error or because the rcond is larger than the provided threshold) full factorization is preformed.

Calling to funciton is a prerequisite to calling [solve_linear_system]

Source

pub fn solve_linear_system(&self, rhs: &mut [D])

solves the linear system Ax=b. The b vector is read from rhs at the beginning of the function. After the functin completes x was written into rhs

Note: This function assumes that [lu_factorize] was called first. If this is not the case this functions panics.

Source

pub fn solve_linear_tranose_system(&self, rhs: &mut [D])

solves the linear system A^T x=b The b vector is read from rhs at the beginning of the function. After the functin completes x was written into rhs

Note: This function assumes that [lu_factorize] was called first. If this is not the case this functions panics.

Source

pub fn get(&self, column: I, row: I) -> Option<&Cell<D>>

Trait Implementations§

Source§

impl<I: KluIndex, D: KluData> Drop for FixedKluMatrix<I, D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<I: KluIndex, D: KluData> Index<(I, I)> for FixedKluMatrix<I, D>

Source§

type Output = Cell<D>

The returned type after indexing.
Source§

fn index(&self, (column, row): (I, I)) -> &Self::Output

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

impl<I: KluIndex, D: KluData> Index<usize> for FixedKluMatrix<I, D>

Source§

type Output = Cell<D>

The returned type after indexing.
Source§

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

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

Auto Trait Implementations§

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.