public class BigDecimalPolynomial
extends java.lang.Object
BigDecimal
coefficients.
Some methods (like 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.BigDecimal[] |
coeffs |
private static java.math.BigDecimal |
ONE_HALF |
private static java.math.BigDecimal |
ZERO |
Constructor and Description |
---|
BigDecimalPolynomial(java.math.BigDecimal[] coeffs)
Constructs a new polynomial with a given set of coefficients.
|
BigDecimalPolynomial(BigIntPolynomial p)
Constructs a
BigDecimalPolynomial from a BigIntPolynomial . |
BigDecimalPolynomial(int N)
Constructs a new polynomial with
N coefficients initialized to 0. |
Modifier and Type | Method and Description |
---|---|
void |
add(BigDecimalPolynomial b)
Adds another polynomial which can have a different number of coefficients.
|
java.lang.Object |
clone()
Makes a copy of the polynomial that is independent of the original.
|
private java.math.BigDecimal[] |
copyOf(java.math.BigDecimal[] a,
int length) |
private java.math.BigDecimal[] |
copyOfRange(java.math.BigDecimal[] a,
int from,
int to) |
java.math.BigDecimal[] |
getCoeffs() |
void |
halve()
Divides all coefficients by 2.
|
BigDecimalPolynomial |
mult(BigDecimalPolynomial poly2)
Multiplies the polynomial by another, taking the indices mod N.
|
BigDecimalPolynomial |
mult(BigIntPolynomial poly2)
Multiplies the polynomial by another.
|
private BigDecimalPolynomial |
multRecursive(BigDecimalPolynomial poly2)
Karazuba multiplication
|
BigIntPolynomial |
round()
Rounds all coefficients to the nearest integer.
|
(package private) void |
sub(BigDecimalPolynomial b)
Subtracts another polynomial which can have a different number of coefficients.
|
private static final java.math.BigDecimal ZERO
private static final java.math.BigDecimal ONE_HALF
java.math.BigDecimal[] coeffs
BigDecimalPolynomial(int N)
N
coefficients initialized to 0.N
- the number of coefficientsBigDecimalPolynomial(java.math.BigDecimal[] coeffs)
coeffs
- the coefficientspublic BigDecimalPolynomial(BigIntPolynomial p)
BigDecimalPolynomial
from a BigIntPolynomial
. The two polynomials are independent of each other.p
- the original polynomialpublic void halve()
public BigDecimalPolynomial mult(BigIntPolynomial poly2)
poly2
- the polynomial to multiply bypublic BigDecimalPolynomial mult(BigDecimalPolynomial poly2)
poly2
- the polynomial to multiply byprivate BigDecimalPolynomial multRecursive(BigDecimalPolynomial poly2)
public void add(BigDecimalPolynomial b)
b
- another polynomialvoid sub(BigDecimalPolynomial b)
b
- public BigIntPolynomial round()
BigInteger
coefficientspublic java.lang.Object clone()
clone
in class java.lang.Object
private java.math.BigDecimal[] copyOf(java.math.BigDecimal[] a, int length)
private java.math.BigDecimal[] copyOfRange(java.math.BigDecimal[] a, int from, int to)
public java.math.BigDecimal[] getCoeffs()