Struct PiecewiseView
pub struct PiecewiseView<'a, R: Scalar> {
data: &'a PiecewiseDiscount,
params: Cow<'a, [R]>,
coefficients: Option<Vec<R>>,
long_coefficients: Option<Vec<R>>,
long_ys: Option<Vec<R>>,
}Expand description
PiecewiseDiscount lifted into one pricing mode.
Borrows the storage; owns only this mode’s parameters (and for the passive mode, borrows those too).
Fields§
§data: &'a PiecewiseDiscount§params: Cow<'a, [R]>§coefficients: Option<Vec<R>>A global scheme’s coefficients, solved once here and shared by every
query against this view. None under a local scheme, which reads only
the pillars bracketing a query and so has nothing to precompute.
On a mixed curve this belongs to the short side and is solved over the anchor-to-changeover knots alone.
long_coefficients: Option<Vec<R>>The long side’s coefficients on a mixed curve, solved over the changeover-to-last knots alone. Neither side’s solve reads the other’s ordinates: that independence is what keeps the two halves from having to agree on a derivative at the join.
long_ys: Option<Vec<R>>The long side’s ordinates in its shifted frame, built once per lift for the same reason its taus live on the curve: a query allocates nothing.
Implementations§
§impl<'a, R: Scalar> PiecewiseView<'a, R>
impl<'a, R: Scalar> PiecewiseView<'a, R>
fn build(data: &'a PiecewiseDiscount, params: Cow<'a, [R]>) -> Self
fn build(data: &'a PiecewiseDiscount, params: Cow<'a, [R]>) -> Self
The one place a view is built: solves a global scheme’s coefficients
and leaves a local scheme’s None.
Every constructor routes through here so the solve cannot be forgotten
on one path and silently produce a curve that reads as LogLinear.
pub fn parameters(&self) -> &[R]
pub fn parameters(&self) -> &[R]
This mode’s parameters. For the passive mode these are the stored ones, borrowed.
pub fn with_parameters(
data: &'a PiecewiseDiscount,
params: &[R],
) -> Result<Self, CurveError>
pub fn with_parameters( data: &'a PiecewiseDiscount, params: &[R], ) -> Result<Self, CurveError>
A view over the same storage with params substituted — how the risk
lift installs tape-registered handles without touching the storage.
§Errors
CurveError::ParameterCountMismatch if params is not one parameter
per free pillar. Checked here so a wrong-length substitution fails at
the seam instead of indexing out of bounds mid-valuation.
Trait Implementations§
§impl<'a, R: Clone + Scalar> Clone for PiecewiseView<'a, R>
impl<'a, R: Clone + Scalar> Clone for PiecewiseView<'a, R>
§fn clone(&self) -> PiecewiseView<'a, R>
fn clone(&self) -> PiecewiseView<'a, R>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<'a, R: Debug + Scalar> Debug for PiecewiseView<'a, R>
impl<'a, R: Debug + Scalar> Debug for PiecewiseView<'a, R>
§impl<R: Scalar> YieldCurve<R> for PiecewiseView<'_, R>
impl<R: Scalar> YieldCurve<R> for PiecewiseView<'_, R>
§fn reference_date(&self) -> NaiveDate
fn reference_date(&self) -> NaiveDate
§fn log_discount(&self, date: NaiveDate) -> Result<R, CurveError>
fn log_discount(&self, date: NaiveDate) -> Result<R, CurveError>
date. Read more§fn discount_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
fn discount_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
ordinal. Read more§fn log_discount_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
fn log_discount_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>
§fn rate_day_count(&self) -> DayCountFraction
fn rate_day_count(&self) -> DayCountFraction
§fn zero_rate(&self, date: NaiveDate) -> Result<R, CurveError>
fn zero_rate(&self, date: NaiveDate) -> Result<R, CurveError>
date. Read more