Package com.itextpdf.text.pdf.qrcode
Class GF256
- java.lang.Object
-
- com.itextpdf.text.pdf.qrcode.GF256
-
public final class GF256 extends java.lang.Object
This class contains utility methods for performing mathematical operations over the Galois Field GF(256). Operations use a given primitive polynomial in calculations.
Throughout this package, elements of GF(256) are represented as an
int
for convenience and speed (but at the cost of memory). Only the bottom 8 bits are really used.- Since:
- 5.0.2
-
-
Field Summary
Fields Modifier and Type Field Description static GF256
DATA_MATRIX_FIELD
private int[]
expTable
private int[]
logTable
private GF256Poly
one
static GF256
QR_CODE_FIELD
private GF256Poly
zero
-
Constructor Summary
Constructors Modifier Constructor Description private
GF256(int primitive)
Create a representation of GF(256) using the given primitive polynomial.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static int
addOrSubtract(int a, int b)
Implements both addition and subtraction -- they are the same in GF(256).(package private) GF256Poly
buildMonomial(int degree, int coefficient)
(package private) int
exp(int a)
(package private) GF256Poly
getOne()
(package private) GF256Poly
getZero()
(package private) int
inverse(int a)
(package private) int
log(int a)
(package private) int
multiply(int a, int b)
-
-
-
Constructor Detail
-
GF256
private GF256(int primitive)
Create a representation of GF(256) using the given primitive polynomial.- Parameters:
primitive
- irreducible polynomial whose coefficients are represented by the bits of an int, where the least-significant bit represents the constant coefficient
-
-
Method Detail
-
getZero
GF256Poly getZero()
-
getOne
GF256Poly getOne()
-
buildMonomial
GF256Poly buildMonomial(int degree, int coefficient)
- Returns:
- the monomial representing coefficient * x^degree
-
addOrSubtract
static int addOrSubtract(int a, int b)
Implements both addition and subtraction -- they are the same in GF(256).- Returns:
- sum/difference of a and b
-
exp
int exp(int a)
- Returns:
- 2 to the power of a in GF(256)
-
log
int log(int a)
- Returns:
- base 2 log of a in GF(256)
-
inverse
int inverse(int a)
- Returns:
- multiplicative inverse of a
-
multiply
int multiply(int a, int b)
- Parameters:
a
-b
-- Returns:
- product of a and b in GF(256)
-
-