Skip to main content

SupernodalLdl

Struct SupernodalLdl 

Source
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: SupernodalOptions

Amalgamation and path-selection options.

Implementations§

Source§

impl<T: Real, K: DenseKernel<T>> SupernodalLdl<T, K>

Source

pub fn new(kernel: K, opts: SupernodalOptions) -> Self

A solver with the given dense kernel and options.

Source

pub fn kernel(&self) -> &K

The dense kernel.

Trait Implementations§

Source§

impl<T: Clone + Real, K: Clone + DenseKernel<T>> Clone for SupernodalLdl<T, K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Real, K: DenseKernel<T> + Default> Default for SupernodalLdl<T, K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Real, K: DenseKernel<T>> KktSolver<T> for SupernodalLdl<T, K>

Source§

type Symbolic = SymbolicLdl

The result of the symbolic phase.
Source§

type Numeric = NumericLdl<T>

The result of the numeric phase.
Source§

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>

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])

x ← F⁻¹ x in place, dense, with F the regularized factor. Read more
Source§

fn nnz_factor(&self, numeric: &NumericLdl<T>) -> usize

Nonzeros of the factor (for the IPM log).
Source§

fn name(&self) -> &'static str

A short name for logs and tables.
Source§

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

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 more

Auto Trait Implementations§

§

impl<T, K> Freeze for SupernodalLdl<T, K>
where K: Freeze,

§

impl<T, K> RefUnwindSafe for SupernodalLdl<T, K>

§

impl<T, K> Send for SupernodalLdl<T, K>
where K: Send, T: Send,

§

impl<T, K> Sync for SupernodalLdl<T, K>
where K: Sync, T: Sync,

§

impl<T, K> Unpin for SupernodalLdl<T, K>
where K: Unpin, T: Unpin,

§

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

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.