pub struct SupernodalLdl<T: Real = f64, K: DenseKernel<T> = NaiveDense> {
pub opts: SupernodalOptions,
/* private fields */
}Expand description
Our own supernodal LDLᵀ (D10; Chapter 5.17): analyze (ordering,
elimination tree, relaxed supernodes, pattern of L), factorize
(left-looking supernodal with the dense kernel K on the diagonal and
update blocks, pivot bumping with the expected signs, regularization
policy of Chapter 5.14), solve (block forward/diagonal/backward sweeps
without allocation). Generic in the scalar T; K is NaiveDense
by default and FaerDense with the faer feature.
use xingo_sparse::{Amd, Col, CscMatrix, KktForm, KktSolver, Refinement, Regularization, Row, SupernodalLdl};
// K = [−D, Aᵀ; A, 0] with D = diag(1, 2), A = [1 1]: lower triangle.
let k = CscMatrix::from_triplets(3, 3, &[
(Row(0), Col(0), -1.0), (Row(2), Col(0), 1.0),
(Row(1), Col(1), -2.0), (Row(2), Col(1), 1.0),
])
.unwrap();
let form = KktForm::Augmented { n_primal: 2, n_dual: 1 };
let solver = SupernodalLdl::<f64>::default(); // NaiveDense kernels, no dependency
let sym = solver.analyze(&k.pattern(), form, &Amd::default()).unwrap();
let (num, inertia) = solver.factorize(&sym, &k, Regularization::default()).unwrap();
assert_eq!(inertia, form.expected_inertia(3)); // (S6): 1 positive, 2 negative
let b = [1.0, 0.0, 3.0];
let mut x = [0.0; 3];
let report = solver.solve_refined(&num, &k, &b, &mut x, Refinement::default());
assert!(report.converged && report.residual <= 1e-12);Fields§
§opts: SupernodalOptionsAmalgamation and path-selection options.
Implementations§
Source§impl<T: Real, K: DenseKernel<T>> SupernodalLdl<T, K>
impl<T: Real, K: DenseKernel<T>> SupernodalLdl<T, K>
Trait Implementations§
Source§impl<T: Clone + Real, K: Clone + DenseKernel<T>> Clone for SupernodalLdl<T, K>
impl<T: Clone + Real, K: Clone + DenseKernel<T>> Clone for SupernodalLdl<T, K>
impl<T: Copy + Real, K: Copy + DenseKernel<T>> Copy for SupernodalLdl<T, K>
Source§impl<T: Debug + Real, K: Debug + DenseKernel<T>> Debug for SupernodalLdl<T, K>
impl<T: Debug + Real, K: Debug + DenseKernel<T>> Debug for SupernodalLdl<T, K>
Source§impl<T: Real, K: DenseKernel<T> + Default> Default for SupernodalLdl<T, K>
impl<T: Real, K: DenseKernel<T> + Default> Default for SupernodalLdl<T, K>
Source§impl<T: Real, K: DenseKernel<T>> KktSolver<T> for SupernodalLdl<T, K>
impl<T: Real, K: DenseKernel<T>> KktSolver<T> for SupernodalLdl<T, K>
Source§type Symbolic = SymbolicLdl
type Symbolic = SymbolicLdl
The result of the symbolic phase.
Source§type Numeric = NumericLdl<T>
type Numeric = NumericLdl<T>
The result of the numeric phase.
Source§fn analyze(
&self,
pattern: &Pattern,
form: KktForm,
ordering: &dyn Ordering,
) -> Result<SymbolicLdl, KktError>
fn analyze( &self, pattern: &Pattern, form: KktForm, ordering: &dyn Ordering, ) -> Result<SymbolicLdl, KktError>
Symbolic phase on the lower triangle of
pattern (plus a full
diagonal) with the given ordering; done once per pattern.Source§fn factorize(
&self,
symbolic: &SymbolicLdl,
k: &CscMatrix<T>,
reg: Regularization<T>,
) -> Result<(NumericLdl<T>, Inertia), KktError>
fn factorize( &self, symbolic: &SymbolicLdl, k: &CscMatrix<T>, reg: Regularization<T>, ) -> Result<(NumericLdl<T>, Inertia), KktError>
Numeric phase on the lower triangle of
k (inside the analyzed
pattern) with regularization (Algorithm K); returns the factor and
its inertia (S6).Source§fn solve(&self, numeric: &NumericLdl<T>, x: &mut [T])
fn solve(&self, numeric: &NumericLdl<T>, x: &mut [T])
Source§fn nnz_factor(&self, numeric: &NumericLdl<T>) -> usize
fn nnz_factor(&self, numeric: &NumericLdl<T>) -> usize
Nonzeros of the factor (for the IPM log).
Source§fn solve_refined(
&self,
numeric: &Self::Numeric,
k: &CscMatrix<T>,
b: &[T],
x: &mut [T],
refinement: Refinement<T>,
) -> RefineReport<T>
fn solve_refined( &self, numeric: &Self::Numeric, k: &CscMatrix<T>, b: &[T], x: &mut [T], refinement: Refinement<T>, ) -> RefineReport<T>
Solve followed by iterative refinement against
k (Algorithm F);
keeps the best iterate (S7). k is the matrix to be solved — the
unregularized one the factor approximates, or any other with the
same order; only its lower triangle is read. x is overwritten.
Allocates its work vectors; KktSolver::solve_refined_with
reuses them. Read moreSource§fn solve_refined_with(
&self,
numeric: &Self::Numeric,
k: &CscMatrix<T>,
b: &[T],
x: &mut [T],
refinement: Refinement<T>,
work: &mut RefineWorkspace<T>,
) -> RefineReport<T>
fn solve_refined_with( &self, numeric: &Self::Numeric, k: &CscMatrix<T>, b: &[T], x: &mut [T], refinement: Refinement<T>, work: &mut RefineWorkspace<T>, ) -> RefineReport<T>
KktSolver::solve_refined with caller-owned work vectors: once
work has served a call with the same order and budget, the
refinement allocates nothing. Read moreAuto Trait Implementations§
impl<T, K> Freeze for SupernodalLdl<T, K>where
K: Freeze,
impl<T, K> RefUnwindSafe for SupernodalLdl<T, K>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, K> Send for SupernodalLdl<T, K>
impl<T, K> Sync for SupernodalLdl<T, K>
impl<T, K> Unpin for SupernodalLdl<T, K>
impl<T, K> UnsafeUnpin for SupernodalLdl<T, K>where
K: UnsafeUnpin,
impl<T, K> UnwindSafe for SupernodalLdl<T, K>where
K: UnwindSafe,
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more