Skip to main content

ClosedFormPenaltyOperator

Struct ClosedFormPenaltyOperator 

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

Matrix-free closed-form anisotropic Duchon penalty operator.

Stores the parameters of the closed-form pair-block (q, m, s, κ, η, knot centers, and optional constraint factors). The hot matvec path stays matrix-free; cached_dense is populated only by dense_form().

Implementations§

Source§

impl ClosedFormPenaltyOperator

Source

pub fn new( centers: ArrayView2<'_, f64>, q: usize, m: usize, s: usize, kappa: f64, aniso_log_scales: Option<&[f64]>, kernel_nullspace: Option<&Array2<f64>>, polynomial_block_cols: usize, outer_identifiability: Option<&Array2<f64>>, ) -> Self

Build an operator with the same closed-form parameters that basis::closed_form_operator_penalty_in_total_basis consumes.

Source

pub fn raw_dim(&self) -> usize

Number of raw kernel rows (K).

Source

pub fn dim(&self) -> usize

Number of columns after applying constraint composition: the dimension that callers see when invoking matvec/dense_form.

Source

pub fn matvec(&self, w: ArrayView1<'_, f64>, out: ArrayViewMut1<'_, f64>)

Evaluate (S w) writing the result into out.

With constraints composed, S' = T^T diag(Z, I_poly)^T S_raw diag(Z, I_poly) T. We apply the chain right-to-left:

  1. u = T w (dim → total_pre)
  2. u_kernel = u[..kernel_cols]; u_poly = u[kernel_cols..]
  3. v = Z u_kernel (kernel_cols → K)
  4. y = S_raw v (K → K), via on-the-fly pair-block evaluation
  5. y_kernel = Z^T y (K → kernel_cols)
  6. compose with zero polynomial block, then out = T^T [y_kernel; 0]
Source

pub fn diag(&self) -> Array1<f64>

Diagonal S[i,i] for i in 0..dim. In the raw layout this is the analytic self-pair repeated K times. With constraint composition the diagonal is not the K-space diagonal; we extract it via e_i^T S' e_i = matvec(e_i)[i].

Source

pub fn trace(&self) -> f64

Trace tr(S'). In raw layout this is K times the analytic self-pair; otherwise it uses the composed-basis diagonal.

Source

pub fn log_det_plus_lambda_i(&self, lambda: f64) -> Result<f64, String>

Exact log det(S' + λI). S' is rank-deficient under typical constraints (kernel/polynomial nullspace), so the regularization λ > 0 is mandatory.

Source

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

Materialize the full constrained operator as a dense Array2 for callers that explicitly request a matrix or for validation against closed_form_operator_penalty_in_total_basis. Uses the internal cache: the first call builds, subsequent calls clone from the cache.

Trait Implementations§

Source§

impl Clone for ClosedFormPenaltyOperator

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 PenaltyOp for ClosedFormPenaltyOperator

Source§

fn dim(&self) -> usize

Side length of the (square) operator.
Source§

fn matvec(&self, w: ArrayView1<'_, f64>, out: ArrayViewMut1<'_, f64>)

Apply the operator: out = S w.
Source§

fn diag(&self) -> Array1<f64>

Diagonal entries S[i,i].
Source§

fn trace(&self) -> f64

Trace tr(S) = Σ_i S[i,i].
Source§

fn log_det_plus_lambda_i(&self, lambda: f64) -> Result<f64, String>

Exact log det(S + λI) for λ > 0. S is allowed to be rank-deficient; the regularization makes the regularized operator strictly positive definite.
Source§

fn as_dense(&self) -> Array2<f64>

Materialize the operator as a dense matrix. Required for the existing analyze_penalty_block path and for callers that need a &Array2 view (Cholesky factorization, etc.). Implementations that already hold a dense form should return it cheaply.
Source§

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

Symmetric eigendecomposition S = V diag(λ) V^T. The default implementation materializes via as_dense and runs the same FaerEigh path the existing dense pipeline uses, which preserves numerical agreement with analyze_penalty_block. Implementations that have a faster path (Lanczos top-k for very large K) may override.

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

Source§

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

Source§

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

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,