Class GaloisPolynomial
Class GaloisPolynomial
java.lang.Object
|
+----GaloisPolynomial
- public class GaloisPolynomial
- extends Object
A class for working with Polynomials.
The coefficients are elements taken from a galois field
- See Also:
- GaloisField, ExtendedGaloisField
-
ZEROCOEFS
- An array of zero coefficients to construct a zero polynomial.
-
GaloisPolynomial(int[], char, GaloisField)
- Construct a polynomial.
-
GaloisPolynomial(String, char, GaloisField)
- Construct a polynomial.
-
allPolynomials(int, char, GaloisField)
- Returns a vector containing all possible polynomials degree 0 till [deg].
-
calcHorner(int)
- Evaluates the polynomial for a given galois element using the Horner scheme.
-
copy()
- Returns a copy of this polynomial.
-
createConstant(int, char, GaloisField)
- Returns a constant 'polynomial'.
-
degree()
- Returns the degree.
-
divide(GaloisPolynomial)
- Returns the quotient of 'this' and a given polynomial.
-
equals(GaloisPolynomial)
- Check if two polynomials are equal.
-
getAlfa()
- Returns the variable.
-
getCoefficient(int)
- Returns the coefficient for position [pos].
-
getField()
- Returns the coefficient's galois field.
-
irrMonomials(int, char, GaloisField)
- Returns a vector containing all the possible irreducible monomials.
-
minus(GaloisPolynomial)
- Returns the difference between 'this' and a given polynomial.
-
product(GaloisPolynomial)
- Returns the product of 'this' and a given polynomial.
-
product_one_term(int, int)
- Returns the product of 'this' and a 'one term polynomial'.
-
sum(GaloisPolynomial)
- Returns the sum of 'this' and a given polynomial.
-
toBase()
- Converts the polynomial's coefficients into base-field elements.
-
toCoefficientString(int)
- Returns a string representation for this polynomial.
-
toExtended(GaloisField)
- Converts the polynomial's coefficients into elements of [fld2].
-
toString()
- Returns a string representation for this polynomial.
ZEROCOEFS
public final static int ZEROCOEFS[]
- An array of zero coefficients to construct a zero polynomial.
GaloisPolynomial
public GaloisPolynomial(int newcoef[],
char newalfa,
GaloisField newfield)
- Construct a polynomial.
- Parameters:
- newcoef - An array containing the coefficients.
- newalpha - The variable. For ex: 'x'.
- newfield - The coefficient galois field.
GaloisPolynomial
public GaloisPolynomial(String poly,
char newalfa,
GaloisField newfield) throws GaloisException
- Construct a polynomial. Invoke the string parser.
- Parameters:
- poly - A string representation for the polynomial.
- newalpha - The variable. For ex: 'x'.
- newfield - The coefficient galois field.
createConstant
public static GaloisPolynomial createConstant(int elem,
char newalfa,
GaloisField newfield)
- Returns a constant 'polynomial'.
- Parameters:
- elem - The constants value.
- newalpha - The variable. For ex: 'x'.
- newfield - The coefficient galois field.
calcHorner
public int calcHorner(int vl)
- Evaluates the polynomial for a given galois element using the Horner scheme.
toBase
public GaloisPolynomial toBase() throws GaloisException
- Converts the polynomial's coefficients into base-field elements.
toExtended
public GaloisPolynomial toExtended(GaloisField fld2) throws GaloisException
- Converts the polynomial's coefficients into elements of [fld2].
- Throws: GaloisException
- If [fld2] is no superfield of getField().
toString
public String toString()
- Returns a string representation for this polynomial.
For ex: 1 + 3x + 4x^2.
- Overrides:
- toString in class Object
toCoefficientString
public String toCoefficientString(int pwr)
- Returns a string representation for this polynomial.
For ex: 11010001011 GF(2) (only the coefficients are given).
For ex: 11 01 00 01 11 GF(4)
degree
public int degree()
- Returns the degree.
equals
public boolean equals(GaloisPolynomial b)
- Check if two polynomials are equal. That is, if the coefficients are equal.
getCoefficient
public int getCoefficient(int pos)
- Returns the coefficient for position [pos].
getCoefficient(0) returns the constant coefficient.
copy
public GaloisPolynomial copy()
- Returns a copy of this polynomial.
You should never use this method because a polynomial can't change.
It uses value-semantics.
sum
public GaloisPolynomial sum(GaloisPolynomial b)
- Returns the sum of 'this' and a given polynomial.
minus
public GaloisPolynomial minus(GaloisPolynomial b)
- Returns the difference between 'this' and a given polynomial.
product
public GaloisPolynomial product(GaloisPolynomial b)
- Returns the product of 'this' and a given polynomial.
product_one_term
public GaloisPolynomial product_one_term(int coef,
int pwr)
- Returns the product of 'this' and a 'one term polynomial'.
For ex: [coef]x^[pwr]
- Parameters:
- coef - The coefficient for the one-term.
- pwr - The power for the one-term.
divide
public GaloisPolynomial[] divide(GaloisPolynomial b) throws GaloisException
- Returns the quotient of 'this' and a given polynomial.
- Throws: GaloisException
- On division by zero.
irrMonomials
public static Vector irrMonomials(int deg,
char alfa,
GaloisField field)
- Returns a vector containing all the possible irreducible monomials.
in the galois field [field].
- Parameters:
- deg - The degree of the monomials.
- alfa - The variable. For ex: 'x'.
- field - The galois field.
allPolynomials
public static GaloisPolynomial[] allPolynomials(int deg,
char alfa,
GaloisField field)
- Returns a vector containing all possible polynomials degree 0 till [deg].
in the galois field [field].
- Parameters:
- deg - The maximum degree of the polynomials.
- alfa - The variable. For ex: 'x'.
- field - The galois field.
getAlfa
public char getAlfa()
- Returns the variable. For ex: 'x'.
getField
public GaloisField getField()
- Returns the coefficient's galois field.