Class GF256Poly

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

final class GF256Poly extends 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.

Since:
5.0.2
  • Field Details

    • field

      private final GF256 field
    • coefficients

      private final int[] coefficients
  • Constructor Details

    • GF256Poly

      GF256Poly(GF256 field, int[] coefficients)
      Parameters:
      field - the GF256 instance representing the field to use to perform computations
      coefficients - coefficients as ints representing elements of GF(256), arranged from most significant (highest-power term) coefficient to least significant
      Throws:
      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 Details

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

      GF256Poly multiply(GF256Poly other)
    • multiply

      GF256Poly multiply(int scalar)
    • multiplyByMonomial

      GF256Poly multiplyByMonomial(int degree, int coefficient)
    • divide

      GF256Poly[] divide(GF256Poly other)
    • toString

      public String toString()
      Overrides:
      toString in class Object