pub struct BlockwisePenalty {
pub col_range: Range<usize>,
pub local: Array2<f64>,
pub prior_mean: CoefficientPriorMean,
pub structure_hint: Option<PenaltyStructureHint>,
pub op: Option<Arc<dyn PenaltyOp>>,
}Expand description
A penalty matrix stored at its natural block size together with the column range it occupies in the global coefficient vector.
Instead of embedding every penalty into a full p_total × p_total dense
matrix filled with zeros, we keep the compact local matrix and reconstruct
the global view only when a downstream consumer explicitly requires it.
Fields§
§col_range: Range<usize>Column range in the global coefficient vector that this penalty covers.
local: Array2<f64>The local penalty matrix — dimensions block_p × block_p where
block_p = col_range.len().
prior_mean: CoefficientPriorMeanOptional nonzero centering vector for this coefficient block.
structure_hint: Option<PenaltyStructureHint>Optional structural hint so downstream spectral/logdet code can stay block-local or factorized without reverse-engineering the matrix.
op: Option<Arc<dyn PenaltyOp>>Optional operator-form handle bit-equivalent to local. Populated when
the originating closed-form factory emitted an op-form penalty so exact
operator algebra can use matvec instead of materializing the dense
block_p × block_p Gram. None for ordinary dense penalties.
Implementations§
Source§impl BlockwisePenalty
impl BlockwisePenalty
Sourcepub fn new(col_range: Range<usize>, local: Array2<f64>) -> Self
pub fn new(col_range: Range<usize>, local: Array2<f64>) -> Self
Create a new blockwise penalty.
pub fn with_prior_mean(self, prior_mean: CoefficientPriorMean) -> Self
Sourcepub fn with_op(self, op: Option<Arc<dyn PenaltyOp>>) -> Self
pub fn with_op(self, op: Option<Arc<dyn PenaltyOp>>) -> Self
Attach an op-form penalty handle bit-equivalent to local.
pub fn ridge(col_range: Range<usize>, scale: f64) -> Self
pub fn kronecker( col_range: Range<usize>, local: Array2<f64>, factors: Vec<Array2<f64>>, ) -> Self
Sourcepub fn to_global(&self, p_total: usize) -> Array2<f64>
pub fn to_global(&self, p_total: usize) -> Array2<f64>
Expand this blockwise penalty into a full p_total × p_total dense
matrix (mostly zeros). Use sparingly — the whole point of blockwise
storage is to avoid this allocation.
Sourcepub fn to_penalty_matrix(&self, total_dim: usize) -> PenaltyMatrix
pub fn to_penalty_matrix(&self, total_dim: usize) -> PenaltyMatrix
Convert into a blockwise gam_problem::PenaltyMatrix without
expanding to full dimensions.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
The block size of this penalty.
Trait Implementations§
Source§impl Clone for BlockwisePenalty
impl Clone for BlockwisePenalty
Source§fn clone(&self) -> BlockwisePenalty
fn clone(&self) -> BlockwisePenalty
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for BlockwisePenalty
impl !UnwindSafe for BlockwisePenalty
impl Freeze for BlockwisePenalty
impl Send for BlockwisePenalty
impl Sync for BlockwisePenalty
impl Unpin for BlockwisePenalty
impl UnsafeUnpin for BlockwisePenalty
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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,
impl<T, U> Imply<T> for U
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.