Skip to main content

RationalCubic

Struct RationalCubic 

Source
pub struct RationalCubic;
Expand description

Rational function, cubic over cubic, with the denominator constant pinned at 1.

y = (a0 + a1·x + a2·x² + a3·x³) / (1 + b1·x + b2·x² + b3·x³)

Parameters (in order): [a0, a1, a2, a3, b1, b2, b3]

One kernel covers three NIST StRD datasets because a lower-order rational is this form with the unused coefficients held at zero:

  • Hahn1 and Thurber are cubic/cubic and use all seven.
  • Kirby2 is quadratic/quadratic: fix a3 = 0 and b3 = 0 and the remaining five map straight onto NIST’s b1..b5.

The denominator constant is pinned at 1 rather than fitted because NIST writes these models that way. Fitting it too would make numerator and denominator jointly scalable — (kN)/(kD) is the same curve — and hand the solver an exact rank deficiency.

Domain guard: D must be non-zero. A rational’s denominator can cross zero mid-search even when the certified parameters keep it clear of the data, so D = 0 returns f64::NAN and the solver backs off rather than emitting an infinity that would poison the residual vector.

Analytic Jacobian (let N and D be numerator and denominator):

  • ∂y/∂a_k = x^k / D for k = 0,1,2,3
  • ∂y/∂b_k = −N · x^k / D² for k = 1,2,3

Trait Implementations§

Source§

impl Model for RationalCubic

Source§

fn eval(&self, x: &[f64], p: &[f64]) -> f64

Evaluate the model at coordinate x with the given params. Read more
Source§

fn jacobian_into(&self, x: &[f64], p: &[f64], out: &mut [f64])

Fill a pre-allocated slice with Jacobian values (one entry per parameter). Read more
Source§

fn jacobian(&self, x: &[f64], p: &[f64]) -> Vec<f64>

Jacobian — one derivative per parameter, in the same order as param_names(). Read more
Source§

fn param_names(&self) -> Vec<Cow<'static, str>>

Ordered parameter names, matching the layout expected by eval and jacobian. Read more
Source§

fn eval_slice_into(&self, xs: &[f64], params: &[f64], out: &mut [f64])

Batch evaluation of a 1-D model: fill out[i] = eval([xs[i]], params). Read more
Source§

fn jac_slice_into(&self, xs: &[f64], params: &[f64], out: &mut [f64])

Batch Jacobian for a 1-D model: fill out in row-major layout [i * params.len() + j] = d(model)/d(params[j]) at xs[i]. Read more
Source§

fn n_dims(&self) -> usize

Number of coordinate dimensions consumed from x. Defaults to 1.

Auto Trait Implementations§

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> 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, 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.