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
impl PsiGramTensor
Sourcepub 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>
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.
Sourcepub fn reduced_basis_equal(&self, psi_ref: f64, psi_new: f64) -> bool
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.
Sourcepub fn contains_for_gradient(&self, psi: f64) -> bool
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.
Sourcepub fn gram_at(&self, psi: f64) -> Array2<f64>
pub fn gram_at(&self, psi: f64) -> Array2<f64>
XᵀWX(ψ) assembled n-free in O(Dk²) from the direct Gram series.
Sourcepub fn dgram_dpsi(&self, psi: f64) -> Array2<f64>
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.
Sourcepub fn d2gram_dpsi2(&self, psi: f64) -> Array2<f64>
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ψ)².
Sourcepub fn d2rhs_dpsi2(&self, psi: f64) -> Array1<f64>
pub fn d2rhs_dpsi2(&self, psi: f64) -> Array1<f64>
Exact ∂²(XᵀWz)/∂ψ², n-free. T_d″·(dx/dψ)² against the rhs slabs.
Sourcepub fn gaussian_fixed_cache_at(&self, psi: f64) -> GaussianFixedCache
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§
impl Freeze for PsiGramTensor
impl RefUnwindSafe for PsiGramTensor
impl Send for PsiGramTensor
impl Sync for PsiGramTensor
impl Unpin for PsiGramTensor
impl UnsafeUnpin for PsiGramTensor
impl UnwindSafe for PsiGramTensor
Blanket Implementations§
impl<T> Allocation for T
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> 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.