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
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<IntPolynomial> static final IntPolynomialThe identity polynomial.static final IntPolynomialThe polynomial that is always one.static final net.minecraft.network.codec.StreamCodec<ByteBuf, IntPolynomial> static final IntPolynomialThe polynomial that is always zero. -
Constructor Summary
ConstructorsConstructorDescriptionIntPolynomial(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.intapplyAsInt(int x) Computes the value of the polynomial at the given input.Gets the coefficients of this polynomial.Computes the derivative of this polynomial.booleaninthashCode()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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.IntUnaryOperator
andThen, compose
-
Field Details
-
CODEC
-
STREAM_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:PolynomialGets the coefficients of this polynomial. For example, the coefficients[2, 0 1]represent the polynomial2x²+1.- Specified by:
coefficientsin classPolynomial<Integer>
-
applyAsInt
public int applyAsInt(int x) Computes the value of the polynomial at the given input.- Specified by:
applyAsIntin interfaceIntUnaryOperator
-
apply
Computes the value of the polynomial at the given input.- Specified by:
applyin interfaceIntFunction<Integer>
-
apply
Computes the value of the polynomial at the given input. -
derivative
Description copied from class:PolynomialComputes the derivative of this polynomial.- Specified by:
derivativein classPolynomial<Integer>
-
negate
Description copied from class:PolynomialNegates this polynomial.- Specified by:
negatein classPolynomial<Integer>
-
add
Description copied from class:PolynomialAdds two polynomials together.- Specified by:
addin classPolynomial<Integer>
-
multiply
Description copied from class:PolynomialMultiplies two polynomials.- Specified by:
multiplyin classPolynomial<Integer>
-
toDouble
Converts this polynomial to aDoublePolynomial. -
hashCode
public int hashCode() -
equals
-