Skip to main content

RowNllProgramGeneric

Trait RowNllProgramGeneric 

Source
pub trait RowNllProgramGeneric<const K: usize>: Send + Sync {
    // Required methods
    fn n_rows(&self) -> usize;
    fn primaries(&self, row: usize) -> Result<[f64; K], String>;
    fn row_nll_generic<S: JetScalar<K>>(
        &self,
        row: usize,
        p: &[S; K],
    ) -> Result<S, String>;
}
Expand description

A family’s row negative log-likelihood written ONCE over the generic crate::jet_scalar::JetScalar interface, so the SAME expression can be re-instantiated at whatever order / representation a consumer needs (crate::jet_scalar::Order2 for (v, g, H), crate::jet_scalar::OneSeed for the contracted third, crate::jet_scalar::TwoSeed for the contracted fourth, or the full Tower4 for every channel at once).

This is additive to RowNllProgram (which is Tower4-specialised): a program implementing this generic trait gets the small contracted scalars for free, dissolving the dense-Tower4<9> cost objection in the location-scale gates (doc §A.4). An existing Tower4-only RowNllProgram continues to work unchanged; new families should prefer this generic trait.

Because a Tower4-specialised row_nll body uses only add/sub/mul/scale/exp/ln/… — all of which this trait also provides — the same body is expressible directly over S: JetScalar<K>. A program written that way needs no Tower4-specialised method and routes the directional and joint-Hessian gates through the contracted scalars from a single definition.

Required Methods§

Source

fn n_rows(&self) -> usize

Number of observations the program covers.

Source

fn primaries(&self, row: usize) -> Result<[f64; K], String>

Current primary-scalar values for row (where to seed the scalar).

Source

fn row_nll_generic<S: JetScalar<K>>( &self, row: usize, p: &[S; K], ) -> Result<S, String>

The row NLL evaluated on a generic jet scalar. p[a] arrives pre-seeded (base value + per-scalar nilpotent directions) by the caller; the body uses ONLY crate::jet_scalar::JetScalar ops and per-row data (response, censoring, offsets) entering as constants.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§