use super::*;
impl SurvivalMarginalSlopeFamily {
pub(crate) fn build_cached_partition_with_moment_order(
&self,
primary: &FlexPrimarySlices,
a: f64,
b: f64,
beta_h: Option<&Array1<f64>>,
beta_w: Option<&Array1<f64>>,
moment_order: usize,
) -> Result<CachedPartitionCells, String> {
let raw_cells = self.denested_partition_cells(a, b, beta_h, beta_w)?;
let n = raw_cells.len();
let mut z_mids = Vec::with_capacity(n);
let mut u_mids = Vec::with_capacity(n);
let mut states = Vec::with_capacity(n);
for partition_cell in &raw_cells {
let cell = partition_cell.cell;
let z_mid = exact_kernel::interval_probe_point(cell.left, cell.right)?;
let u_mid = a + b * z_mid;
let state = exact_kernel::evaluate_cell_moments(cell, moment_order)?;
z_mids.push(z_mid);
u_mids.push(u_mid);
states.push(state);
}
let mut cells = Vec::with_capacity(n);
for (idx, partition_cell) in raw_cells.into_iter().enumerate() {
let fixed = self.denested_cell_primary_fixed_partials(
primary,
a,
b,
partition_cell.score_span,
partition_cell.link_span,
z_mids[idx],
u_mids[idx],
)?;
cells.push(CachedCellEntry {
partition_cell,
state: states[idx].clone(),
fixed,
});
}
Ok(CachedPartitionCells { cells })
}
pub(crate) fn build_cached_partition(
&self,
primary: &FlexPrimarySlices,
a: f64,
b: f64,
beta_h: Option<&Array1<f64>>,
beta_w: Option<&Array1<f64>>,
) -> Result<CachedPartitionCells, String> {
self.build_cached_partition_with_moment_order(primary, a, b, beta_h, beta_w, 32)
}
}