Function discounted_sum
pub fn discounted_sum<R: Scalar>(
flows: &[Cashflow<R>],
disc: &dyn YieldCurve<R>,
) -> Result<R, CurveError>Expand description
The sum of flows discounted on disc — the shared NPV kernel.
Two passes and one fused product: the first pass evaluates each discount
factor (recording whatever the curve’s interpolation records), and
Real::dot then closes the accumulation as a single
n-ary statement rather than a 2n-long multiply-add chain. The passive mode
takes the same shape and gets a plain vectorizable loop out of it.
An empty set of flows is zero.
§Errors
Whatever the curve reports — CurveError::BeforeReference if a payment
falls before the curve’s own anchor.