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
impl KluNativeSystem
Sourcepub fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>
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.
Sourcepub fn with_scale(
n: usize,
entries: &[(usize, usize, f64)],
scale: i32,
) -> Option<Self>
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.
Sourcepub fn factor_and_solve(
&mut self,
entries: &[(usize, usize, f64)],
rhs: &[f64],
) -> Option<Vec<f64>>
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).
Sourcepub fn adopt_storage_order(&mut self) -> Option<Vec<usize>>
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
impl LinearSolver for KluNativeSystem
Source§fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>
fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>
entries’ sparsity pattern (fill-reducing ordering,
elimination structure) and factors it once. None if the pattern is
structurally invalid or the matrix is singular.Auto Trait Implementations§
impl Freeze for KluNativeSystem
impl RefUnwindSafe for KluNativeSystem
impl Send for KluNativeSystem
impl Sync for KluNativeSystem
impl Unpin for KluNativeSystem
impl UnsafeUnpin for KluNativeSystem
impl UnwindSafe for KluNativeSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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