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>
impl<I: KluIndex, D: KluData> FixedKluMatrix<I, D>
Sourcepub fn into_alloc(self) -> Vec<D>
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
Sourcepub fn new_with_alloc(spec: Rc<KluMatrixSpec<I>>, alloc: Vec<D>) -> Option<Self>
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
Sourcepub fn new(spec: Rc<KluMatrixSpec<I>>) -> Option<Self>
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
pub fn data(&self) -> &[Cell<D>]
Sourcepub fn data_ptr(&self) -> *mut D
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>
pub fn write_all(&self, val: D)
pub fn write_zero(&self)
Sourcepub fn lu_factorize(&mut self, refactor_threshold: Option<f64>) -> bool
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]
Sourcepub fn solve_linear_system(&self, rhs: &mut [D])
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.
Sourcepub fn solve_linear_tranose_system(&self, rhs: &mut [D])
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.