HFE
Class Poly4Max

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

final class Poly4Max
extends java.lang.Object

This class provides polynomials of positive degree over the finite field F_4 which is provided in the class Field4. It also provides addition, multiplication and modulo-operations The maximal degree of the polynomials is fixed by the constant maxLen

Version:
0.1

Field Summary
static int maxLen
          Maximal length of the polynomials
private static Poly4Max modulus
          Modulus for the mod version of the operations
private  int[] value
          Current value of the polynomial.
 
Constructor Summary
(package private) Poly4Max()
          sets all the coefficients to zero
(package private) Poly4Max(int initValue)
          Creates a new polynomial.
(package private) Poly4Max(int[] inArray)
          array2poly(int[])
(package private) Poly4Max(Poly4Max father)
          Creates a copy from the given polynomial
(package private) Poly4Max(Poly4Max father, int shift)
          Takes one polynomial and shifts it by the given shift.
 
Method Summary
(package private)  void add(Poly4Max whom)
          calculate this += whom as polynomial addition
(package private)  void add(Poly4Max a, Poly4Max b)
          calculates this = wen1 + wen2 as polynomial addition
(package private)  void addMod(Poly4Max b)
          Computes this = (this+b)%modul.
(package private)  void addMod(Poly4Max a, Poly4Max b)
          Computes this = (a+b)%modul.
(package private)  void array2poly(int[] inArray)
          Sets the coefficients using the given coefficient / power array.
(package private)  int coeff(int which)
          Returns te coefficient for a given degree which (i.e.
(package private)  int degree()
          Returns the degree of the object.
(package private) static void findIrr()
          Find all irreducible polynomials.
(package private)  void int2poly(int intValue)
          Sets the coefficients according to intValue.
(package private)  boolean isBigger(Poly4Max whom)
          Compares the current polynomial with the given one.
(package private)  boolean isEqual(Poly4Max 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(Poly4Max 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(Poly4Max b)
          Calculates this %= b
(package private)  void mod(Poly4Max a, Poly4Max b)
          Calculates this = a % b
(package private)  void mul(Poly4Max a, Poly4Max b)
          calculates this = a * b as polynomial addition.
(package private)  void mulFactor(int factor)
          multiplies all coefficients by the given factor in F_4.
(package private)  void mulMod(Poly4Max a, Poly4Max b)
          Computes this = (a*b)%modul.
(package private) static void plotFunction()
           
(package private)  int polyInt()
          Returns the polynomial as an integer.
(package private)  void pow(Poly4Max base, int by)
          calculates this = base^by.
(package private)  void powMod(Poly4Max base, int by)
          Computes this = (base^by)%modul.
(package private) static void rootBeta()
           
(package private) static void rootFunction()
           
(package private) static void setModulus(Poly4Max 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)  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

public static final int maxLen
Maximal length of the polynomials

modulus

private static Poly4Max modulus
Modulus for the mod version of the operations

value

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

Poly4Max

Poly4Max()
sets all the coefficients to zero

Poly4Max

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

Poly4Max

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

Poly4Max

Poly4Max(Poly4Max 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.

Poly4Max

Poly4Max(int[] inArray)
array2poly(int[])
Method Detail

setModulus

static void setModulus(Poly4Max 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.

coeff

int coeff(int which)
Returns te coefficient for a given degree which (i.e. coeff*x^which) within the given polynomial.

isLess

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

isBigger

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

isEqual

boolean isEqual(Poly4Max 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

int2poly

void int2poly(int intValue)
Sets the coefficients according to intValue. The bits 0/1 are the coefficient for x^0, bits 2/3 are the coefficient for x^1, ...

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.

mulFactor

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

add

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

add

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

mul

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

pow

void pow(Poly4Max 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(Poly4Max a,
         Poly4Max b)
Calculates this = a % b

mod

void mod(Poly4Max b)
Calculates this %= b

addMod

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

addMod

void addMod(Poly4Max b)
Computes this = (this+b)%modul. Assumes thisnot check this condition.

mulMod

void mulMod(Poly4Max a,
            Poly4Max b)
Computes this = (a*b)%modul. Assumes anot check this condition.

powMod

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

writeString

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

polyInt

int polyInt()
Returns the polynomial as an integer. Bits 0/1 are the coefficient for x^0, Bits 2/3 are the coefficients for x^1, ...

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.

findIrr

static void findIrr()
Find all irreducible polynomials.

main

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