pub struct PPoly {
pub c: Array2<f64>,
pub x: Vec<f64>,
pub extrapolate: bool,
}Expand description
A piecewise polynomial of degree k on m intervals.
Fields§
§c: Array2<f64>Coefficients, shape (k + 1, m); row 0 multiplies the highest power.
x: Vec<f64>The m + 1 breakpoints, increasing.
extrapolate: boolEvaluate outside [x₀, x_m] by extending the end pieces (otherwise NaN).
Implementations§
Source§impl PPoly
impl PPoly
Sourcepub fn new(
c: Array2<f64>,
x: Vec<f64>,
extrapolate: bool,
) -> Result<PPoly, ErrorsJSL>
pub fn new( c: Array2<f64>, x: Vec<f64>, extrapolate: bool, ) -> Result<PPoly, ErrorsJSL>
A piecewise polynomial from coefficients (shape (k + 1, m)) and m + 1 breakpoints.
Sourcepub fn evaluate_derivative(&self, v: f64, nu: usize) -> f64
pub fn evaluate_derivative(&self, v: f64, nu: usize) -> f64
The nu-th derivative at v.
Sourcepub fn derivative(&self, nu: usize) -> PPoly
pub fn derivative(&self, nu: usize) -> PPoly
The derivative of order nu as a piecewise polynomial of degree k − nu (degree 0 and
value 0 if nu > k).
Sourcepub fn antiderivative(&self, nu: usize) -> PPoly
pub fn antiderivative(&self, nu: usize) -> PPoly
The antiderivative of order nu, zero at x₀ and continuous with its first nu − 1
derivatives (SciPy’s antiderivative): the coefficients are divided by rising factorials,
and the new low-order coefficients of each piece are set from the previous piece’s values
at the shared breakpoint.
Sourcepub fn integrate(&self, a: f64, b: f64) -> f64
pub fn integrate(&self, a: f64, b: f64) -> f64
∫_a^b p(x) dx (with extrapolation beyond the breakpoints if enabled).
Sourcepub fn solve(&self, y: f64, discontinuity: bool) -> Vec<f64>
pub fn solve(&self, y: f64, discontinuity: bool) -> Vec<f64>
The real x with p(x) = y (SciPy’s solve), increasing. Each piece’s roots are the
eigenvalues of the companion matrix of its polynomial, kept when real (to a small
tolerance) and inside the piece, then polished by Newton steps. With discontinuity, a
breakpoint where the polynomial jumps across y is reported too. Pieces that equal y
identically are skipped.
Sourcepub fn cubic_hermite(
x: &[f64],
y: &[f64],
dydx: &[f64],
) -> Result<PPoly, ErrorsJSL>
pub fn cubic_hermite( x: &[f64], y: &[f64], dydx: &[f64], ) -> Result<PPoly, ErrorsJSL>
The cubic Hermite interpolant with values y and slopes dydx at the strictly increasing
x (SciPy’s CubicHermiteSpline). With h the interval length and s the secant slope,
the piece is y₀ + d₀ t + (3s − 2d₀ − d₁)/h · t² + (d₀ + d₁ − 2s)/h² · t³.
Sourcepub fn from_spline(spline: &BSpline) -> PPoly
pub fn from_spline(spline: &BSpline) -> PPoly
The same function as a B-spline, as pieces between its distinct knots in the base interval
[t_k, t_n] (SciPy’s PPoly.from_spline, which also keeps the empty intervals between
repeated knots): each piece’s coefficients are the spline’s Taylor coefficients
s⁽ⁱ⁾(x_j)/i! at the left end.