Class GenericGF
- java.lang.Object
-
- com.google.zxing.common.reedsolomon.GenericGF
-
public final class GenericGF extends java.lang.ObjectThis class contains utility methods for performing mathematical operations over the Galois Fields. Operations use a given primitive polynomial in calculations.
Throughout this package, elements of the GF are represented as an
intfor convenience and speed (but at the cost of memory).The size of the GF is assumed to be a power of two.
-
-
Field Summary
Fields Modifier and Type Field Description static GenericGFAZTEC_DATA_10static GenericGFAZTEC_DATA_12static GenericGFAZTEC_DATA_6static GenericGFAZTEC_DATA_8static GenericGFAZTEC_PARAMstatic GenericGFDATA_MATRIX_FIELD_256private int[]expTableprivate intgeneratorBaseprivate int[]logTablestatic GenericGFMAXICODE_FIELD_64private GenericGFPolyoneprivate intprimitivestatic GenericGFQR_CODE_FIELD_256private intsizeprivate GenericGFPolyzero
-
Constructor Summary
Constructors Constructor Description GenericGF(int primitive, int size, int b)Create a representation of GF(size) using the given primitive polynomial.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static intaddOrSubtract(int a, int b)Implements both addition and subtraction -- they are the same in GF(size).(package private) GenericGFPolybuildMonomial(int degree, int coefficient)(package private) intexp(int a)intgetGeneratorBase()(package private) GenericGFPolygetOne()intgetSize()(package private) GenericGFPolygetZero()(package private) intinverse(int a)(package private) intlog(int a)(package private) intmultiply(int a, int b)java.lang.StringtoString()
-
-
-
Field Detail
-
AZTEC_DATA_12
public static final GenericGF AZTEC_DATA_12
-
AZTEC_DATA_10
public static final GenericGF AZTEC_DATA_10
-
AZTEC_DATA_6
public static final GenericGF AZTEC_DATA_6
-
AZTEC_PARAM
public static final GenericGF AZTEC_PARAM
-
QR_CODE_FIELD_256
public static final GenericGF QR_CODE_FIELD_256
-
DATA_MATRIX_FIELD_256
public static final GenericGF DATA_MATRIX_FIELD_256
-
AZTEC_DATA_8
public static final GenericGF AZTEC_DATA_8
-
MAXICODE_FIELD_64
public static final GenericGF MAXICODE_FIELD_64
-
expTable
private final int[] expTable
-
logTable
private final int[] logTable
-
zero
private final GenericGFPoly zero
-
one
private final GenericGFPoly one
-
size
private final int size
-
primitive
private final int primitive
-
generatorBase
private final int generatorBase
-
-
Constructor Detail
-
GenericGF
public GenericGF(int primitive, int size, int b)Create a representation of GF(size) 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 coefficientsize- the size of the fieldb- the factor b in the generator polynomial can be 0- or 1-based (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))). In most cases it should be 1, but for QR code it is 0.
-
-
Method Detail
-
getZero
GenericGFPoly getZero()
-
getOne
GenericGFPoly getOne()
-
buildMonomial
GenericGFPoly 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(size).- Returns:
- sum/difference of a and b
-
exp
int exp(int a)
- Returns:
- 2 to the power of a in GF(size)
-
log
int log(int a)
- Returns:
- base 2 log of a in GF(size)
-
inverse
int inverse(int a)
- Returns:
- multiplicative inverse of a
-
multiply
int multiply(int a, int b)- Returns:
- product of a and b in GF(size)
-
getSize
public int getSize()
-
getGeneratorBase
public int getGeneratorBase()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-