Skip to main content

PolyOver

Struct PolyOver 

Source
pub struct PolyOver<K> { /* private fields */ }
Expand description

A polynomial in one variable over K, little-endian, no trailing zero.

Implementations§

Source§

impl<K: OrderedField> PolyOver<K>

Source

pub fn from(c: Vec<K>) -> PolyOver<K>

Source

pub fn constant(a: K) -> PolyOver<K>

Source

pub fn zero() -> PolyOver<K>

Source

pub fn one() -> PolyOver<K>

Source

pub fn variable() -> PolyOver<K>

The variable itself.

Source

pub fn is_zero(&self) -> bool

Source

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

Source

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

The index of the lowest-order nonzero coefficient.

Source

pub fn coeff(&self, i: usize) -> K

Source

pub fn add(&self, o: &PolyOver<K>) -> PolyOver<K>

Source

pub fn neg(&self) -> PolyOver<K>

Source

pub fn mul(&self, o: &PolyOver<K>) -> PolyOver<K>

Source

pub fn scale(&self, k: &K) -> PolyOver<K>

Source

pub fn div_rem(&self, d: &PolyOver<K>) -> (PolyOver<K>, PolyOver<K>)

Euclid’s division by a nonzero d: (q, r) with self = q·d + r and deg r < deg d.

Source

pub fn monic(&self) -> PolyOver<K>

Source

pub fn gcd(&self, o: &PolyOver<K>) -> PolyOver<K>

The monic greatest common divisor.

Source

pub fn derivative(&self) -> PolyOver<K>

Source

pub fn squarefree_parts(&self) -> (K, Vec<(PolyOver<K>, usize)>)

lc · Π aᵢ^i with each aᵢ monic and squarefree and the aᵢ coprime, by Yun’s algorithm: the leading coefficient and each (aᵢ, i) of positive degree.

Source

pub fn eval(&self, t: &K) -> K

Source

pub fn spread(&self, m: usize) -> PolyOver<K>

self(x^m).

Source

pub fn squarefree(&self) -> PolyOver<K>

The squarefree part, monic: self / gcd(self, self′).

Source

pub fn shift(&self, a: &K) -> PolyOver<K>

self(x + a), by Horner’s rule.

Source

pub fn neg_var(&self) -> PolyOver<K>

self(−x).

Source

pub fn without_zero_root(&self) -> PolyOver<K>

self / x^k for the largest k that divides it: the polynomial without its root 0.

Source

pub fn reversed(&self) -> PolyOver<K>

x^n·self(1/x) for n the degree: the polynomial whose roots are the reciprocals of the nonzero roots.

Source

pub fn resultant(&self, o: &PolyOver<K>) -> K

The resultant lc^{deg o}·Π o(α) over the roots α of self, by Euclid’s algorithm.

Source

pub fn interpolate(degree: usize, at: impl Fn(i64) -> K) -> PolyOver<K>

The polynomial of degree at most degree whose value at each integer j ≤ degree is at(j), by Newton’s divided differences.

Source

pub fn sum_poly(p: &PolyOver<K>, q: &PolyOver<K>) -> PolyOver<K>

The monic polynomial whose roots are the sums rᵢ + sⱼ of a root of each, every pair once — Res_z(P(z), Q(y − z)) up to its leading coefficient — through power sums: the sums’ m-th power sum is Σ_k C(m, k)·p_k(P)·p_(m−k)(Q).

Source

pub fn product_poly(p: &PolyOver<K>, q: &PolyOver<K>) -> PolyOver<K>

The monic polynomial whose roots are the products rᵢ·sⱼ of a root of each, every pair once — Res_z(P(z), z^n·Q(y/z)) up to its leading coefficient — through power sums: the products’ m-th power sum is p_m(P)·p_m(Q).

Source

pub fn pade( series: &[K], l: usize, m: usize, ) -> Option<(PolyOver<K>, PolyOver<K>)>

The rational function num/den of numerator degree at most l and denominator degree at most m, den(0) ≠ 0, whose expansion at 0 begins with series (its first l + m + 1 coefficients), by the extended Euclidean algorithm on x^(l+m+1) and the truncated series; None when no such function exists.

Source

pub fn power_poly(p: &PolyOver<K>, k: u32) -> PolyOver<K>

The monic polynomial whose roots are the k-th powers of the roots of P, each as often as in P — Res_z(P(z), y − z^k) up to its leading coefficient. A binomial P = a·zⁿ + b, whose roots are the n-th roots of c = −b/a, has their k-th powers the roots of y^(n/g) − c^(k/g) for g = gcd(n, k), read off at once. Any other is read through the power sums of its roots: by Newton’s identities the coefficients give s₁ … s_{dk}, the k-th powers have the power sums s_k, s_{2k}, …, s_{dk}, and the same identities give their coefficients back — O(d²k) field operations, no determinant.

Trait Implementations§

Source§

impl<K: Clone> Clone for PolyOver<K>

Source§

fn clone(&self) -> PolyOver<K>

Returns a duplicate 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<K: Debug> Debug for PolyOver<K>

Source§

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

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

impl<K: Hash> Hash for PolyOver<K>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K: PartialEq> PartialEq for PolyOver<K>

Source§

fn eq(&self, other: &PolyOver<K>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K: Eq> Eq for PolyOver<K>

Source§

impl<K> StructuralPartialEq for PolyOver<K>

Auto Trait Implementations§

§

impl<K> Freeze for PolyOver<K>

§

impl<K> RefUnwindSafe for PolyOver<K>
where K: RefUnwindSafe,

§

impl<K> Send for PolyOver<K>
where K: Send,

§

impl<K> Sync for PolyOver<K>
where K: Sync,

§

impl<K> Unpin for PolyOver<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for PolyOver<K>

§

impl<K> UnwindSafe for PolyOver<K>
where K: 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> 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> 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 = 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>,

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.