Skip to main content

BlockPenaltyOp

Struct BlockPenaltyOp 

Source
pub struct BlockPenaltyOp {
    pub k: usize,
    pub blocks: Vec<(usize, Array2<f64>)>,
}
Expand description

Block-local penalty operator: applies per-block penalty matrices (matching ParameterBlockSpec boundaries) without materialising a full K×K dense matrix.

Each entry is (global_offset, local_matrix) where global_offset is the start of that block in the full β vector.

Fields§

§k: usize

Full β dimension K.

§blocks: Vec<(usize, Array2<f64>)>

(global_start, local_matrix) for each atom/block.

Trait Implementations§

Source§

impl BetaPenaltyOp for BlockPenaltyOp

Source§

fn dim(&self) -> usize

Full dimension K of the β vector.
Source§

fn matvec(&self, x: &[f64], y: &mut [f64])

y += P x — penalty Hessian-vector product (length K).
Source§

fn gradient(&self, beta: &[f64], out: &mut [f64])

Penalty gradient: out += P β.
Source§

fn diagonal(&self, diag: &mut [f64])

diag += diag(P) — diagonal entries used by Jacobi preconditioner.
Source§

fn block( &self, id: BetaBlockId, offsets: &[Range<usize>], out: &mut Array2<f64>, )

Add the b×b dense penalty sub-block for block id into out (row-major, block size b = offsets[id.0].len()). Used by the block-Jacobi Schur preconditioner (#287).
Source§

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

Materialize the full K×K dense penalty matrix (needed by Direct / SqrtBA modes that form the Schur complement explicitly).
Source§

fn fingerprint(&self, hasher: &mut Fingerprinter)

Mix the operator’s defining state into hasher for cache-validity fingerprinting. Must change whenever matvec / to_dense would change, so the factorization / evidence cache (cache_matches_system) is invalidated when the β-block content changes. Implementations hash their own compact defining data (e.g. Kronecker factors, block matrices) rather than the full K×K dense form, which would defeat the structured operator’s storage savings.
Source§

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

Per-row absolute-value sums out[r] = Σ_c |P[r,c]|, the row contribution to the operator’s -norm. The default folds to_dense(), which costs an O(K²) materialization; structured operators override this to fold their compact factors directly so the backward-error certificate’s arrow_operator_infinity_norm never builds a dense K×K matrix on the SAE LLM-border critical path (#1017). Overrides MUST agree bit-for-bit with the to_dense() row sums (verified by the cross-check tests).

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