Skip to main content

DenseSpectralOperator

Struct DenseSpectralOperator 

Source
pub struct DenseSpectralOperator { /* private fields */ }
Expand description

Dense spectral Hessian operator using eigendecomposition.

Computes logdet, trace, and solve from a single eigendecomposition, guaranteeing spectral consistency. Indefinite or near-singular eigenvalues are handled via smooth spectral regularization r_ε(σ) rather than hard clamping, ensuring that logdet and inverse use the same smooth mapping.

Implementations§

Source§

impl DenseSpectralOperator

Source

pub fn from_symmetric(h: &Array2<f64>) -> Result<Self, String>

Create from a symmetric matrix (may be indefinite or singular).

The eigendecomposition is computed once. Eigenvalues are smoothly regularized via r_ε(σ). All subsequent operations (logdet, trace, solve) use the regularized spectrum, ensuring mathematical consistency.

Source

pub fn from_symmetric_with_mode( h: &Array2<f64>, mode: PseudoLogdetMode, ) -> Result<Self, String>

Variant of from_symmetric that selects the log-determinant convention.

See PseudoLogdetMode for the derivation and the exact set of kernels that differ between the two modes. At a high level: Smooth keeps every eigenpair in play with a soft floor, whereas HardPseudo masks out σ_j ≤ ε consistently across logdet, gradient traces, cross-traces, and the H⁻¹ kernels.

Source

pub fn logdet_gradient_factor(&self) -> &Array2<f64>

Factor F satisfying trace(G_epsilon(H) A) = trace(F^T A F).

Structured row-local operators use this to contract the logdet-gradient trace directly in row space without forming A F in coefficient space.

Trait Implementations§

Source§

impl HessianOperator for DenseSpectralOperator

Source§

fn logdet(&self) -> f64

log|H|₊ — pseudo-logdet using only active eigenvalues/pivots.
Source§

fn as_exact_dense_spectral(&self) -> Option<&DenseSpectralOperator>

Exact dense spectral representation, when this backend has one. Read more
Source§

fn assemble_h_dense_for_tangent_projection(&self) -> Result<Array2<f64>, String>

Assemble the raw dense Hessian represented by this backend for active-constraint tangent projection. Read more
Source§

fn trace_hinv_product(&self, a: &Array2<f64>) -> f64

tr(H₊⁻¹ A) — trace of pseudo-inverse times a symmetric matrix. Uses the SAME decomposition as logdet.
Source§

fn solve(&self, rhs: &Array1<f64>) -> Array1<f64>

H⁻¹ v — linear solve using the active decomposition.
Source§

fn solve_multi(&self, rhs: &Array2<f64>) -> Array2<f64>

H⁻¹ M — multi-column solve.
Source§

fn trace_hinv_product_cross(&self, a: &Array2<f64>, b: &Array2<f64>) -> f64

tr(H⁻¹ A H⁻¹ B) for dense symmetric Hessian drifts. Read more
Source§

fn trace_hinv_operator(&self, op: &dyn HyperOperator) -> f64

tr(H₊⁻¹ B) for an operator-backed Hessian drift. Read more
Source§

fn trace_hinv_matrix_operator_cross( &self, matrix: &Array2<f64>, op: &dyn HyperOperator, ) -> f64

tr(H⁻¹ A H⁻¹ B) for a dense drift A and an operator-backed drift B. Read more
Source§

fn trace_hinv_operator_cross( &self, left: &dyn HyperOperator, right: &dyn HyperOperator, ) -> f64

tr(H⁻¹ A H⁻¹ B) for operator-backed Hessian drifts. Read more
Source§

fn trace_logdet_gradient(&self, a: &Array2<f64>) -> f64

tr(G_ε(H) A) — trace for the logdet gradient ∂_i log|R_ε(H)|. Read more
Source§

fn xt_logdet_kernel_x_diagonal(&self, x: &DesignMatrix) -> Array1<f64>

diag(X · G_ε(H) · Xᵀ) — the leverage corresponding to trace_logdet_gradient. trace_logdet_gradient(Xᵀ diag(w) X) = Σᵢ wᵢ · h^G[i]. Read more
Source§

fn trace_logdet_block_local( &self, block: &Array2<f64>, scale: f64, start: usize, end: usize, ) -> f64

tr(G_ε(H) · A_block) where A_block is a p_block × p_block matrix embedded at rows/columns [start..end]. Read more
Source§

fn trace_logdet_operator(&self, op: &dyn HyperOperator) -> f64

tr(G_ε(H) B) for an operator-backed Hessian drift. Read more
Source§

fn trace_logdet_hessian_cross( &self, h_i: &Array2<f64>, h_j: &Array2<f64>, ) -> f64

Cross-trace for the logdet Hessian: ∂²_{ij} log|R_ε(H)| = tr(G_ε Ḧ_{ij}) + spectral_cross(Ḣ_i, Ḣ_j). Read more
Source§

fn trace_logdet_hessian_cross_matrix_operator( &self, h_i: &Array2<f64>, h_j: &dyn HyperOperator, ) -> f64

Operator-backed mixed form of [trace_logdet_hessian_cross]. Read more
Source§

fn trace_logdet_hessian_cross_operator( &self, h_i: &dyn HyperOperator, h_j: &dyn HyperOperator, ) -> f64

Operator-backed form of [trace_logdet_hessian_cross]. Read more
Source§

fn active_rank(&self) -> usize

Number of active dimensions (rank of pseudo-inverse).
Source§

fn dim(&self) -> usize

Full dimension of H.
Source§

fn is_dense(&self) -> bool

Whether this operator is backed by a dense factorization. Read more
Source§

fn prefers_stochastic_trace_estimation(&self) -> bool

Whether the unified evaluator should batch large trace computations through the stochastic Hutchinson path for this operator. Read more
Source§

fn logdet_traces_match_hinv_kernel(&self) -> bool

Whether stochastic Hutchinson estimates based on H⁻¹ are valid for logdet-gradient / logdet-Hessian trace terms on this backend. Read more
Source§

fn as_dense_spectral(&self) -> Option<&DenseSpectralOperator>

Access the dense spectral backend when this operator is powered by a single eigendecomposition.
Source§

fn stochastic_trace_solve(&self, rhs: &Array1<f64>, rel_tol: f64) -> Array1<f64>

H⁻¹ v for stochastic trace probes. Read more
Source§

fn stochastic_trace_solve_for_probe( &self, rhs: &Array1<f64>, rel_tol: f64, probe_id: u64, state: Option<&Arc<Mutex<StochasticTraceState>>>, ) -> Array1<f64>

H⁻¹ v for a deterministic stochastic trace probe id. Read more
Source§

fn stochastic_trace_solve_multi( &self, rhs: &Array2<f64>, rel_tol: f64, ) -> Array2<f64>

H⁻¹ M for stochastic trace probes.
Source§

fn has_matrix_free_trace_cg_operator(&self) -> bool

Whether this backend exposes a matrix-free operator usable by trace CG.
Source§

fn trace_logdet_h_k( &self, a_k: &Array2<f64>, third_deriv_correction: Option<&Array2<f64>>, ) -> f64

Efficient computation of tr(G_ε(H) Hₖ) for the logdet gradient. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V