Interface Poly
- All Known Implementing Classes:
AbstractPoly, DensePoly, SparsePoly
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA non-zero term of a polynomial. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionPerforms polynomial addition.default intcoefficient(int degree) Returns the coefficient of the term of given exponent.intdegree()Returns the degree of this polynomial.booleanisZero()Checks whether this polynomial is the zero polynomial.minus()Returns the negated polynomial.Performs polynomial multiplication.default PolyPerforms polynomial subtraction.static Poly.Termterm(int c, int d) Creates a term with given coefficient and degree.Methods inherited from interface Iterable
forEach, iterator, spliterator
-
Field Details
-
ZERO
-
-
Method Details
-
term
Creates a term with given coefficient and degree.- Parameters:
c- the coefficient.d- the degree.- Returns:
- the term \( cx^d \).
- Throws:
IllegalArgumentException- if the degree is negative or the coefficient is zero.
-
isZero
boolean isZero()Checks whether this polynomial is the zero polynomial.- Returns:
trueif this polynomial is the zero polynomial,falseotherwise.
-
degree
int degree()Returns the degree of this polynomial.- Returns:
- the largest exponent with a non-zero coefficient.
- Throws:
IllegalStateException- if this is the zero polynomial.
-
coefficient
default int coefficient(int degree) Returns the coefficient of the term of given exponent.- Parameters:
degree- the exponent of the term to consider.- Returns:
- the coefficient of the considered term.
-
minus
Poly minus()Returns the negated polynomial.If \( p \) is this polynomial, returns \( -p \).
- Returns:
- this polynomial multiplied by \( -1 \).
-
add
Performs polynomial addition.If \( p \) is this polynomial, returns \( p + q \).
- Parameters:
q- the polynomial to add to this one.- Returns:
- the sum among this and the given polynomial.
- Throws:
NullPointerException- ifqisnull.
-
sub
Performs polynomial subtraction.If \( p \) is this polynomial, returns \( p - q \).
- Parameters:
q- the polynomial to subtract from this one.- Returns:
- the subtraction among this and the given polynomial.
- Throws:
NullPointerException- ifqisnull.
-
mul
Performs polynomial multiplication.If \( p \) is this polynomial, returns \( p q \).
- Parameters:
q- the polynomial to multiply by this one.- Returns:
- the product among this and the given polynomial.
- Throws:
NullPointerException- ifqisnull.
-