Skip to main content

ParameterBlockSpec

Struct ParameterBlockSpec 

Source
pub struct ParameterBlockSpec {
    pub name: String,
    pub design: DesignMatrix,
    pub offset: Array1<f64>,
    pub penalties: Vec<PenaltyMatrix>,
    pub nullspace_dims: Vec<usize>,
    pub initial_log_lambdas: Array1<f64>,
    pub initial_beta: Option<Array1<f64>>,
    pub gauge_priority: u8,
    pub jacobian_callback: Option<Arc<dyn BlockEffectiveJacobian>>,
    pub stacked_design: Option<DesignMatrix>,
    pub stacked_offset: Option<Array1<f64>>,
}
Expand description

Static specification for one parameter block in a custom family.

design and stacked_design are two structurally distinct operators:

  • design is the canonical, single-channel, n-observation operator. design.nrows() ALWAYS equals n_obs (one row per training observation). This is the matrix the identifiability audit, the shape policy, and every “what shape is this block?” reader inspect. For most blocks design is also the eta-producing operator used by the solver — see Self::solver_design.
  • stacked_design, when Some, is the multi-channel eta-producing operator used by the solver. Survival time-varying blocks stack [exit; entry; deriv] into a (3·n × p) operator here so the solver can produce a 3·n-long eta in one mat-vec; the audit never sees this matrix. When None, the solver uses design (the single-channel default).

The single contract that downstream code can rely on: design.nrows() == n_obs. No more dual semantics on design.

Read access:

  • Audit / canonicalize / “n_obs is the row count” code → &spec.design.
  • Eta-producing solver code → Self::solver_design.

Fields§

§name: String§design: DesignMatrix§offset: Array1<f64>§penalties: Vec<PenaltyMatrix>

Block-local penalty matrices (all p_block x p_block).

§nullspace_dims: Vec<usize>

Structural nullspace dimension of each penalty matrix (same length as penalties). Used by the penalty pseudo-logdet to determine rank without numerical thresholds. If empty, falls back to eigenvalue-based rank detection.

§initial_log_lambdas: Array1<f64>

Initial log-smoothing parameters for this block (same length as penalties).

§initial_beta: Option<Array1<f64>>

Optional initial coefficients (defaults to zeros if omitted).

§gauge_priority: u8

Gauge ownership priority. Higher = more likely to retain a redundant direction during canonical-gauge reparameterisation. Defaults to 100. Set higher for blocks that should “own” shared affine/null-space directions (e.g. baseline time in survival).

§jacobian_callback: Option<Arc<dyn BlockEffectiveJacobian>>

Full β-dependent Jacobian callback. When Some, this is the authoritative source for effective_jacobian_at. For simple single-output row-scaled blocks use RowScaledJacobian.

§stacked_design: Option<DesignMatrix>

Optional multi-channel eta-producing operator used by the solver.

When Some, the solver consumes this matrix (typically (k·n × p) for k stacked channels — e.g. survival [exit; entry; deriv] with k = 3) to evaluate eta = stacked · β + stacked_offset. The audit and shape policy NEVER read this field; they only ever inspect design (which always has n_obs rows).

When None, the solver falls back to design — the correct behavior for every single-channel block (i.e. all non-survival time-varying blocks).

Read this field via Self::solver_design, never directly.

Invariant: when stacked_design = Some(_), stacked_offset MUST also be Some(_) and its length MUST equal stacked_design.nrows().

§stacked_offset: Option<Array1<f64>>

Optional offset paired with Self::stacked_design. Same Option state as stacked_design (both Some or both None). Read via Self::solver_offset.

Implementations§

Source§

impl ParameterBlockSpec

Source

pub fn defaults() -> Self

Returns a ParameterBlockSpec with sensible defaults for all optional fields. Callers using struct literal syntax can use ..ParameterBlockSpec::defaults() to fill in any fields added after the literal was written.

Source

pub fn solver_design(&self) -> &DesignMatrix

Returns the eta-producing operator used by the solver.

Resolution order:

  1. stacked_design = Some(d) → return d (multi-channel operator, e.g. (3n × p) for survival time-varying blocks).
  2. otherwise → return &self.design (the single-channel default).

Solver code that needs eta = D · β MUST call this accessor; reading &self.design directly silently breaks multi-channel (survival LS time-varying) blocks because self.design.nrows() always equals n_obs, never 3·n_obs.

Source

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

Returns the offset paired with Self::solver_design. When stacked_offset = Some(o) this returns &o; otherwise it falls back to &self.offset.

Source

pub fn effective_design(&self, caller: &str) -> Result<Array2<f64>, String>

Returns the effective design D_eff for this block at β = 0 with no family scalars — a convenience wrapper around Self::effective_jacobian_at for the single-output (n_outputs = 1) case.

Callers that need multi-output Jacobians or β-dependent scalars should call effective_jacobian_at directly with the appropriate state.

Returns Err if the design cannot be densified.

Source

pub fn effective_jacobian_at( &self, caller: &str, state: &FamilyLinearizationState<'_>, ) -> Result<Array2<f64>, String>

Returns the β-dependent stacked Jacobian J(β) for this block.

Shape: (n_rows * n_outputs, p_block). For most blocks n_outputs = 1 and the result is the familiar (n_rows, p_block) effective design.

Dispatch order:

  1. jacobian_callback = Some(cb)cb.effective_jacobian_at(state).
  2. jacobian_callback = Nonedesign.clone() (ignores beta and family_scalars).

Returns Err if the design cannot be densified.

Trait Implementations§

Source§

impl Clone for ParameterBlockSpec

Source§

fn clone(&self) -> ParameterBlockSpec

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 ParameterBlockSpec

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> 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