Skip to main content

sh_eval_mixed_impl

Function sh_eval_mixed_impl 

Source
pub fn sh_eval_mixed_impl<W, R, const L: usize, const N: usize>(
    t: &ShTable<R::Primal, N>,
    x: W,
    y: W,
    z: W,
    out: &mut [W; N],
)
where W: FloatVector + Mul<R, Output = W> + CoreMath, R: PrimalProjection,
Expand description

sh_eval_impl with the coefficients kept in a different, simpler type than the values.

The case this exists for is a composite W (a Dual, say) evaluated against a table of plain real coefficients. Every recurrence constant has a zero derivative, so carrying it as a Dual means computing a.re * 0.0 cross terms for each one, which LLVM cannot fold away under strict IEEE (a.re could be an infinity or a NaN). Typing the table by R’s primal instead turns each of those into Dual * real, which thermite-dual implements as 1 + N multiplies rather than 1 + 2N.

It also shrinks the table itself, which is the larger saving in practice: a ShTable<Dual<V, 3>, 25> is 600 vector stores to fill, against 150 for ShTable<V, 25>, and the general path fills one per call.

Deliberately not a generalization of sh_eval_impl. The single-type version folds its recurrence into mul_adde, and no fused multiply-add spans two operand types, so merging them would cost the real path its FMAs to benefit the composite one. The duplicated body is about twenty lines and neither copy has to compromise.

Last built: 2026-09-08 21:35:55 UTC