Class GaloisField
Class GaloisField
java.lang.Object
|
+----GaloisField
- public class GaloisField
- extends Object
-
ALFAPOWER
- A constant for the display mode ALFAPOWER
For ex: valueString(a) -> a^k
-
ONE
- A constant for the galois element one '1'
-
POLYCOEFS
- A constant for the display mode POLYCOEFS
For ex: valueString(a) -> 1 1
-
POLYNOMIAL
- A constant for the display mode POLYNOMIAL
For ex: valueString(a) -> 1+a
-
ZERO
- A constant for the galois element zero '0'
-
GaloisField(int)
- Creates a new base galois field.
-
GaloisField(int, int)
- This constructor is for internal use only.
-
atoi(String)
- Converts a string to an integer.
-
cleanString(String)
- Cleans a string.
-
divide(int, int)
- Returns a / b.
-
fillString(char, int)
- Returns a string length [len] containing nothing but characters [ch].
-
getAlfa()
- Returns the character used for alpha in a polynomial representation.
-
getAlfaPower(int)
- Returns a power of the primitive element.
-
getAllCyclotomics(int)
- Returns all the cyclotomics modulo [modulo].
-
getBase()
- Returns the base field.
-
getCardinality()
- Returns the cardinality.
-
getCyclotomic(int, int)
- Returns the cyclotomic of [elem] modulo [modulo].
-
getDisplayMode()
- Returns the display mode.
-
getKPrimitiveNRoot(int)
- Method for construction of primitive roots for 'one'.
-
getMinimalPolynomial(int, char)
- Returns a minimal polynomial.
-
getRoot()
- Returns the root field.
-
isBase()
- Is this field a base field?.
-
minus(int, int)
- Returns a - b.
-
modulo(int, int)
- Returns (a mod b).
-
normalise(int)
- Normalises a galois element.
-
parse(String, int)
- Converts a string to a galois element.
-
power(int, int)
- Calculates the power of a given integer.
-
product(int, int)
- Returns the product of two galois elements.
-
setDisplayMode(int)
- Set a new display mode.
-
sum(int, int)
- Returns the sum of two galois elements.
-
toBase(int)
- Converts a galois element from 'this' field to the base field.
-
toExtended(int, GaloisField)
- Converts a galois element from 'this' field to a given ExtendedGaloisField.
-
toString()
- Returns a String representation of this field.
-
toSuper(int)
- Converts a galois element from the base field to 'this' field.
-
valueString(int)
- Returns a String representation for the given element.
ZERO
public final static int ZERO
- A constant for the galois element zero '0'
ONE
public final static int ONE
- A constant for the galois element one '1'
ALFAPOWER
public final static int ALFAPOWER
- A constant for the display mode ALFAPOWER
For ex: valueString(a) -> a^k
POLYNOMIAL
public final static int POLYNOMIAL
- A constant for the display mode POLYNOMIAL
For ex: valueString(a) -> 1+a
POLYCOEFS
public final static int POLYCOEFS
- A constant for the display mode POLYCOEFS
For ex: valueString(a) -> 1 1
GaloisField
public GaloisField(int p) throws GaloisException
- Creates a new base galois field.
- Parameters:
- p - The cardinality for the new field.
- Throws: GaloisException
- If p is not a prime number.
GaloisField
public GaloisField(int newcard,
int newalfa)
- This constructor is for internal use only. Do not call it directly!
- Parameters:
- newcard - The cardinality for the new field.
- newalpha - The index of the primitive element.
setDisplayMode
public void setDisplayMode(int newmode)
- Set a new display mode.
See: 'ALFAPOWER'
See: 'POLYNOMIAL'
See: 'POLYCOEFS'
- Parameters:
- newmode - One of the supported display modes.
getDisplayMode
public int getDisplayMode()
- Returns the display mode.
See: setDisplayMode
getCardinality
public int getCardinality()
- Returns the cardinality.
normalise
public int normalise(int element)
- Normalises a galois element.
Returns the modulo value of the element in [0,getCardinality()-1].
toString
public String toString()
- Returns a String representation of this field.
Something like "Base Galois Field GF(5)".
- Overrides:
- toString in class Object
sum
public int sum(int a,
int b)
- Returns the sum of two galois elements.
minus
public int minus(int a,
int b)
- Returns a - b.
product
public int product(int a,
int b)
- Returns the product of two galois elements.
divide
public int divide(int a,
int b) throws GaloisException
- Returns a / b.
- Throws: GaloisException
- If b = 0 (Division by zero).
getCyclotomic
public int[] getCyclotomic(int modulo,
int elem)
- Returns the cyclotomic of [elem] modulo [modulo].
This is an array of primitive element powers.
- Parameters:
- modulo - The modulo parameter for the cyclotomic.
- elem - The starting power.
getAllCyclotomics
public Vector getAllCyclotomics(int modulo)
- Returns all the cyclotomics modulo [modulo].
This is a Vector of cyclotomics.
See: getCyclotomic
- Parameters:
- modulo - The modulo parameter for the cyclotomic.
getKPrimitiveNRoot
public int[] getKPrimitiveNRoot(int n)
- Method for construction of primitive roots for 'one'.
Returns an array of two integers.
The first is the k-parameter for the extended field containing the root.
The second is the power p of the primitive element in that field.
beta^n = 1, beta = alpha^p in GF(base^k).
- Parameters:
- n - Take the n-th root of 'one'.
getMinimalPolynomial
public GaloisPolynomial getMinimalPolynomial(int alphapwr,
char talfa) throws GaloisException
- Returns a minimal polynomial.
- Parameters:
- alphapwr - To identify the polynomial: p(alpha^alphapwr) = 0.
- talpha - The polynomial variable. For ex: 'x'.
- Throws: GaloisException
- If an error occurs.
getAlfaPower
public int getAlfaPower(int pwr)
- Returns a power of the primitive element.
valueString
public String valueString(int a)
- Returns a String representation for the given element.
isBase
public boolean isBase()
- Is this field a base field?.
getBase
public GaloisField getBase()
- Returns the base field.
getRoot
public GaloisField getRoot()
- Returns the root field.
If 'this' = GF((p^k)...^q)) this method returns GF(p).
toBase
public int toBase(int a) throws GaloisException
- Converts a galois element from 'this' field to the base field.
- Throws: GaloisException
- If the element can't be found in the base field.
toSuper
public int toSuper(int a) throws GaloisException
- Converts a galois element from the base field to 'this' field.
- Throws: GaloisException
- If the element can't be converted.
toExtended
public int toExtended(int a,
GaloisField till) throws GaloisException
- Converts a galois element from 'this' field to a given ExtendedGaloisField.
- Throws: GaloisException
- If 'this' is no sub-field of the given field.
getAlfa
public char getAlfa()
- Returns the character used for alpha in a polynomial representation.
cleanString
public static String cleanString(String strg)
- Cleans a string. Removes all surrounding spaces and parantheses.
For ex: " ( (lk()dj )) " -> "lk()dj"
parse
public int parse(String strg,
int onempty) throws GaloisException
- Converts a string to a galois element.
- Throws: GaloisException
- If the string is no valid representation.
atoi
public static int atoi(String intvl) throws GaloisException
- Converts a string to an integer.
- Throws: GaloisException
- If there are illegal characters in the string.
power
public static int power(int what,
int vl)
- Calculates the power of a given integer.
Warning: this is not the power function for galois elements.
fillString
public static String fillString(char ch,
int len)
- Returns a string length [len] containing nothing but characters [ch].
modulo
public static int modulo(int a,
int b)
- Returns (a mod b).