Skip to main content

AssemblyBackend

Trait AssemblyBackend 

Source
pub trait AssemblyBackend: LinearizationMode {
    // Required methods
    fn assemble(
        problem: &Problem,
        variables: &SlotMap<VarKey, Box<dyn ManifoldVariable>>,
        variable_index_map: &SecondaryMap<VarKey, usize>,
        symbolic_structure: Option<&SymbolicStructure>,
        total_dof: usize,
    ) -> LinearizerResult<(Mat<f64>, Self::Jacobian)>;
    fn compute_column_norms(jacobian: &Self::Jacobian) -> Vec<f64>;
    fn apply_column_scaling(
        jacobian: &Self::Jacobian,
        scaling: &[f64],
    ) -> Self::Jacobian;
    fn apply_inverse_scaling(step: &Mat<f64>, scaling: &[f64]) -> Mat<f64>;
    fn hessian_vec_product(hessian: &Self::Hessian, vec: &Mat<f64>) -> Mat<f64>;
}
Expand description

Type-level backend for assembling (residuals, Jacobian) and performing matrix operations. Implemented by SparseMode and DenseMode.

All methods are static — this trait is used as a compile-time strategy selector, not as an object interface. Extends LinearizationMode with the five operations an optimizer needs each iteration: building (r, J), scaling J, unscaling dx, and H·v.

All three optimizers (LM, GN, DogLeg) are generic over M: AssemblyBackend, giving zero-cost static dispatch through the entire pipeline.

Required Methods§

Source

fn assemble( problem: &Problem, variables: &SlotMap<VarKey, Box<dyn ManifoldVariable>>, variable_index_map: &SecondaryMap<VarKey, usize>, symbolic_structure: Option<&SymbolicStructure>, total_dof: usize, ) -> LinearizerResult<(Mat<f64>, Self::Jacobian)>

Assemble residuals and Jacobian from the problem.

Source

fn compute_column_norms(jacobian: &Self::Jacobian) -> Vec<f64>

Compute column norms of the Jacobian (for Jacobi scaling).

Source

fn apply_column_scaling( jacobian: &Self::Jacobian, scaling: &[f64], ) -> Self::Jacobian

Apply diagonal column scaling to the Jacobian. Returns a new Jacobian with columns scaled by 1 / (1 + norm).

Source

fn apply_inverse_scaling(step: &Mat<f64>, scaling: &[f64]) -> Mat<f64>

Apply inverse scaling to a step vector: step_i *= scaling_i

Source

fn hessian_vec_product(hessian: &Self::Hessian, vec: &Mat<f64>) -> Mat<f64>

Hessian-vector product: H * v (needed by DogLeg for Cauchy point)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§