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
impl ClosedFormPenaltyOperator
Sourcepub 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
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.
Sourcepub fn dim(&self) -> usize
pub fn dim(&self) -> usize
Number of columns after applying constraint composition: the dimension that callers see when invoking matvec/dense_form.
Sourcepub fn matvec(&self, w: ArrayView1<'_, f64>, out: ArrayViewMut1<'_, f64>)
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:
u = T w(dim → total_pre)u_kernel = u[..kernel_cols]; u_poly = u[kernel_cols..]v = Z u_kernel(kernel_cols → K)y = S_raw v(K → K), via on-the-fly pair-block evaluationy_kernel = Z^T y(K → kernel_cols)- compose with zero polynomial block, then
out = T^T [y_kernel; 0]
Sourcepub fn diag(&self) -> Array1<f64>
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].
Sourcepub fn trace(&self) -> f64
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.
Sourcepub fn log_det_plus_lambda_i(&self, lambda: f64) -> Result<f64, String>
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.
Sourcepub fn dense_form(&self) -> Array2<f64>
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
impl Clone for ClosedFormPenaltyOperator
Source§impl PenaltyOp for ClosedFormPenaltyOperator
impl PenaltyOp for ClosedFormPenaltyOperator
Source§fn matvec(&self, w: ArrayView1<'_, f64>, out: ArrayViewMut1<'_, f64>)
fn matvec(&self, w: ArrayView1<'_, f64>, out: ArrayViewMut1<'_, f64>)
out = S w.Source§fn log_det_plus_lambda_i(&self, lambda: f64) -> Result<f64, String>
fn log_det_plus_lambda_i(&self, lambda: f64) -> Result<f64, String>
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>
fn as_dense(&self) -> Array2<f64>
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>
fn eigendecompose(&self) -> Result<(Array1<f64>, Array2<f64>), String>
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§
impl !Freeze for ClosedFormPenaltyOperator
impl RefUnwindSafe for ClosedFormPenaltyOperator
impl Send for ClosedFormPenaltyOperator
impl Sync for ClosedFormPenaltyOperator
impl Unpin for ClosedFormPenaltyOperator
impl UnsafeUnpin for ClosedFormPenaltyOperator
impl UnwindSafe for ClosedFormPenaltyOperator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.