Class BigIntPolynomial
java.lang.Object
org.bouncycastle.pqc.legacy.math.ntru.polynomial.BigIntPolynomial
A polynomial with
Some methods (like
BigInteger coefficients.Some methods (like
add) change the polynomial, others (like mult) do
not but return the result as a new polynomial.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aBigIntPolynomialfrom aIntegerPolynomial. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds another polynomial which can have a different number of coefficients.clone()Makes a copy of the polynomial that is independent of the original.div(BigDecimal divisor, int decimalPlaces) Divides each coefficient by aBigDecimaland rounds the result todecimalPlacesplaces.voiddiv(BigInteger divisor) Divides each coefficient by aBigIntegerand rounds the result to the nearest whole number.
Does not return a new polynomial but modifies this polynomial.booleanintReturns the base10 length of the largest coefficient.inthashCode()voidmod(BigInteger modulus) Takes each coefficient modulo a number.voidmult(BigInteger factor) Multiplies each coefficient by aBigInteger.mult(BigIntPolynomial poly2) Multiplies the polynomial by another, taking the indices mod N.voidSubtracts another polynomial which can have a different number of coefficients.
-
Constructor Details
-
BigIntPolynomial
Constructs aBigIntPolynomialfrom aIntegerPolynomial. The two polynomials are independent of each other.- Parameters:
p- the original polynomial
-
-
Method Details
-
mult
Multiplies the polynomial by another, taking the indices mod N. Does not change this polynomial but returns the result as a new polynomial.
Both polynomials must have the same number of coefficients.- Parameters:
poly2- the polynomial to multiply by- Returns:
- a new polynomial
-
add
Adds another polynomial which can have a different number of coefficients.- Parameters:
b- another polynomial
-
sub
Subtracts another polynomial which can have a different number of coefficients.- Parameters:
b- another polynomial
-
mult
Multiplies each coefficient by aBigInteger. Does not return a new polynomial but modifies this polynomial.- Parameters:
factor-
-
div
Divides each coefficient by aBigIntegerand rounds the result to the nearest whole number.
Does not return a new polynomial but modifies this polynomial.- Parameters:
divisor- the number to divide by
-
div
Divides each coefficient by aBigDecimaland rounds the result todecimalPlacesplaces.- Parameters:
divisor- the number to divide bydecimalPlaces- the number of fractional digits to round the result to- Returns:
- a new
BigDecimalPolynomial
-
getMaxCoeffLength
public int getMaxCoeffLength()Returns the base10 length of the largest coefficient.- Returns:
- length of the longest coefficient
-
mod
Takes each coefficient modulo a number.- Parameters:
modulus-
-
clone
Makes a copy of the polynomial that is independent of the original. -
hashCode
public int hashCode() -
equals
-
getCoeffs
-