Class GF256

java.lang.Object
com.itextpdf.text.pdf.qrcode.GF256

public final class GF256 extends 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 Details

    • QR_CODE_FIELD

      public static final GF256 QR_CODE_FIELD
    • DATA_MATRIX_FIELD

      public static final GF256 DATA_MATRIX_FIELD
    • expTable

      private final int[] expTable
    • logTable

      private final int[] logTable
    • zero

      private final GF256Poly zero
    • one

      private final GF256Poly one
  • Constructor Details

    • 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 Details

    • 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)