Package com.itextpdf.barcodes.qrcode
Class GF256Poly
- java.lang.Object
-
- com.itextpdf.barcodes.qrcode.GF256Poly
-
final class GF256Poly extends java.lang.Object
Represents a polynomial whose coefficients are elements of GF(256). Instances of this class are immutable.Much credit is due to William Rucklidge since portions of this code are an indirect port of his C++ Reed-Solomon implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
coefficients
private GF256
field
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) GF256Poly
addOrSubtract(GF256Poly other)
GF addition or subtraction (they are identical for a GF(2^n)(package private) GF256Poly[]
divide(GF256Poly other)
(package private) int
evaluateAt(int a)
(package private) int
getCoefficient(int degree)
(package private) int[]
getCoefficients()
(package private) int
getDegree()
(package private) boolean
isZero()
(package private) GF256Poly
multiply(int scalar)
GF scalar multiplication(package private) GF256Poly
multiply(GF256Poly other)
GF multiplication(package private) GF256Poly
multiplyByMonomial(int degree, int coefficient)
java.lang.String
toString()
-
-
-
Field Detail
-
field
private final GF256 field
-
coefficients
private final int[] coefficients
-
-
Constructor Detail
-
GF256Poly
GF256Poly(GF256 field, int[] coefficients)
- Parameters:
field
- theGF256
instance representing the field to use to perform computationscoefficients
- coefficients as ints representing elements of GF(256), arranged from most significant (highest-power term) coefficient to least significant- Throws:
java.lang.IllegalArgumentException
- if argument is null or empty, or if leading coefficient is 0 and this is not a constant polynomial (that is, it is not the monomial "0")
-
-
Method Detail
-
getCoefficients
int[] getCoefficients()
-
getDegree
int getDegree()
- Returns:
- degree of this polynomial
-
isZero
boolean isZero()
- Returns:
- true iff this polynomial is the monomial "0"
-
getCoefficient
int getCoefficient(int degree)
- Returns:
- coefficient of x^degree term in this polynomial
-
evaluateAt
int evaluateAt(int a)
- Returns:
- evaluation of this polynomial at a given point
-
addOrSubtract
GF256Poly addOrSubtract(GF256Poly other)
GF addition or subtraction (they are identical for a GF(2^n)- Parameters:
other
- the other GF-poly- Returns:
- new GF256Poly obtained by summing this GF and other
-
multiply
GF256Poly multiply(GF256Poly other)
GF multiplication- Parameters:
other
- the other GF-poly- Returns:
- new GF-poly obtained by multiplying this with other
-
multiply
GF256Poly multiply(int scalar)
GF scalar multiplication- Parameters:
scalar
- scalar- Returns:
- new GF-poly obtained by multiplying every element of this with the scalar.
-
multiplyByMonomial
GF256Poly multiplyByMonomial(int degree, int coefficient)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representation of the Galois Field polynomial.
-
-