Skip to main content

DirectLagrangeSolver

Struct DirectLagrangeSolver 

Source
pub struct DirectLagrangeSolver {
    pub n: usize,
    /* private fields */
}
Expand description

Direct Lagrangian solver over an (N+1)x(N+1) augmented CSC system.

Mirrors Python solve_direct_lagrange: the augmented matrix is [[K, c], [c^T, 0]] assembled by assemble_torsion_lagrange, solved with RHS [f, 0]; the multiplier magnitude must satisfy |uN| / max|u| <= 1e-7.

Fields§

§n: usize

Size of the leading K block.

Implementations§

Source§

impl DirectLagrangeSolver

Source

pub fn assemble_torsion_lagrange(k: &SparseMatrix, c: &[f64]) -> CscMatrix

Assemble the augmented Lagrangian matrix exactly as Python Section.assemble_torsion does: [[K, c], [c^T, 0]] in CSC format.

Source

pub fn new(k: &SparseMatrix, c: &[f64]) -> Result<Self, FemError>

Factor using the default backend: the skyline LDL^T, which is self-contained and robust.

Source

pub fn with_kernel( kernel: LagrangeKernel, k: &SparseMatrix, c: &[f64], opts: SolverOptions, ) -> Result<Self, FemError>

Factor with an explicit kernel and options.

Source

pub fn solve(&self, f: &[f64]) -> Result<Vec<f64>, FemError>

Solve [K c; c^T 0] [u; lam] = [f; 0] and return u.

Source

pub fn solve_full(&self, f: &[f64]) -> Result<(Vec<f64>, f64), FemError>

Solve returning (u, lambda).

Source

pub fn multiplier_error(&self, f: &[f64], u: &[f64]) -> f64

Multiplier error metric |lam| / max|u| (Python’s u[-1]/max|u|).

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 = !

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.