Evaluate the polynomial at x
.
Returns the coefficients in little-endian order.
Returns the coefficients in little-endian order. So, the i-th element is coeffsArray(i) * (x ** i).
Returns the degree of this polynomial.
Traverses each term in this polynomial, in order of degree, lowest to highest (eg.
Traverses each term in this polynomial, in order of degree, lowest to
highest (eg. constant term would be first) and calls f
with the degree
of term and its coefficient. This may skip zero terms, or it may not.
Returns true
if this polynomial is ring.zero
.
Returns the coefficient of max term of this polynomial.
Returns the coefficient of the n-th degree term.
Returns a polynomial with the max term removed.
Return an iterator of non-zero terms.
Return an iterator of non-zero terms.
This method is used to implement equals and hashCode.
NOTE: This method uses a (_ == 0) test to prune zero values. This makes sense in a context where Semiring[C] and Eq[C] are unavailable, but not other places.
Returns a polynmial that has a dense representation.
Returns a polynomial that has a sparse representation.
Compose this polynomial with another.
Returns a map from exponent to coefficient of this polynomial.
This will flip/mirror the polynomial about the y-axis.
This will flip/mirror the polynomial about the y-axis. It is equivalent to
poly.compose(-Polynomial.x)
, but will likely be faster to calculate.
Traverses each non-zero term in this polynomial, in order of degree, lowest to highest (eg.
Traverses each non-zero term in this polynomial, in order of degree, lowest
to highest (eg. constant term would be first) and calls f
with the degree
of term and its coefficient.
Returns true
iff this polynomial is constant.
Returns the term of the highest degree in this polynomial.
Returns the non-zero term of the minimum degree in this polynomial, unless it is zero.
Returns the non-zero term of the minimum degree in this polynomial, unless it is zero. If this polynomial is zero, then this returns a zero term.
Returns this polynomial as a monic polynomial, where the leading coefficient (ie.
Returns this polynomial as a monic polynomial, where the leading
coefficient (ie. maxOrderTermCoeff
) is 1.
Returns the reciprocal of this polynomial.
Returns the reciprocal of this polynomial. Essentially, if this polynomial
is p
with degree n
, then returns a polynomial q(x) = x^n*p(1/x)
.
http://en.wikipedia.org/wiki/Reciprocal_polynomial
Removes all zero roots from this polynomial.
Returns the real roots of this polynomial.
Returns the real roots of this polynomial.
Depending on C
, the finder
argument may need to be passed "explicitly"
via an implicit conversion. This is because some types (eg BigDecimal
,
Rational
, etc) require an error bound, and so provide implicit
conversions to RootFinder
s from the error type. For instance,
BigDecimal
requires either a scale or MathContext. So, we'd call this
method with poly.roots(MathContext.DECIMAL128)
, which would return a
Roots[BigDecimal
whose roots are approximated to the precision specified
in DECIMAL128
and rounded appropriately.
On the other hand, a type like Double
doesn't require an error bound and
so can be called without specifying the RootFinder
.
a root finder to extract roots with
the real roots of this polynomial
Shift this polynomial along the x-axis by h
, so that this(x + h) ==
this.shift(h).apply(x)
.
Shift this polynomial along the x-axis by h
, so that this(x + h) ==
this.shift(h).apply(x)
. This is equivalent to calling
this.compose(Polynomial.x + h)
, but is likely to compute the shifted
polynomial much faster.
Returns the number of sign variations in the coefficients of this polynomial.
Returns the number of sign variations in the coefficients of this polynomial. Given 2 consecutive terms (ignoring 0 terms), a sign variation is indicated when the terms have differing signs.
Returns a list of non-zero terms.