HFE
Class Field2

java.lang.Object
  |
  +--HFE.Field2

final class Field2
extends java.lang.Object

This class encapsulates the operations for a finite field with 2 elements.
Operations are performed using and (mul) and xor (add).

Version:
0.1

Field Summary
static int elements
          number of elements in this field
 
Constructor Summary
(package private) Field2()
           
 
Method Summary
static int add(int ter1, int ter2)
          Adds two numbers using the xor function for intergers.
static int div(int whom, int by)
          Divides two numbers using finite field arithmetic in F_2.
static boolean isElement(int elem)
          Checks if a given integer is within the range of a Field2 element.
static boolean isElement(int[] elems)
          Checks if a given vector consists only of Field2 elements.
static boolean isElement(int[][] elems)
          Checks if a given matrix consists only of Field2 elements.
static void main(java.lang.String[] args)
          Tests everything in this class
static int mul(int fac1, int fac2)
          Multiplies two numbers using finite field arithmetic in F_4.
static int rnd(java.util.Random rnd)
          returns a random element from Field2.
static int sub(int ter1, int ter2)
          Subtracts two numbers using the xor function for intergers.
static void testIt()
          Tests the functionality of the whole class.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

elements

public static final int elements
number of elements in this field
Constructor Detail

Field2

Field2()
Method Detail

isElement

public static boolean isElement(int elem)
Checks if a given integer is within the range of a Field2 element.
Returns:
is elem in the range of an Field2 element

isElement

public static boolean isElement(int[] elems)
Checks if a given vector consists only of Field2 elements.
Returns:
true iff all elements of the vector are Field2 elements.

isElement

public static boolean isElement(int[][] elems)
Checks if a given matrix consists only of Field2 elements.
Returns:
true iff all elements of the matrix are Field2 elements.

add

public static final int add(int ter1,
                            int ter2)
Adds two numbers using the xor function for intergers. Note: This works for any extionsion field over p=2.
Parameters:
ter1 - element of F_4
ter2 - element of F_4
Returns:
(ter1 + ter2) over F_4

sub

public static final int sub(int ter1,
                            int ter2)
Subtracts two numbers using the xor function for intergers. Note: This works for any extionsion field over p=2
Parameters:
ter1 - element of F_4
ter2 - element of F_4
Returns:
(ter1 - ter2) over F_4

mul

public static final int mul(int fac1,
                            int fac2)
Multiplies two numbers using finite field arithmetic in F_4. For the sake of speed I store the results in an lookup table.
Parameters:
fac1 - element of F_4
fac2 - element of F_4
Returns:
(fac1 * fac2) over F_4

div

public static final int div(int whom,
                            int by)
Divides two numbers using finite field arithmetic in F_2. Should not be used as the only by possible is 1...
Parameters:
whom - which number should be divised
by - which number divides
Returns:
(whom/by) over F_2

rnd

public static final int rnd(java.util.Random rnd)
returns a random element from Field2.

testIt

public static final void testIt()
Tests the functionality of the whole class. If there occurs any error it will be printed on stdout.

main

public static void main(java.lang.String[] args)
Tests everything in this class
See Also:
testIt()