Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.math.ntru.polynomial

public Class BigDecimalPolynomial

extends Object
Class Inheritance
Imports
java.math.BigDecimal

A polynomial with BigDecimal coefficients. Some methods (like add) change the polynomial, others (like mult) do not but return the result as a new polynomial.

Field Summary

Modifier and TypeField and Description
pack-priv BigDecimal[]
private static final BigDecimal
private static final BigDecimal

Constructor Summary

AccessConstructor and Description
pack-priv
BigDecimalPolynomial(int
the number of coefficients
N
)

Constructs a new polynomial with N coefficients initialized to 0.

pack-priv
BigDecimalPolynomial(BigDecimal[]
the coefficients
coeffs
)

Constructs a new polynomial with a given set of coefficients.

public
BigDecimalPolynomial(BigIntPolynomial
the original polynomial
p
)

Constructs a BigDecimalPolynomial from a BigIntPolynomial.

Method Summary

Modifier and TypeMethod and Description
public void
add(BigDecimalPolynomial
another polynomial
b
)

Adds another polynomial which can have a different number of coefficients.

public Object
clone()

Overrides java.lang.Object.clone.

Makes a copy of the polynomial that is independent of the original.
private BigDecimal[]
copyOf(BigDecimal[] a, int length)

private BigDecimal[]
copyOfRange(BigDecimal[] a, int from, int to)

public BigDecimal[]
public void
halve()

Divides all coefficients by 2.

public BigDecimalPolynomial

Returns:

a new polynomial
mult
(BigIntPolynomial
the polynomial to multiply by
poly2
)

Multiplies the polynomial by another.

public BigDecimalPolynomial

Returns:

a new polynomial
mult
(BigDecimalPolynomial
the polynomial to multiply by
poly2
)

Multiplies the polynomial by another, taking the indices mod N.

private BigDecimalPolynomial
multRecursive(BigDecimalPolynomial poly2)

Karazuba multiplication

public BigIntPolynomial

Returns:

a new polynomial with BigInteger coefficients
round
()

Rounds all coefficients to the nearest integer.

pack-priv void
sub(BigDecimalPolynomial b)

Subtracts another polynomial which can have a different number of coefficients.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

coeffsback to summary
pack-priv BigDecimal[] coeffs
ONE_HALFback to summary
private static final BigDecimal ONE_HALF
ZEROback to summary
private static final BigDecimal ZERO

Constructor Detail

BigDecimalPolynomialback to summary
pack-priv BigDecimalPolynomial(int N)

Constructs a new polynomial with N coefficients initialized to 0.

Parameters
N:int

the number of coefficients

BigDecimalPolynomialback to summary
pack-priv BigDecimalPolynomial(BigDecimal[] coeffs)

Constructs a new polynomial with a given set of coefficients.

Parameters
coeffs:BigDecimal[]

the coefficients

BigDecimalPolynomialback to summary
public BigDecimalPolynomial(BigIntPolynomial p)

Constructs a BigDecimalPolynomial from a BigIntPolynomial. The two polynomials are independent of each other.

Parameters
p:BigIntPolynomial

the original polynomial

Method Detail

addback to summary
public void add(BigDecimalPolynomial b)

Adds another polynomial which can have a different number of coefficients.

Parameters
b:BigDecimalPolynomial

another polynomial

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Makes a copy of the polynomial that is independent of the original.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

copyOfback to summary
private BigDecimal[] copyOf(BigDecimal[] a, int length)
copyOfRangeback to summary
private BigDecimal[] copyOfRange(BigDecimal[] a, int from, int to)
getCoeffsback to summary
public BigDecimal[] getCoeffs()
halveback to summary
public void halve()

Divides all coefficients by 2.

multback to summary
public BigDecimalPolynomial mult(BigIntPolynomial poly2)

Multiplies the polynomial by another. Does not change this polynomial but returns the result as a new polynomial.

Parameters
poly2:BigIntPolynomial

the polynomial to multiply by

Returns:BigDecimalPolynomial

a new polynomial

multback to summary
public BigDecimalPolynomial mult(BigDecimalPolynomial poly2)

Multiplies the polynomial by another, taking the indices mod N. Does not change this polynomial but returns the result as a new polynomial.

Parameters
poly2:BigDecimalPolynomial

the polynomial to multiply by

Returns:BigDecimalPolynomial

a new polynomial

multRecursiveback to summary
private BigDecimalPolynomial multRecursive(BigDecimalPolynomial poly2)

Karazuba multiplication

roundback to summary
public BigIntPolynomial round()

Rounds all coefficients to the nearest integer.

Returns:BigIntPolynomial

a new polynomial with BigInteger coefficients

subback to summary
pack-priv void sub(BigDecimalPolynomial b)

Subtracts another polynomial which can have a different number of coefficients.