pub struct Polynomial<N: ComplexField + FromPrimitive + Copy>
where <N as ComplexField>::RealField: FromPrimitive + Copy,
{ /* private fields */ }
Expand description

Polynomial on a ComplexField.

Implementations§

source§

impl<N: ComplexField + FromPrimitive + Copy> Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source

pub fn new() -> Self

Returns the zero polynomial on a given field

source

pub fn with_tolerance( tolerance: <N as ComplexField>::RealField ) -> Result<Self, String>

source

pub fn with_capacity(capacity: usize) -> Self

Returns the zero polynomial on a given field with preallocated memory

source

pub fn from_slice(data: &[N]) -> Self

Create a polynomial from a slice, with the first element of the slice being the highest power

source

pub fn set_tolerance( &mut self, tolerance: <N as ComplexField>::RealField ) -> Result<(), String>

source

pub fn get_tolerance(&self) -> <N as ComplexField>::RealField

source

pub fn order(&self) -> usize

Get the order of the polynomial

source

pub fn get_coefficients(&self) -> Vec<N>

Returns the coefficients in the correct order to recreate the polynomial with Polynomial::from_slice(data: &[N]);

source

pub fn get_coefficient(&self, ind: usize) -> N

Get the coefficient of a power

source

pub fn make_complex( &self ) -> Polynomial<Complex<<N as ComplexField>::RealField>>

Make a polynomial complex

source

pub fn evaluate(&self, x: N) -> N

Evaluate a polynomial at a value

source

pub fn evaluate_derivative(&self, x: N) -> (N, N)

Evaluate a polynomial and its derivative at a value

source

pub fn set_coefficient(&mut self, power: u32, coefficient: N)

Set a coefficient of a power in the polynomial

source

pub fn purge_coefficient(&mut self, power: usize)

Remove the coefficient of a power in the polynomial

source

pub fn purge_leading(&mut self)

Remove all leading 0 coefficients

source

pub fn derivative(&self) -> Self

Get the derivative of the polynomial

source

pub fn antiderivative(&self, constant: N) -> Self

Get the antiderivative of the polynomial with specified constant

source

pub fn integrate(&self, lower: N, upper: N) -> N

Integrate this polynomial between to starting points

source

pub fn divide(&self, divisor: &Polynomial<N>) -> Result<(Self, Self), String>

Divide this polynomial by another, getting a quotient and remainder, using tol to check for 0

source

pub fn roots( &self, tol: <N as ComplexField>::RealField, n_max: usize ) -> Result<VecDeque<Complex<<N as ComplexField>::RealField>>, String>

Get the n (possibly including repeats) of the polynomial given n using Laguerre’s method

source

pub fn dft(&self, size: usize) -> Vec<Complex<<N as ComplexField>::RealField>>

Get the polynomial in point form evaluated at roots of unity at k points where k is the smallest power of 2 greater than or equal to size

source

pub fn idft( vec: &[Complex<<N as ComplexField>::RealField>], tol: <N as ComplexField>::RealField ) -> Self

Trait Implementations§

source§

impl<N: ComplexField + FromPrimitive + Copy> Add<&Polynomial<N>> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Polynomial<N>) -> Polynomial<N>

Performs the + operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Add<&Polynomial<N>> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Polynomial<N>) -> Polynomial<N>

Performs the + operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Add<N> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the + operator.
source§

fn add(self, rhs: N) -> Polynomial<N>

Performs the + operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Add<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the + operator.
source§

fn add(self, rhs: N) -> Polynomial<N>

Performs the + operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Add<Polynomial<N>> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Polynomial<N>) -> Polynomial<N>

Performs the + operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Add for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Polynomial<N>) -> Polynomial<N>

Performs the + operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> AddAssign<&Polynomial<N>> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn add_assign(&mut self, rhs: &Polynomial<N>)

Performs the += operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> AddAssign<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn add_assign(&mut self, rhs: N)

Performs the += operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> AddAssign for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn add_assign(&mut self, rhs: Polynomial<N>)

Performs the += operation. Read more
source§

impl<N: Clone + ComplexField + FromPrimitive + Copy> Clone for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn clone(&self) -> Polynomial<N>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<N: Debug + ComplexField + FromPrimitive + Copy> Debug for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

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

Formats the value using the given formatter. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Default for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Div<N> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the / operator.
source§

fn div(self, rhs: N) -> Polynomial<N>

Performs the / operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Div<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the / operator.
source§

fn div(self, rhs: N) -> Polynomial<N>

Performs the / operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> DivAssign<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn div_assign(&mut self, rhs: N)

Performs the /= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> From<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn from(n: N) -> Polynomial<N>

Converts to this type from the input type.
source§

impl<N: RealField + FromPrimitive + Copy> From<Polynomial<N>> for Polynomial<Complex<N>>

source§

fn from(poly: Polynomial<N>) -> Polynomial<Complex<N>>

Converts to this type from the input type.
source§

impl<N: ComplexField + FromPrimitive + Copy> FromIterator<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn from_iter<I: IntoIterator<Item = N>>(iter: I) -> Polynomial<N>

Creates a value from an iterator. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Mul<&Polynomial<N>> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Polynomial<N>) -> Polynomial<N>

Performs the * operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Mul<&Polynomial<N>> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Polynomial<N>) -> Polynomial<N>

Performs the * operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Mul<N> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: N) -> Polynomial<N>

Performs the * operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Mul<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: N) -> Polynomial<N>

Performs the * operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Mul<Polynomial<N>> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Polynomial<N>) -> Polynomial<N>

Performs the * operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Mul for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Polynomial<N>) -> Polynomial<N>

Performs the * operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> MulAssign<&Polynomial<N>> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn mul_assign(&mut self, rhs: &Polynomial<N>)

Performs the *= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> MulAssign<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn mul_assign(&mut self, rhs: N)

Performs the *= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> MulAssign for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn mul_assign(&mut self, rhs: Polynomial<N>)

Performs the *= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Neg for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn neg(self) -> Polynomial<N>

Performs the unary - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Neg for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn neg(self) -> Polynomial<N>

Performs the unary - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Sub<&Polynomial<N>> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Polynomial<N>) -> Polynomial<N>

Performs the - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Sub<&Polynomial<N>> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Polynomial<N>) -> Polynomial<N>

Performs the - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Sub<N> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: N) -> Polynomial<N>

Performs the - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Sub<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: N) -> Polynomial<N>

Performs the - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Sub<Polynomial<N>> for &Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Polynomial<N>) -> Polynomial<N>

Performs the - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Sub for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

§

type Output = Polynomial<N>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Polynomial<N>) -> Polynomial<N>

Performs the - operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> SubAssign<&Polynomial<N>> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn sub_assign(&mut self, rhs: &Polynomial<N>)

Performs the -= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> SubAssign<N> for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn sub_assign(&mut self, rhs: N)

Performs the -= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> SubAssign for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn sub_assign(&mut self, rhs: Polynomial<N>)

Performs the -= operation. Read more
source§

impl<N: ComplexField + FromPrimitive + Copy> Zero for Polynomial<N>
where <N as ComplexField>::RealField: FromPrimitive + Copy,

source§

fn zero() -> Polynomial<N>

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

§

impl<N> RefUnwindSafe for Polynomial<N>
where N: RefUnwindSafe, <N as ComplexField>::RealField: RefUnwindSafe,

§

impl<N> Send for Polynomial<N>

§

impl<N> Sync for Polynomial<N>

§

impl<N> Unpin for Polynomial<N>
where N: Unpin, <N as ComplexField>::RealField: Unpin,

§

impl<N> UnwindSafe for Polynomial<N>
where N: UnwindSafe, <N as ComplexField>::RealField: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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

§

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

§

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

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

§

impl<T, Right> ClosedDiv<Right> for T
where T: Div<Right, Output = T> + DivAssign<Right>,

§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,