Class BigIntPolynomial
- java.lang.Object
-
- org.bouncycastle.pqc.math.ntru.polynomial.BigIntPolynomial
-
public class BigIntPolynomial extends java.lang.ObjectA polynomial withBigIntegercoefficients.
Some methods (likeadd) change the polynomial, others (likemult) do not but return the result as a new polynomial.
-
-
Constructor Summary
Constructors Constructor Description BigIntPolynomial(IntegerPolynomial p)Constructs aBigIntPolynomialfrom aIntegerPolynomial.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(BigIntPolynomial b)Adds another polynomial which can have a different number of coefficients.java.lang.Objectclone()Makes a copy of the polynomial that is independent of the original.BigDecimalPolynomialdiv(java.math.BigDecimal divisor, int decimalPlaces)Divides each coefficient by aBigDecimaland rounds the result todecimalPlacesplaces.voiddiv(java.math.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.booleanequals(java.lang.Object obj)java.math.BigInteger[]getCoeffs()intgetMaxCoeffLength()Returns the base10 length of the largest coefficient.inthashCode()voidmod(java.math.BigInteger modulus)Takes each coefficient modulo a number.voidmult(java.math.BigInteger factor)Multiplies each coefficient by aBigInteger.BigIntPolynomialmult(BigIntPolynomial poly2)Multiplies the polynomial by another, taking the indices mod N.voidsub(BigIntPolynomial b)Subtracts another polynomial which can have a different number of coefficients.
-
-
-
Constructor Detail
-
BigIntPolynomial
public BigIntPolynomial(IntegerPolynomial p)
Constructs aBigIntPolynomialfrom aIntegerPolynomial. The two polynomials are independent of each other.- Parameters:
p- the original polynomial
-
-
Method Detail
-
mult
public BigIntPolynomial mult(BigIntPolynomial poly2)
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
public void add(BigIntPolynomial b)
Adds another polynomial which can have a different number of coefficients.- Parameters:
b- another polynomial
-
sub
public void sub(BigIntPolynomial b)
Subtracts another polynomial which can have a different number of coefficients.- Parameters:
b- another polynomial
-
mult
public void mult(java.math.BigInteger factor)
Multiplies each coefficient by aBigInteger. Does not return a new polynomial but modifies this polynomial.- Parameters:
factor-
-
div
public void div(java.math.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.- Parameters:
divisor- the number to divide by
-
div
public BigDecimalPolynomial div(java.math.BigDecimal divisor, int decimalPlaces)
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
public void mod(java.math.BigInteger modulus)
Takes each coefficient modulo a number.- Parameters:
modulus-
-
clone
public java.lang.Object clone()
Makes a copy of the polynomial that is independent of the original.- Overrides:
clonein classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getCoeffs
public java.math.BigInteger[] getCoeffs()
-
-