Skip to main content

PiecewiseView

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>

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]

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>

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.

fn log_df(&self, tau: f64) -> R

The log discount factor at tau, under this curve’s scheme. The anchor (0, 0) is the implicit left end.

Trait Implementations§

§

impl<'a, R: Clone + Scalar> Clone for PiecewiseView<'a, R>

§

fn clone(&self) -> PiecewiseView<'a, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'a, R: Debug + Scalar> Debug for PiecewiseView<'a, R>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<R: Scalar> YieldCurve<R> for PiecewiseView<'_, R>

§

fn reference_date(&self) -> NaiveDate

The date at which the discount factor is 1.
§

fn discount(&self, date: NaiveDate) -> Result<R, CurveError>

The discount factor to date. Read more
§

fn log_discount(&self, date: NaiveDate) -> Result<R, CurveError>

The log discount factor to date. Read more
§

fn discount_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>

The discount factor to the proleptic-Gregorian day number ordinal. Read more
§

fn log_discount_at_ordinal(&self, ordinal: i32) -> Result<R, CurveError>

The log discount factor at ordinal; see discount_at_ordinal. Read more
§

fn rate_day_count(&self) -> DayCountFraction

The day count this curve forms a rate under. Read more
§

fn zero_rate(&self, date: NaiveDate) -> Result<R, CurveError>

The continuously-compounded zero rate to date. Read more
§

fn forward_rate( &self, start: NaiveDate, end: NaiveDate, ) -> Result<R, CurveError>

The continuously-compounded forward rate between start and end. Read more

Auto Trait Implementations§

§

impl<'a, R> Freeze for PiecewiseView<'a, R>

§

impl<'a, R> RefUnwindSafe for PiecewiseView<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for PiecewiseView<'a, R>

§

impl<'a, R> Sync for PiecewiseView<'a, R>

§

impl<'a, R> Unpin for PiecewiseView<'a, R>
where R: Unpin,

§

impl<'a, R> UnsafeUnpin for PiecewiseView<'a, R>

§

impl<'a, R> UnwindSafe for PiecewiseView<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.