public class BigIntPolynomial
extends java.lang.Object
BigInteger
coefficients.add
) change the polynomial, others (like mult
) do
not but return the result as a new polynomial.Modifier and Type | Field and Description |
---|---|
(package private) java.math.BigInteger[] |
coeffs |
private static double |
LOG_10_2 |
Constructor and Description |
---|
BigIntPolynomial(java.math.BigInteger[] coeffs)
Constructs a new polynomial with a given set of coefficients.
|
BigIntPolynomial(int N)
Constructs a new polynomial with
N coefficients initialized to 0. |
BigIntPolynomial(IntegerPolynomial p)
Constructs a
BigIntPolynomial from a IntegerPolynomial . |
Modifier and Type | Method and Description |
---|---|
void |
add(BigIntPolynomial b)
Adds another polynomial which can have a different number of coefficients.
|
(package private) void |
add(BigIntPolynomial b,
java.math.BigInteger modulus)
Adds another polynomial which can have a different number of coefficients,
and takes the coefficient values mod
modulus . |
java.lang.Object |
clone()
Makes a copy of the polynomial that is independent of the original.
|
BigDecimalPolynomial |
div(java.math.BigDecimal divisor,
int decimalPlaces)
Divides each coefficient by a
BigDecimal and rounds the result to decimalPlaces places. |
void |
div(java.math.BigInteger divisor)
Divides each coefficient by a
BigInteger and rounds the result to the nearest whole number.Does not return a new polynomial but modifies this polynomial. |
boolean |
equals(java.lang.Object obj) |
(package private) static BigIntPolynomial |
generateRandomSmall(int N,
int numOnes,
int numNegOnes)
Generates a random polynomial with
numOnes coefficients equal to 1,
numNegOnes coefficients equal to -1, and the rest equal to 0. |
java.math.BigInteger[] |
getCoeffs() |
int |
getMaxCoeffLength()
Returns the base10 length of the largest coefficient.
|
int |
hashCode() |
private java.math.BigInteger |
maxCoeffAbs() |
void |
mod(java.math.BigInteger modulus)
Takes each coefficient modulo a number.
|
void |
mult(java.math.BigInteger factor)
Multiplies each coefficient by a
BigInteger . |
BigIntPolynomial |
mult(BigIntPolynomial poly2)
Multiplies the polynomial by another, taking the indices mod N.
|
(package private) void |
mult(int factor)
Multiplies each coefficient by a
int . |
private BigIntPolynomial |
multRecursive(BigIntPolynomial poly2)
Karazuba multiplication
|
void |
sub(BigIntPolynomial b)
Subtracts another polynomial which can have a different number of coefficients.
|
(package private) java.math.BigInteger |
sumCoeffs()
Returns the sum of all coefficients, i.e.
|
BigIntPolynomial(int N)
N
coefficients initialized to 0.N
- the number of coefficientsBigIntPolynomial(java.math.BigInteger[] coeffs)
coeffs
- the coefficientspublic BigIntPolynomial(IntegerPolynomial p)
BigIntPolynomial
from a IntegerPolynomial
. The two polynomials are
independent of each other.p
- the original polynomialstatic BigIntPolynomial generateRandomSmall(int N, int numOnes, int numNegOnes)
numOnes
coefficients equal to 1,
numNegOnes
coefficients equal to -1, and the rest equal to 0.N
- number of coefficientsnumOnes
- number of 1'snumNegOnes
- number of -1'spublic BigIntPolynomial mult(BigIntPolynomial poly2)
poly2
- the polynomial to multiply byprivate BigIntPolynomial multRecursive(BigIntPolynomial poly2)
void add(BigIntPolynomial b, java.math.BigInteger modulus)
modulus
.b
- another polynomialpublic void add(BigIntPolynomial b)
b
- another polynomialpublic void sub(BigIntPolynomial b)
b
- another polynomialpublic void mult(java.math.BigInteger factor)
BigInteger
. Does not return a new polynomial but modifies this polynomial.factor
- void mult(int factor)
int
. Does not return a new polynomial but modifies this polynomial.factor
- public void div(java.math.BigInteger divisor)
BigInteger
and rounds the result to the nearest whole number.divisor
- the number to divide bypublic BigDecimalPolynomial div(java.math.BigDecimal divisor, int decimalPlaces)
BigDecimal
and rounds the result to decimalPlaces
places.divisor
- the number to divide bydecimalPlaces
- the number of fractional digits to round the result toBigDecimalPolynomial
public int getMaxCoeffLength()
private java.math.BigInteger maxCoeffAbs()
public void mod(java.math.BigInteger modulus)
modulus
- java.math.BigInteger sumCoeffs()
public java.lang.Object clone()
clone
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.math.BigInteger[] getCoeffs()