Struct rustnomial::QuadraticTrinomial [−][src]
Expand description
A type that stores terms of a quadratic trinomial in a static array. Operations are much faster than on Polynomial for the same size polynomial, but terms can not be added freely.
Fields
coefficients: [N; 3]
Implementations
Create a QuadraticTrinomial
with the given coefficients.
Example
use rustnomial::{SizedPolynomial, QuadraticTrinomial, Degree}; let trinomial = QuadraticTrinomial::new([3.0, 1.0, 0.5]); assert_eq!([3.0, 1.0, 0.5], trinomial.coefficients); assert_eq!(Degree::Num(2), trinomial.degree());
Return the roots of QuadraticTrinomial
with largest
first, smallest second.
Trait Implementations
type Output = QuadraticTrinomial<N>
type Output = QuadraticTrinomial<N>
The resulting type after applying the +
operator.
Performs the +
operation. Read more
Performs the +=
operation. Read more
Returns the derivative of the QuadraticTrinomial
.
Example
use rustnomial::{QuadraticTrinomial, Derivable}; let binomial = QuadraticTrinomial::new([3.0, 2.0, 1.0]); assert_eq!(QuadraticTrinomial::new([0.0, 6.0, 2.0]), binomial.derivative());
type Output = QuadraticTrinomial<N>
type Output = QuadraticTrinomial<N>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
Performs the /=
operation. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
impl<N> Integrable<N, Polynomial<N>> for QuadraticTrinomial<N> where
N: Zero + TryFromUsizeExact + Copy + DivAssign + Mul<Output = N> + MulAssign + AddAssign + Div<Output = N>,
impl<N> Integrable<N, Polynomial<N>> for QuadraticTrinomial<N> where
N: Zero + TryFromUsizeExact + Copy + DivAssign + Mul<Output = N> + MulAssign + AddAssign + Div<Output = N>,
Returns the integral of the Monomial
.
Example
use rustnomial::{QuadraticTrinomial, Integrable, Polynomial}; let trinomial = QuadraticTrinomial::new([3.0, 0., 0.]); let integral = trinomial.integral(); assert_eq!(&Polynomial::new(vec![1.0, 0.0, 0.0, 0.0]), integral.inner());
Errors
Will panic if N
can not losslessly represent 2usize
or 3usize
.
type Output = QuadraticTrinomial<N>
type Output = QuadraticTrinomial<N>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
Performs the *=
operation. Read more
impl<N> MutablePolynomial<N> for QuadraticTrinomial<N> where
N: Zero + SubAssign + AddAssign + Copy,
impl<N> MutablePolynomial<N> for QuadraticTrinomial<N> where
N: Zero + SubAssign + AddAssign + Copy,
Tries to add the term with given coefficient and degree
to self
, returning an error
if the particular term can not be added to self without violating constraints. Read more
Tries to subtract the term with given coefficient and degree
from self
, returning
an error if the particular term can not be subtracted from self without violating
constraints. Read more
type Output = QuadraticTrinomial<N>
type Output = QuadraticTrinomial<N>
The resulting type after applying the -
operator.
Performs the unary -
operation. Read more
impl<N> PartialEq<QuadraticTrinomial<N>> for QuadraticTrinomial<N> where
N: Zero + PartialEq + Copy,
impl<N> PartialEq<QuadraticTrinomial<N>> for QuadraticTrinomial<N> where
N: Zero + PartialEq + Copy,
type Output = QuadraticTrinomial<N>
type Output = QuadraticTrinomial<N>
The resulting type after applying the >>
operator.
Performs the >>
operation. Read more
Performs the >>=
operation. Read more
Returns the term with the given degree
of the QuadraticTrinomial
.
Example
use rustnomial::{QuadraticTrinomial, SizedPolynomial, Term}; let trinomial = QuadraticTrinomial::new([1, 0, 3]); assert_eq!(Term::Term(1, 2), trinomial.term_with_degree(2)); assert_eq!(Term::ZeroTerm, trinomial.term_with_degree(1)); assert_eq!(Term::Term(3, 0), trinomial.term_with_degree(0));
Returns the degree of the QuadraticTrinomial
.
Example
use rustnomial::{SizedPolynomial, QuadraticTrinomial, Degree}; let trinomial = QuadraticTrinomial::new([1, 2, 3]); assert_eq!(Degree::Num(2), trinomial.degree()); let binomial = QuadraticTrinomial::new([0, 2, 3]); assert_eq!(Degree::Num(1), binomial.degree()); let monomial = QuadraticTrinomial::new([0, 0, 3]); assert_eq!(Degree::Num(0), monomial.degree()); let zero = QuadraticTrinomial::new([0, 0, 0]); assert_eq!(Degree::NegInf, zero.degree());
Return a QuadraticTrinomial
which is equal to zero.
Example
use rustnomial::{QuadraticTrinomial, SizedPolynomial}; assert!(QuadraticTrinomial::<i32>::zero().is_zero());
Sets self to zero.
Example
use rustnomial::{QuadraticTrinomial, SizedPolynomial}; let mut non_zero = QuadraticTrinomial::new([1, 1, 1]); assert!(!non_zero.is_zero()); non_zero.set_to_zero(); assert!(non_zero.is_zero());
Returns a Vec containing all of the terms of self
, where each item is
the coefficient and degree of each non-zero term, in order of descending degree. Read more
type Output = QuadraticTrinomial<N>
type Output = QuadraticTrinomial<N>
The resulting type after applying the -
operator.
Performs the -
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl<N> RefUnwindSafe for QuadraticTrinomial<N> where
N: RefUnwindSafe,
impl<N> Send for QuadraticTrinomial<N> where
N: Send,
impl<N> Sync for QuadraticTrinomial<N> where
N: Sync,
impl<N> Unpin for QuadraticTrinomial<N> where
N: Unpin,
impl<N> UnwindSafe for QuadraticTrinomial<N> where
N: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more