Skip to main content

ExactNumPoly

Struct ExactNumPoly 

Source
pub struct ExactNumPoly { /* private fields */ }
Expand description

Dense univariate polynomial c₀ + c₁ x + ⋯ + cₙ xⁿ.

Coefficients are stored lowest degree first. Leading zeros are stripped. The zero polynomial has an empty coefficient vector. Arithmetic methods take an explicit precision p and rounding mode; stored (p, rm) are the values used when the polynomial was constructed.

Implementations§

Source§

impl ExactNumPoly

Source

pub fn zero(p: usize, rm: RoundingMode) -> ExactNumPoly

Zero polynomial at (p, rm).

Source

pub fn one(p: usize, rm: RoundingMode) -> ExactNumPoly

Constant 1 at (p, rm).

Source

pub fn from_coeffs( p: usize, rm: RoundingMode, coeffs: &[ExactNum], ) -> ExactNumPoly

Build from coefficients, lowest degree first. Each coefficient is rounded to (p, rm). Leading zeros are stripped.

Source

pub fn from_i64_coeffs( p: usize, rm: RoundingMode, coeffs: &[i64], ) -> ExactNumPoly

Coefficients from i64 values, lowest degree first.

Source

pub fn precision(&self) -> usize

Stored construction precision.

Source

pub fn rounding(&self) -> RoundingMode

Stored construction rounding mode.

Source

pub fn coeffs(&self) -> &[ExactNum]

Coefficients, lowest degree first. Empty if this is the zero polynomial.

Source

pub fn degree(&self) -> Option<usize>

Degree n of a nonzero polynomial. None if this is zero.

Source

pub fn is_zero(&self) -> bool

True if every coefficient is zero (or the vector is empty).

Source

pub fn coeff(&self, k: usize) -> ExactNum

Coefficient of x^k, or zero if k exceeds the degree.

Source

pub fn eval( &self, x: &ExactNum, p: usize, rm: RoundingMode, _cc: &mut Consts, ) -> ExactNum

Horner evaluation c₀ + x(c₁ + x(c₂ + ⋯)) at (p, rm).

cc is accepted for signature uniformity with other numeric methods; Horner uses only add and fused multiply-add.

Source

pub fn add( &self, rhs: &ExactNumPoly, p: usize, rm: RoundingMode, ) -> ExactNumPoly

Coefficient-wise sum at precision p.

Source

pub fn sub( &self, rhs: &ExactNumPoly, p: usize, rm: RoundingMode, ) -> ExactNumPoly

Coefficient-wise difference at precision p.

Source

pub fn mul( &self, rhs: &ExactNumPoly, p: usize, rm: RoundingMode, ) -> ExactNumPoly

Schoolbook product at precision p.

Source

pub fn div_rem( &self, g: &ExactNumPoly, p: usize, rm: RoundingMode, ) -> Option<(ExactNumPoly, ExactNumPoly)>

Polynomial division: self = q·g + r with deg r < deg g.

None if g is the zero polynomial or a coefficient is non-finite.

Source

pub fn gcd( &self, other: &ExactNumPoly, p: usize, rm: RoundingMode, ) -> ExactNumPoly

Euclidean GCD with integer content removal, returned monic.

Both zero → zero. One zero → monic of the other.

Source

pub fn compose( &self, g: &ExactNumPoly, p: usize, rm: RoundingMode, _cc: &mut Consts, ) -> ExactNumPoly

Composition self(g(x)) by Horner at precision p.

Source

pub fn derivative(&self, p: usize, rm: RoundingMode) -> ExactNumPoly

Formal derivative. The derivative of a constant is zero.

Source

pub fn integral(&self, p: usize, rm: RoundingMode) -> ExactNumPoly

Indefinite integral with constant term zero.

Source

pub fn companion_matrix( &self, p: usize, rm: RoundingMode, ) -> Option<ExactNumArray>

Monic companion matrix of this polynomial, or None if the degree is zero or the polynomial is zero / non-finite.

Last column is (-c₀/cₙ, …, -cₙ₋₁/cₙ). Subdiagonal is ones.

Source

pub fn roots_real( &self, p: usize, rm: RoundingMode, _cc: &mut Consts, ) -> Option<Vec<ExactNum>>

Real roots via the companion characteristic equation.

Degree 1 and 2 use the closed-form eigenvalues of the companion (linear solve / quadratic formula) at extra working precision, then one round to p. Degree greater than POLY_COMPANION_CLOSED_DEG returns None — those companions are not symmetric, so ExactNumArray::eigen_decomp does not apply.

The zero polynomial returns None. A nonzero constant returns an empty vector. A negative discriminant returns an empty vector.

Trait Implementations§

Source§

impl Clone for ExactNumPoly

Source§

fn clone(&self) -> ExactNumPoly

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExactNumPoly

Source§

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

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

impl PartialEq for ExactNumPoly

Source§

fn eq(&self, other: &ExactNumPoly) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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

Source§

type Error = !

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

Source§

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.