Package org.moddingx.libx.util.math
Class IntPolynomial
- All Implemented Interfaces:
Function<Integer,
,Integer> IntFunction<Integer>
,IntUnaryOperator
,UnaryOperator<Integer>
public final class IntPolynomial
extends Polynomial<Integer>
implements IntUnaryOperator, IntFunction<Integer>
A polynomial with integer coefficients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<IntPolynomial>
static final IntPolynomial
The identity polynomial.static final IntPolynomial
The polynomial that is always one.static final IntPolynomial
The polynomial that is always zero. -
Constructor Summary
ConstructorDescriptionIntPolynomial
(int... coefficients) Creates a new polynomial with the given coefficients. -
Method Summary
Modifier and TypeMethodDescriptionadd
(Polynomial<Integer> other) Adds two polynomials together.apply
(int x) Computes the value of the polynomial at the given input.Computes the value of the polynomial at the given input.int
applyAsInt
(int x) Computes the value of the polynomial at the given input.Gets the coefficients of this polynomial.Computes the derivative of this polynomial.boolean
int
hashCode()
multiply
(Polynomial<Integer> other) Multiplies two polynomials.negate()
Negates this polynomial.toDouble()
Converts this polynomial to aDoublePolynomial
.Methods inherited from class org.moddingx.libx.util.math.Polynomial
subtract, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.IntUnaryOperator
andThen, compose
-
Field Details
-
CODEC
-
ZERO
The polynomial that is always zero. -
ONE
The polynomial that is always one. -
IDENTITY
The identity polynomial.
-
-
Constructor Details
-
IntPolynomial
public IntPolynomial(int... coefficients) Creates a new polynomial with the given coefficients.new IntPolynomial(2,0,1)
gives for example the polynomial2x²+1
.
-
-
Method Details
-
coefficients
Description copied from class:Polynomial
Gets the coefficients of this polynomial. For example, the coefficients[2, 0 1]
represent the polynomial2x²+1
.- Specified by:
coefficients
in classPolynomial<Integer>
-
applyAsInt
public int applyAsInt(int x) Computes the value of the polynomial at the given input.- Specified by:
applyAsInt
in interfaceIntUnaryOperator
-
apply
Computes the value of the polynomial at the given input.- Specified by:
apply
in interfaceIntFunction<Integer>
-
apply
Computes the value of the polynomial at the given input. -
derivative
Description copied from class:Polynomial
Computes the derivative of this polynomial.- Specified by:
derivative
in classPolynomial<Integer>
-
negate
Description copied from class:Polynomial
Negates this polynomial.- Specified by:
negate
in classPolynomial<Integer>
-
add
Description copied from class:Polynomial
Adds two polynomials together.- Specified by:
add
in classPolynomial<Integer>
-
multiply
Description copied from class:Polynomial
Multiplies two polynomials.- Specified by:
multiply
in classPolynomial<Integer>
-
toDouble
Converts this polynomial to aDoublePolynomial
. -
hashCode
public int hashCode() -
equals
-