Raw Univariate Polynomial Operations #
Operations and evaluation lemmas for raw computable univariate polynomials.
@[inline, specialize #[]]
def
CompPoly.CPolynomial.Raw.eval₂Horner
{R : Type u_1}
{S : Type u_3}
[Semiring R]
[Semiring S]
(f : R →+* S)
(x : S)
(p : Raw R)
:
S
Evaluates a CPolynomial.Raw at x : S using Horner's method.
Computes f(aₙ) + x * (f(aₙ₋₁) + x * (... + x * f(a₀))) via a right fold.
Instances For
@[inline, specialize #[]]
Evaluates a CPolynomial.Raw at a given value
Instances For
@[inline, specialize #[]]
Exponentiation of a CPolynomial.Raw by a natural number n via repeated multiplication.
This is the specification; powBySq is the efficient O(log n) implementation.
Instances For
@[irreducible, inline, specialize #[]]
Exponentiation via repeated squaring: $ O(\log n) $ multiplications instead of $ O(n) $.
For $ n > 0 $, computes $ p ^ n $ by recursing on $ n / 2 $:
- If $ n $ is even: $ (p ^ {n/2})^2 $
- If $ n $ is odd: $ p \cdot (p ^ {n/2})^2 $
Instances For
Convert degreeBound to a natural number by sending ⊥ to 0.
Instances For
Pseudo-division by X: removes the constant term and shifts remaining coefficients left.