Struct rustnomial::LinearBinomial[][src]

pub struct LinearBinomial<N> {
    pub coefficients: [N; 2],
}
Expand description

A type that stores terms of a linear binomial 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; 2]

Implementations

Create a LinearBinomial with the given terms.

Example

use rustnomial::{SizedPolynomial, LinearBinomial, Degree};
let binomial = LinearBinomial::new([3, 2]);
assert_eq!(Degree::Num(1), binomial.degree());

Return the root of LinearBinomial.

Example

use rustnomial::{LinearBinomial, Roots, SizedPolynomial};
let binomial = LinearBinomial::new([1.0, 2.0]);
assert_eq!(Roots::OneRealRoot(-2.0), binomial.root());
let zero = LinearBinomial::<i32>::zero();
assert_eq!(Roots::InfiniteRoots, zero.root());
let constant = LinearBinomial::new([0, 1]);
assert_eq!(Roots::NoRoots, constant.root());

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

Example

use rustnomial::{LinearBinomial, Derivable};
let binomial = LinearBinomial::new([3.0, 1.0]);
assert_eq!(LinearBinomial::new([0., 3.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 LinearBinomial at the given point.

Example

use rustnomial::{LinearBinomial, Evaluable};
let binomial = LinearBinomial::new([1, 2]);
assert_eq!(7, binomial.eval(5));
assert_eq!(2, binomial.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 LinearBinomial.

Example

use rustnomial::{LinearBinomial, Integrable, Polynomial};
let binomial = LinearBinomial::new([2.0, 0.]);
let integral = binomial.integral();
assert_eq!(&Polynomial::new(vec![1.0, 0.0, 0.0]), integral.inner());

Will panic if N can not losslessly represent 2usize.

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 LinearBinomial and other are equal.

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

Example

use rustnomial::{LinearBinomial, SizedPolynomial, Term};
let binomial = LinearBinomial::new([5, 0]);
assert_eq!(Term::Term(5, 1), binomial.term_with_degree(1));
assert_eq!(Term::ZeroTerm, binomial.term_with_degree(0));

Returns the degree of the LinearBinomial.

Example

use rustnomial::{SizedPolynomial, LinearBinomial, Degree};
let binomial = LinearBinomial::new([3.0, 2.0]);
assert_eq!(Degree::Num(1), binomial.degree());
let monomial = LinearBinomial::new([0.0, 1.0]);
assert_eq!(Degree::Num(0), monomial.degree());
let zero = LinearBinomial::<i32>::zero();
assert_eq!(Degree::NegInf, zero.degree());

Returns a LinearBinomial with no terms.

Example

use rustnomial::{SizedPolynomial, LinearBinomial};
let zero = LinearBinomial::<i32>::zero();
assert!(zero.is_zero());
assert!(zero.ordered_term_iter().next().is_none());

Sets self to zero.

Example

use rustnomial::{SizedPolynomial, LinearBinomial};
let mut non_zero = LinearBinomial::new([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.