Struct rustnomial::QuadraticTrinomial[][src]

pub struct QuadraticTrinomial<N> {
    pub coefficients: [N; 3],
}
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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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());

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Returns the value of the QuadraticTrinomial at the given point.

Example

use rustnomial::{QuadraticTrinomial, Evaluable};
let trinomial = QuadraticTrinomial::new([1, 2, 3]);
assert_eq!(6, trinomial.eval(1));
assert_eq!(3, trinomial.eval(0));

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.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

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.

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

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

The resulting type after applying the - operator.

Performs the unary - operation. Read more

Returns true if this QuadraticTrinomial is equal to other.

This method tests for !=.

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

Returns true if all terms of self are zero, and false if a non-zero term exists. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.