Skip to main content

Module poly

Module poly 

Source
Expand description

Polynomials with coefficients stored highest power first, like NumPy’s legacy np.poly* functions (np.polyval, np.polyfit, np.roots, …).

[1.0, -3.0, 2.0] is x^2 - 3x + 2. The numerical kernels live in the private kernels module and work on plain Vec<f64> / &[f64]; the public Array-level wrappers live in api.rs.

Roots are complex in general. rustnum v0.1 has no complex dtype, so roots returns the real and imaginary parts as two arrays (re, im).

Functions§

polyadd
Sum of two polynomials, like np.polyadd(a, b).
polyder
m-th derivative of a polynomial, like np.polyder(p, m).
polydiv
Polynomial division u / v, like np.polydiv(u, v); returns (quotient, remainder).
polyfit
Least-squares polynomial fit of degree deg, like np.polyfit(x, y, deg).
polyint
m-fold antiderivative of a polynomial, like np.polyint(p, m, k).
polymul
Product of two polynomials, like np.polymul(a, b) (a convolution of the coefficients).
polysub
Difference of two polynomials, like np.polysub(a, b).
polyval
Evaluate a polynomial at x, like np.polyval(p, x).
roots
Roots of a polynomial, like np.roots(p); returns (re, im) arrays of length degree.