Skip to main content

KluNativeSystem

Struct KluNativeSystem 

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

A real sparse system whose sparsity pattern is fixed across repeated solves — the pure-Rust twin of sparse_klu::KluRealSystem, same public shape (new/factor_and_solve) so solver.rs can dispatch to either backend mechanically. Caches the symbolic analysis (analyze::analyze) and numeric factorization (factor::Numeric) across calls, using refactor::refactor for cheap numeric-only re-factorization on repeat calls — mirrors KluRealSystem’s own doc comment and the same pattern validated for RealSparseSystem/BlockLu::refactor elsewhere in this crate.

Implementations§

Source§

impl KluNativeSystem

Source

pub fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>

Builds the symbolic factorization from an initial sparsity pattern and factors it once. Subsequent calls to factor_and_solve must supply entries with the exact same (row, col) pairs in the exact same order (values may differ) — same precondition as KluRealSystem::new, for the same reason (the cached CSC position mapping in groups assumes positional correspondence, not just set equality). Scales rows as SuiteSparse’s KLU does by default (see the module documentation). Returns None if the matrix is structurally or numerically singular.

Source

pub fn with_scale( n: usize, entries: &[(usize, usize, f64)], scale: i32, ) -> Option<Self>

new with KLU’s row scaling: scale is Common->scale (2 divides each row by its largest magnitude, KLU’s default; 1 by its sum; 0 does not scale). As in klu_factor.c and klu_refactor.c, the factors are recomputed from every new set of values, each value is divided by its row’s, and the solve divides the right-hand side by the same, so the solution is unchanged: scaling only decides which pivots partial pivoting sees as large, and how the arithmetic rounds.

Source

pub fn factor_and_solve( &mut self, entries: &[(usize, usize, f64)], rhs: &[f64], ) -> Option<Vec<f64>>

Numeric-only refactorization against the cached symbolic pattern, then solves A x = b. Returns None if the matrix is singular (or the solve produces a non-finite result, matching KluRealSystem’s own finite-check — a pure-Rust factorization has no common.status/KLU_SINGULAR to check directly, so a non-finite entry is this port’s only symptom of an ill-conditioned refactor that a fixed pattern still let through).

Source

pub fn adopt_storage_order(&mut self) -> Option<Vec<usize>>

From now on takes values in this system’s own storage order and refactors them without copying: returns order, where order[k] is the input index (in the order new was given) that position k holds. The caller reorders its values to match, once, and keeps them so. None, changing nothing, if some position sums several inputs.

Trait Implementations§

Source§

impl LinearSolver for KluNativeSystem

Source§

fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>

Analyzes entries’ sparsity pattern (fill-reducing ordering, elimination structure) and factors it once. None if the pattern is structurally invalid or the matrix is singular.
Source§

fn factor_and_solve( &mut self, entries: &[(usize, usize, f64)], rhs: &[f64], ) -> Option<Vec<f64>>

Numeric-only refactorization against the cached pattern, then solves A x = b. None if the matrix is singular at these values.
Source§

fn factor_and_solve_values( &mut self, values: &[f64], rhs: &[f64], ) -> Option<Vec<f64>>

As factor_and_solve, but taking only the nonzero values, positionally matching the entries passed to new. 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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V