Skip to main content

Factorization

Struct Factorization 

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

Value-typed handle holding a sparse symmetric factorization.

Construction (via Factorization::new) performs the symbolic + numeric factor; subsequent Factorization::solve calls are pure back-substitution. Factorization::refactor replaces the numeric values without redoing the symbolic work.

The matrix is supplied in triplet (COO) format with 1-based indices over the lower triangle — the universal denominator the trait expects. Backends that prefer CSR are fed via the standard TripletToCsrConverter inside the wrapper.

Implementations§

Source§

impl Factorization

Source

pub fn new( dim: Index, airn: Vec<Index>, ajcn: Vec<Index>, values: Vec<Number>, backend: Box<dyn SparseSymLinearSolverInterface>, ) -> Result<Self, FactorizationError>

Factor a new matrix. Pattern (airn, ajcn) and values are the lower-triangle triplet of A, 1-based indices, length nnz each. backend is any implementor (feral, MA57, …).

Performs both the symbolic and numeric factorization. Subsequent Self::solve calls are back-substitution only; Self::refactor redoes the numeric work but reuses the symbolic factor.

§Errors
§Panics

Panics if airn.len() != ajcn.len() or if values.len() != airn.len().

Source

pub fn solve( &mut self, rhs: &mut [Number], nrhs: usize, ) -> Result<(), FactorizationError>

Back-substitute against the cached factor. rhs packs nrhs columns (each length dim) in column-major layout; solutions overwrite rhs in place.

§Errors

FactorizationError::FatalError — backend solve failed.

§Panics

Panics if rhs.len() != dim * nrhs.

Source

pub fn solve_one( &mut self, rhs: &mut [Number], ) -> Result<(), FactorizationError>

Convenience for the common nrhs=1 case. Identical to solve(rhs, 1).

Source

pub fn refactor( &mut self, new_values: &[Number], ) -> Result<(), FactorizationError>

Replace the numeric values and refactor. Pattern is unchanged; the backend reuses its symbolic factor / AMD ordering.

§Errors

Same as Self::new.

§Panics

Panics if new_values.len() != nnz.

Source

pub fn number_of_neg_evals(&self) -> Option<Index>

Number of negative eigenvalues from the most recent factor, if the backend reports inertia. None otherwise.

Source

pub fn dim(&self) -> Index

Dimension n of the factored n × n matrix.

Source

pub fn nnz(&self) -> Index

Number of nonzeros in the triplet pattern.

Trait Implementations§

Source§

impl Debug for Factorization

Source§

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

Formats the value using the given formatter. 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.