HFE
Class Poly2Max

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

final class Poly2Max
extends java.lang.Object

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

Version:
0.15

Field Summary
static int maxLen
          Maximal length of the polynomials
private static Poly2Max modulus
          Modulus for the mod version of the operations
private  int[] value
          Current value of the polynomial.
 
Constructor Summary
(package private) Poly2Max()
          sets all the coefficients to zero
(package private) Poly2Max(int initValue)
          Creates a new polynomial.
(package private) Poly2Max(int[] inArray)
          array2poly(int[])
(package private) Poly2Max(Poly2Max father)
          Creates a copy from the given polynomial
(package private) Poly2Max(Poly2Max father, int shift)
          Takes one polynomial and shifts it by the given shift.
 
Method Summary
(package private)  void add(Poly2Max whom)
          calculate this += whom as polynomial addition
(package private)  void add(Poly2Max a, Poly2Max b)
          calculates this = wen1 + wen2 as polynomial addition
(package private)  void addMod(Poly2Max b)
          Computes this = (this+b)%modul.
(package private)  void addMod(Poly2Max a, Poly2Max b)
          Computes this = (a+b)%modul.
(package private)  void array2poly(int[] inArray)
          Sets the coefficients using the given 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)  void int2poly(int intValue)
          Sets the coefficients according to intValue.
(package private)  boolean isEqual(Poly2Max 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(Poly2Max b)
          Calculates this %= b
(package private)  void mod(Poly2Max a, Poly2Max b)
          Calculates this = a % b
(package private)  void mul(Poly2Max a, Poly2Max b)
          calculates this = a * b as polynomial addition.
(package private)  void mulFactor(int factor)
          multiplies all coefficients by the given factor in F_2.
(package private)  void mulMod(Poly2Max a, Poly2Max b)
          Computes this = (a*b)%modul.
(package private)  int polyInt()
          Returns the polynomial as an integer.
(package private)  void pow(Poly2Max base, int by)
          calculates this = base^by.
(package private) static void setModulus(Poly2Max 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 Poly2Max 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_2. The element value[i] is the coefficient for x^i so value[0] is the constant term for this polynomial.
Constructor Detail

Poly2Max

Poly2Max()
sets all the coefficients to zero

Poly2Max

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

Poly2Max

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

Poly2Max

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

Poly2Max

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

setModulus

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

isEqual

boolean isEqual(Poly2Max 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 power array. The elements in this array have the form {p_0, p_1, ...} where x^(p_i). The coefficient is assumed to be 1. For all elements _not_ in this array, the coefficient is assumed to be 0.

mulFactor

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

add

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

add

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

mul

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

pow

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

mod

void mod(Poly2Max b)
Calculates this %= b

addMod

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

addMod

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

mulMod

void mulMod(Poly2Max a,
            Poly2Max b)
Computes this = (a*b)%modul. Assumes anot 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 == 30

main

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