Skip to main content

SpatialLogKappaCoords

Struct SpatialLogKappaCoords 

Source
pub struct SpatialLogKappaCoords {
    pub values: Array1<f64>,
    pub dims_per_term: Vec<usize>,
}

Fields§

§values: Array1<f64>

Flattened ψ values. For isotropic terms, one entry per term. For anisotropic terms, d entries per term (one ψ_a per axis).

§dims_per_term: Vec<usize>

Dimensionality of each term: 1 for isotropic, d for anisotropic.

Implementations§

Source§

impl SpatialLogKappaCoords

Source

pub fn new_with_dims(values: Array1<f64>, dims_per_term: Vec<usize>) -> Self

Construct from an explicit dims layout plus values.

Source

pub fn from_length_scales( spec: &TermCollectionSpec, term_indices: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Isotropic initialization (backward-compatible path).

Source

pub fn from_length_scales_aniso( spec: &TermCollectionSpec, term_indices: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Anisotropic-aware initialization.

Initialization strategy (per math team recommendation): standardize the knot cloud axiswise, then run the existing isotropic κ initializer in the standardized space. This reuses the trusted isotropic initializer and gives initial η_a = −ln(σ_a) + mean(ln(σ_a)), which satisfies Ση_a = 0 by construction.

For each term, checks whether it has aniso_log_scales set on its basis spec.

  • If isotropic (no aniso_log_scales, or 1-D): 1 entry = −ln(length_scale).
  • If anisotropic with a scalar length scale: d entries, one ψ_a per axis. Initialized as ψ_a = −ln(length_scale) + η_a where η_a are the existing aniso_log_scales (which sum to zero). Multi-dimensional terms without explicit anisotropy stay scalar here so the seed dimensionality matches spatial_dims_per_term.
  • If pure Duchon anisotropic: d - 1 free entries store the leading η_a values directly; the final axis is reconstructed to keep Ση_a = 0.
Source

pub fn lower_bounds_from_data( data: ArrayView2<'_, f64>, spec: &TermCollectionSpec, term_indices: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Isotropic lower bounds derived from per-term data geometry. Each entry gets the ψ_lo bound returned by spatial_term_psi_bounds for the corresponding term, intersected with the options window.

Source

pub fn upper_bounds_from_data( data: ArrayView2<'_, f64>, spec: &TermCollectionSpec, term_indices: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Isotropic upper bounds derived from per-term data geometry.

Source

pub fn lower_bounds_aniso_from_data( data: ArrayView2<'_, f64>, spec: &TermCollectionSpec, term_indices: &[usize], dims_per_term: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Anisotropic-aware lower bounds derived from per-term data geometry. For hybrid anisotropic terms the scalar ψ_lo bound applies to the mean ψ̄, not directly to every raw axis coordinate ψ_a = ψ̄ + η_a. Shift each axis by the current centered η_a so projecting/clamping the seed moves only the global scale direction and does not silently shrink anisotropy that is already consistent with the current length_scale.

Pure Duchon anisotropy is structurally different: its stored coordinates are (d-1) free η_a values representing log axis-scale ratios, NOT log-κ. For those terms the κ-range geometry bound is over-restrictive (η_a = ±5 is normal, but that corresponds to 7+ orders of magnitude in κ-space and would be rejected by the data window). Fall back to the options window [-ln(max_ls), -ln(min_ls)] for those coordinates — that’s the same bound the pre-data-geometry code used, which is calibrated to allow legitimate anisotropy.

Source

pub fn upper_bounds_aniso_from_data( data: ArrayView2<'_, f64>, spec: &TermCollectionSpec, term_indices: &[usize], dims_per_term: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Anisotropic-aware upper bounds derived from per-term data geometry. See lower_bounds_aniso_from_data for the hybrid-aniso offsetting and pure-Duchon dispatch rationale.

Source

pub fn reseed_from_data( self, data: ArrayView2<'_, f64>, spec: &TermCollectionSpec, term_indices: &[usize], options: &SpatialLengthScaleOptimizationOptions, ) -> Self

Rewrite any ψ entries whose originating term lacks an explicit length_scale so they sit at the midpoint of the per-term data-derived ψ window. Used so the outer optimizer starts inside the physically meaningful region instead of at an arbitrary options.max_length_scale derived seed. For terms with an explicit length_scale, the user’s choice is respected. Anisotropy offsets η_a (those stored by from_length_scales_aniso) are preserved: we re-center around the new ψ̄, keeping Ση_a = 0.

Source

pub fn clamp_to_bounds( self, lower: &SpatialLogKappaCoords, upper: &SpatialLogKappaCoords, ) -> Self

Project ψ values into [lower, upper] element-wise. Used after from_length_scales* + reseed_from_data when a user-supplied spec.length_scale falls outside the data-derived ψ window set by {lower,upper}_bounds*_from_data. BFGS requires theta0 ∈ [lower, upper]; projecting is the unique closest feasible seed. The user’s length_scale was always a hint for the outer optimizer (the optimizer is authoritative for κ), not a hard constraint — so clipping preserves their intent as far as the geometry allows. Emits log::info! when any coordinate moves, so the outside-window case is diagnostically visible (not silent).

Source

pub fn from_theta_tail_with_dims( theta: &Array1<f64>, start: usize, dims_per_term: Vec<usize>, ) -> Self

Reconstruct from theta tail with known dimensionality layout.

Source

pub fn len(&self) -> usize

Total number of ψ values in the flat array (= sum of dims_per_term).

Source

pub fn dims_per_term(&self) -> &[usize]

Dimensionality layout: how many ψ values each term contributes.

Source

pub fn term_slice(&self, term_idx: usize) -> &[f64]

Get the slice of ψ values for logical term i.

Source

pub fn as_array(&self) -> &Array1<f64>

Source

pub fn set_scalar_slot(&mut self, slot: usize, value: f64) -> bool

#1464: overwrite the single ψ value of a scalar (1-D) logical term by its position slot in this coords vector (the same ordering as the term_indices slice the constructors were built from). Used to inject the fixed-κ sign-basin seed into a constant-curvature term’s raw-κ slot before the joint solve. No-op (returns false) when the slot is not scalar.

Source

pub fn split_at(&self, mid: usize) -> (Self, Self)

Split at a logical-term boundary. mid is the number of terms in the first half (not a flat-array index).

Source

pub fn apply_tospec( &self, spec: &TermCollectionSpec, term_indices: &[usize], ) -> Result<TermCollectionSpec, EstimationError>

Apply optimized ψ values back to the spec.

For isotropic terms (dims=1): sets scalar length_scale = exp(−ψ). For anisotropic terms (dims=d): hybrid/isotropic families set length_scale = exp(−ψ̄) with centered η_a = ψ_a − ψ̄, while pure Duchon writes only centered η_a and leaves length_scale = None.

Trait Implementations§

Source§

impl Clone for SpatialLogKappaCoords

Source§

fn clone(&self) -> SpatialLogKappaCoords

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpatialLogKappaCoords

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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