pub struct Polynomial {
pub coeffs: Vec<f64>,
}Expand description
A polynomial p(z) = coeffs[0] + coeffs[1]*z + coeffs[2]*z^2 + …
Used to represent continuous functions on the spectrum for the continuous functional calculus (by density of polynomials in C(K)).
Fields§
§coeffs: Vec<f64>Coefficients in ascending degree order: coeffs[i] is the coefficient of z^i.
Implementations§
Source§impl Polynomial
impl Polynomial
Sourcepub fn new(coeffs: Vec<f64>) -> Self
pub fn new(coeffs: Vec<f64>) -> Self
Create a polynomial from coefficients in ascending degree order.
Sourcepub fn eval(&self, x: f64) -> f64
pub fn eval(&self, x: f64) -> f64
Evaluate the polynomial at a scalar point x using Horner’s method.
Sourcepub fn add(&self, other: &Polynomial) -> Polynomial
pub fn add(&self, other: &Polynomial) -> Polynomial
Add two polynomials.
Sourcepub fn multiply(&self, other: &Polynomial) -> Polynomial
pub fn multiply(&self, other: &Polynomial) -> Polynomial
Multiply two polynomials via convolution.
Sourcepub fn scale(&self, s: f64) -> Polynomial
pub fn scale(&self, s: f64) -> Polynomial
Scale the polynomial by a constant factor.
Sourcepub fn compose(&self, other: &Polynomial) -> Polynomial
pub fn compose(&self, other: &Polynomial) -> Polynomial
Compose two polynomials: compute (self o other)(z) = self(other(z)).
Trait Implementations§
Source§impl Clone for Polynomial
impl Clone for Polynomial
Source§fn clone(&self) -> Polynomial
fn clone(&self) -> Polynomial
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Polynomial
impl RefUnwindSafe for Polynomial
impl Send for Polynomial
impl Sync for Polynomial
impl Unpin for Polynomial
impl UnsafeUnpin for Polynomial
impl UnwindSafe for Polynomial
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more