Skip to main content

PsiGramTensor

Struct PsiGramTensor 

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

Certified Chebyshev-in-ψ expansion of a design-moving Gram (#1033b).

Holds the one-time Chebyshev sufficient-statistic series; every per-trial accessor is O(Dk²) or cheaper and never touches n rows again.

Implementations§

Source§

impl PsiGramTensor

Source

pub fn build( eval_design: impl FnMut(f64) -> Result<Array2<f64>, String>, weights: ArrayView1<'_, f64>, z: ArrayView1<'_, f64>, psi_lo: f64, psi_hi: f64, ) -> Result<Self, String>

Build and certify the tensor over psi ∈ [psi_lo, psi_hi].

eval_design(psi) must return the EXACT n×k design at psi (the same builder the per-trial path uses — exactness of the expansion is judged against it). weights are the fixed observation weights, z the fixed weighted-response target (e.g. y − offset). Returns None when the window is degenerate, any evaluation fails/has non-finite entries, or no ladder rung certifies — callers then keep the exact per-trial path.

Source

pub fn reduced_basis_equal(&self, psi_ref: f64, psi_new: f64) -> bool

True when the realized reduced basis the design-revision fast path freezes at the pinning psi_ref is still valid at psi_new — the genuine reduced-basis-equality witness the skip requires (#1264, #1216 item 3).

The fast path keeps the reference surface (its conditioned frame and its RRQR-reduced / null-space basis) frozen at psi_ref while re-keying only the Gram XᵀWX(ψ) and penalty S(ψ) to psi_new. That is exact iff the reduced basis — the range / null split of the conditioned data Gram — is unchanged. A conditioning-ratio or RRQR rank/permutation gate only bounds NECESSARY conditions; the reduced SUBSPACE can still rotate while rank and pivot order look tame, which is exactly the ~7.8e-2 β̂ regression a cluster run found. This witness compares the orthogonal RANGE PROJECTORS of the conditioned Gram at psi_ref and psi_new (both assembled n-free from the tensor): the skip is sound only when the numerical ranks match AND the projectors agree to proj_atol in max-norm — i.e. the two reduced bases span the SAME subspace. The projector identity is gauge-invariant, so it certifies subspace equality directly rather than a particular basis choice.

psi_ref == psi_new (a repeat trial at the same ψ) is trivially sound. Off-window ψ’s, a non-finite / rank-degenerate Gram, or any eigendecomp failure return false (refuse the skip → caller takes the slow path).

ROTATION WALL (#1033). On production spatial geometry the conditioned data-Gram range subspace can ROTATE with ψ at fixed rank — the wall on which the earlier RRQR-pivot / entrywise-projector gates kept refusing the skip. The fix is the SUBSPACE-DISTANCE certificate below: the skip is sound exactly when the two equal-rank ranges coincide as SUBSPACES, measured by the spectral norm of the projector difference (the principal angle), which is invariant to any orthonormal-basis rotation WITHIN the range. So a pure gauge rotation that left the entrywise max-abs above tolerance — and therefore used to be refused — now certifies, letting the n-free skip fire across the rotation. A genuine subspace MOVE (different rank, or a real principal-angle separation) still refuses; refusing is the SOUND fallback (the caller takes the exact slow path). Do not weaken PSI_GRAM_SKIP_PROJ_ATOL / PSI_GRAM_SKIP_RANK_RTOL: the spectral gate is already the tightest correct subspace metric, and loosening it past a true principal-angle separation reintroduces the ~7.8e-2 β̂ regression this witness exists to prevent.

Source

pub fn contains(&self, psi: f64) -> bool

True when psi lies inside the certified window.

Source

pub fn contains_for_gradient(&self, psi: f64) -> bool

True when psi lies inside the certified gradient window where the analytic ψ-derivative is bit-tight against the exact design derivative (#1033b). The n-free kappa outer loop is armed only when this covers the full optimizer bounds.

Source

pub fn gram_at(&self, psi: f64) -> Array2<f64>

XᵀWX(ψ) assembled n-free in O(Dk²) from the direct Gram series.

Source

pub fn rhs_at(&self, psi: f64) -> Array1<f64>

XᵀWz(ψ) assembled n-free in O(Dk).

Source

pub fn dgram_dpsi(&self, psi: f64) -> Array2<f64>

Exact ∂(XᵀWX)/∂ψ from the SAME representation as the value — the structural cure for the objective↔gradient desync class on this channel. n-free, O(Dk²) from the direct Gram series.

Source

pub fn drhs_dpsi(&self, psi: f64) -> Array1<f64>

Exact ∂(XᵀWz)/∂ψ, n-free.

Source

pub fn d2gram_dpsi2(&self, psi: f64) -> Array2<f64>

Exact ∂²(XᵀWX)/∂ψ² from the SAME representation as the value/gradient — the n-free curvature that lets the outer Newton/ARC step read the τ-τ Hessian’s design-moving block without re-streaming an O(n) slab Gram (#1033, Gaussian-identity single-ψ Hessian channel). O(Dk²) from the direct Gram series.

XᵀWX(ψ) = Σ_d T_d(x) G_d with x = mapped(ψ), so by the chain rule d²/dψ² = T_d″(x) · (dx/dψ)².

Source

pub fn d2rhs_dpsi2(&self, psi: f64) -> Array1<f64>

Exact ∂²(XᵀWz)/∂ψ², n-free. T_d″·(dx/dψ)² against the rhs slabs.

Source

pub fn gaussian_fixed_cache_at(&self, psi: f64) -> GaussianFixedCache

Assemble the Gaussian-identity sufficient-statistic cache at psi without touching a single data row — the bridge from this tensor into the inner PLS solver’s fast path (#1033b → GaussianFixedCache).

(XᵀWX, XᵀWz, zᵀWz) is everything the Gaussian penalized solve needs at any λ, so a ψ-trial that holds a certified tensor can hand the inner solver this cache instead of realizing the n×k design. The caller is responsible for contains(psi) (off-window trials fall back to the exact realizer path). Dense-path bridge only: the sparse scatter cache stays None.

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