HFE
Class Poly64Max

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

class Poly64Max
extends java.lang.Object

This class encapsulates the operations for polynomials over the finite field F_64 which is an extension over F_4. The generation polynomial is f(x) = x^3 + x^2 + 2x + 3
The polynomials are bounded by maxLen.

Version:
0.1

Field Summary
(package private) static int extension
          Basicly the degree of the generation polynomial de facto the dimension of the vector space which can be assigned to F_64 in terms of F_4.
(package private) static Poly4Max genPoly
          Generating Polynomial over Field4.
(package private) static int maxLen
          Maximal length of the polynomials
(package private) static Poly64Max mod_additive
           
(package private) static Poly64Max modulus
          Modulus for the mod version of the operations
(package private)  int[] value
          Current value of the polynomial.
 
Constructor Summary
(package private) Poly64Max()
          sets all the coefficients to zero
(package private) Poly64Max(int initValue)
          Creates a new polynomial.
(package private) Poly64Max(int[] inArray)
          array2poly(int[])
(package private) Poly64Max(Poly64Max father)
          Creates a copy from the given polynomial
(package private) Poly64Max(Poly64Max father, int shift)
          Takes one polynomial and shifts it by the given shift.
(package private) Poly64Max(java.util.Random rnd)
          Generates a polynomial with random coefficients.
 
Method Summary
(package private)  void add(Poly64Max whom)
          calculate this += whom as polynomial addition
(package private)  void add(Poly64Max a, Poly64Max b)
          calculates this = wen1 + wen2 as polynomial addition
(package private)  void addMod(Poly64Max b)
           
(package private)  void addMod(Poly64Max a, Poly64Max b)
          Computes this = (a+b)%modul.
(package private) static int addNum(int ter1, int ter2)
          Adds two numbers using xor
(package private) static int addNumByPoly(int ter1, int ter2)
          adds two numbers using Poly4Max as representation of the numbers.
(package private)  int applyPoly(int num)
          Uses the given polynomial as a function.
(package private)  void array2poly(int[] inArray)
          Sets the coefficients using the given coefficient / power array.
(package private)  void copyShift(Poly64Max father, int shift)
          Takes one polynomial and shifts it by the given shift.
(package private)  int degree()
          Returns the degree of the object.
(package private) static int divNum(int whom, int by)
          divides whom by the number by.
(package private)  void int2poly(int intValue)
          Sets the coefficients according to intValue.
(package private)  boolean isBigger(Poly64Max whom)
          Compares the current polynomial with the given one.
(package private)  boolean isEqual(Poly64Max whom)
          Compares the current polynomial with the given one.
(package private) static void isIrr(int poly)
          Tests if a given polynomial (specified as a number, see int2poly(int)) is irreducible.
(package private)  boolean isLess(Poly64Max whom)
          Compares the current polynomial with the given one.
(package private)  boolean isZero()
          Checks if a polynomial is the zero polynomial.
static void main(java.lang.String[] args)
          Mainly invoces the testIt() method.
(package private)  void mod()
          Calculates this %= moduls.
(package private)  void mod(Poly64Max b)
          Calculates this %= b
(package private)  void mod(Poly64Max a, Poly64Max b)
          Calculates this = a % b
(package private)  void mul(Poly64Max a, Poly64Max b)
          calculates this = a * b as polynomial addition.
(package private)  void mulFactor(int factor)
          multiplies all coefficients by the given factor in F_64.
(package private)  void mulMod(Poly64Max a, Poly64Max b)
          Computes this = (this+b)%modul.
(package private) static int mulNum(int fac1, int fac2)
          multiplies two numbers by looking up the result in the multiplication table which is provided by the class Field64_Tab
(package private) static int mulNumByPoly(int fac1, int fac2)
          Multiplies two numbers using Poly4Max as representation of the numbers.
(package private) static void plotFunction()
           
(package private)  int polyInt()
          Returns the polynomial as an integer.
(package private)  void pow(Poly64Max base, int by)
          calculates this = base^by.
(package private)  void powMod(Poly64Max base, int by)
          Computes this = (base^by)%modul.
(package private) static int powNum(int num, int by)
          Computes (num^by) in F_64.
(package private) static void rootBeta()
           
(package private) static void rootFunction()
           
(package private) static void setModulus(Poly64Max newModulus)
          Sets the private field modulus.
(package private)  void setZero()
          Sets all the coefficients to zero by allocating new memory
(package private) static void testIt()
          Tests the functionality for the whole class.
(package private) static void writeDivTab()
          Produce the division table by using mulNumByPoly and Field64_Tab.inverseTab.
(package private) static void writeInverseTab()
          Produce the table with the multiplicative inverses of every element by using mulNumByPoly.
(package private) static void writeMulTab()
          Produce the multiplication table by using mulNumByPoly.
(package private)  void writeString()
          Writes the polynomial as a string to stdout
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

maxLen

static final int maxLen
Maximal length of the polynomials

genPoly

static final Poly4Max genPoly
Generating Polynomial over Field4.

extension

static final int extension
Basicly the degree of the generation polynomial de facto the dimension of the vector space which can be assigned to F_64 in terms of F_4.

modulus

static Poly64Max modulus
Modulus for the mod version of the operations

value

int[] value
Current value of the polynomial. The polynomial has at most degree (maxLen-1). Its coefficients are taken from F_64. The element value[i] is the coefficient for x^i so value[0] is the constant term for this polynomial.

mod_additive

static Poly64Max mod_additive
Constructor Detail

Poly64Max

Poly64Max()
sets all the coefficients to zero

Poly64Max

Poly64Max(int initValue)
Creates a new polynomial. int2poly(int)

Poly64Max

Poly64Max(Poly64Max father)
Creates a copy from the given polynomial

Poly64Max

Poly64Max(Poly64Max father,
          int shift)
Takes one polynomial and shifts it by the given shift. It basicly leaves out shift number of coefficients and starts copying at value[shift]. Makes a copy of this polynomial.

Poly64Max

Poly64Max(int[] inArray)
array2poly(int[])

Poly64Max

Poly64Max(java.util.Random rnd)
Generates a polynomial with random coefficients. The degree of this polynomial can be expected to be (maxLen-1).
Method Detail

setModulus

static void setModulus(Poly64Max newModulus)
Sets the private field modulus. Does not clone the moduls but storing it. Checks if the degree of the moduls is less than (maxLen/2).

degree

int degree()
Returns the degree of the object. The degree of a constant polynomial is 0, the degree of the zero polynomial is -1.

isLess

boolean isLess(Poly64Max whom)
Compares the current polynomial with the given one.
Returns:
true iff (this < whom)

isBigger

boolean isBigger(Poly64Max whom)
Compares the current polynomial with the given one.
Returns:
true iff (this > whom)

isEqual

boolean isEqual(Poly64Max whom)
Compares the current polynomial with the given one.
Returns:
true iff (this == whom) for all coefficients

isZero

boolean isZero()
Checks if a polynomial is the zero polynomial.
Returns:
true iff all coefficients are zero

setZero

void setZero()
Sets all the coefficients to zero by allocating new memory

copyShift

void copyShift(Poly64Max father,
               int shift)
Takes one polynomial and shifts it by the given shift. It basicly leaves out shift number of coefficients and starts copying at value[shift]. Makes a copy of this polynomial.

int2poly

void int2poly(int intValue)
Sets the coefficients according to intValue. The bits 0..3 are the coefficient for x^0, bits 4..7 are the coefficient for x^1, ... So this function can only set the least significant 7 coeficients.

array2poly

void array2poly(int[] inArray)
Sets the coefficients using the given coefficient / power array. The elements in this array have the form {c_0,p_0, c_1,p_1, ...} where c_i is the coefficient for x^(p_i). If there are doublicate values for p_i, the last one is taken.

addNumByPoly

static int addNumByPoly(int ter1,
                        int ter2)
adds two numbers using Poly4Max as representation of the numbers.

addNum

static int addNum(int ter1,
                  int ter2)
Adds two numbers using xor

mulNumByPoly

static int mulNumByPoly(int fac1,
                        int fac2)
Multiplies two numbers using Poly4Max as representation of the numbers.

writeMulTab

static void writeMulTab()
Produce the multiplication table by using mulNumByPoly. The table is writen to stdout as valid java statement and can be directed to a file.

mulNum

static int mulNum(int fac1,
                  int fac2)
multiplies two numbers by looking up the result in the multiplication table which is provided by the class Field64_Tab

writeInverseTab

static void writeInverseTab()
Produce the table with the multiplicative inverses of every element by using mulNumByPoly. The table is writen to stdout as valid java statement and can be directed to a file. zero is set to zero.

writeDivTab

static void writeDivTab()
Produce the division table by using mulNumByPoly and Field64_Tab.inverseTab. The table is writen to stdout as valid java statement and can be directed to a file. zero is set to zero.

divNum

static int divNum(int whom,
                  int by)
divides whom by the number by. uUses the division table provided by Field64_Tab.
Returns:
(whom/by) in F_64

mulFactor

void mulFactor(int factor)
multiplies all coefficients by the given factor in F_64.

add

void add(Poly64Max a,
         Poly64Max b)
calculates this = wen1 + wen2 as polynomial addition

add

void add(Poly64Max whom)
calculate this += whom as polynomial addition

mul

void mul(Poly64Max a,
         Poly64Max b)
calculates this = a * b as polynomial addition. Does not check if the result is of degree < maxLen

pow

void pow(Poly64Max base,
         int by)
calculates this = base^by. Does not
check if the result is of degree < maxLen

mod

void mod()
Calculates this %= moduls. Uses the static field modulus.

mod

void mod(Poly64Max a,
         Poly64Max b)
Calculates this = a % b

mod

void mod(Poly64Max b)
Calculates this %= b

addMod

void addMod(Poly64Max a,
            Poly64Max b)
Computes this = (a+b)%modul. Assumes anot check this condition.

addMod

void addMod(Poly64Max b)

mulMod

void mulMod(Poly64Max a,
            Poly64Max b)
Computes this = (this+b)%modul. Assumes thisnot check this condition.

powMod

void powMod(Poly64Max base,
            int by)
Computes this = (base^by)%modul. Assumes basenot check this condition.

powNum

static int powNum(int num,
                  int by)
Computes (num^by) in F_64.

applyPoly

int applyPoly(int num)
Uses the given polynomial as a function. Applies the value num (from F_64) to the polynomial.
Returns:
f(num)

writeString

void writeString()
Writes the polynomial as a string to stdout

polyInt

int polyInt()
Returns the polynomial as an integer. Bits 0..3 are the coefficient for x^0, Bits 4..7 are the coefficients for x^1, ... The result is only valid if maxLen < 7

testIt

static void testIt()
Tests the functionality for the whole class. Reports errors to stdout. Works only for maxLen == 15

plotFunction

static void plotFunction()

rootFunction

static void rootFunction()

rootBeta

static void rootBeta()

isIrr

static void isIrr(int poly)
Tests if a given polynomial (specified as a number, see int2poly(int)) is irreducible. If so, prints it to stdout.

main

public static void main(java.lang.String[] args)
Mainly invoces the testIt() method.