HFE
Class SquarePolyVec

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

final class SquarePolyVec
extends java.lang.Object

This class provides a vector of polynomials of degree one in n independent variables. The polynomials are over the finite field GF(2) each. As all these polynomials are processed in parallel, the coefficients are represented in terms of Field2_n each.

Version:
0.15

Field Summary
private  Field2_n[] coeff
          Coefficients for the variables.
static int coeffNum
          The number of coefficients in this polynomial
static int elemNum
          The number of rows in this vector.
private static Field2_n mulTmp1
          Static register for multiplication of two vectors
private static Field2_n mulTmp2
           
static int varNum
          The number of variables in this polynomial.
 
Constructor Summary
SquarePolyVec()
          Initializes all coefficients to zero.
SquarePolyVec(AffinePolyVec father)
          Creates a copy from the given affine polynomial.
SquarePolyVec(AffinePolyVec fac1, AffinePolyVec fac2)
          Creates a new object as the product of two given affine polynomials
SquarePolyVec(SquarePolyVec father)
          Creates a copy from the given polynomial.
 
Method Summary
 void add(AffinePolyVec whom)
          calculate this += whom as polynomial addition
 void add(SquarePolyVec whom)
          calculate this += whom as polynomial addition
 void add(SquarePolyVec a, SquarePolyVec b)
          calculates this = a + b as polynomial addition
 void apply(Field2_n res, Field2_n value)
          Evaluate the polynomial using the given value vector The entry value[0] is _not_ uses, value[1] is the first valid entry.
 void apply(Field2_n res, int[] values)
          Evaluate the polynomial using the given value vector The entry value[0] is _not_ uses, value[1] is the first valid entry.
 Field2_n coeff(int which)
          Returns the coefficients for a given variable.
 Field2_n[] coeffs()
          returns the coefficient array without copying it.
 void copy(SquarePolyVec father)
          Copies the coefficients from another polynomial vector
 void initMem()
          Allocates new memory for the coefficients.
 boolean isEqual(SquarePolyVec whom)
          Compares this and whom coefficientwise.
static void main(java.lang.String[] args)
          Mainly invoces the testIt() method.
 void mul(AffinePolyVec fac1, AffinePolyVec fac2)
          res = fac1*fac2 in terms of affine polynomial vector multiplication
 void mul(Field2_n fac)
          this *= fac in terms of quadratic polynomial vector multiplication
 void mulSlow(AffinePolyVec fac1, AffinePolyVec fac2)
          res = fac1*fac2 in terms of affine polynomial vector multiplication.
 void rnd(java.util.Random rnd)
          Initializes all coefficients with random bits
 void setCoeffs(Field2_n[] inArray)
          Sets all the coefficients by the given array.
 void setZero()
          Sets all the coefficients to zero
static void speedIt()
          Tests how fast the package runs on the current hardware.
 void sub(SquarePolyVec whom)
          calculate this -= whom as polynomial subtraction
 void sub(SquarePolyVec a, SquarePolyVec b)
          calculates this = a - b as polynomial subtraction
static void testIt()
          Tests the functionality for the whole class.
 void transform2poly(Transform2 inTransform)
          Transforms an affine transformation into an affine polynomial vector.
 void writeString()
          Writes the polynomials 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

varNum

public static int varNum
The number of variables in this polynomial.

coeffNum

public static int coeffNum
The number of coefficients in this polynomial

elemNum

public static int elemNum
The number of rows in this vector.

coeff

private Field2_n[] coeff
Coefficients for the variables. The variables are x_1..x_n where n is coeffNum. Position 0 is for the constant terms.

mulTmp1

private static Field2_n mulTmp1
Static register for multiplication of two vectors

mulTmp2

private static Field2_n mulTmp2
Constructor Detail

SquarePolyVec

public SquarePolyVec()
Initializes all coefficients to zero. The resulting polynomial vector is _not_ affine!

SquarePolyVec

public SquarePolyVec(SquarePolyVec father)
Creates a copy from the given polynomial. Uses memory copy for the coefficients.

SquarePolyVec

public SquarePolyVec(AffinePolyVec father)
Creates a copy from the given affine polynomial. Uses memory copy for the coefficients.

SquarePolyVec

public SquarePolyVec(AffinePolyVec fac1,
                     AffinePolyVec fac2)
Creates a new object as the product of two given affine polynomials
Method Detail

coeff

public Field2_n coeff(int which)
Returns the coefficients for a given variable. Valid values: 0: constant term, 1..valNum: variable, varNum+1: var_1*var_2, ...

coeffs

public Field2_n[] coeffs()
returns the coefficient array without copying it.

isEqual

public boolean isEqual(SquarePolyVec whom)
Compares this and whom coefficientwise. If the two polynomials have different number of variables they can not be equal.
Returns:
true iff all the coefficients are the same both objects

setZero

public void setZero()
Sets all the coefficients to zero

initMem

public void initMem()
Allocates new memory for the coefficients. The coefficients are initalized with zero.

rnd

public void rnd(java.util.Random rnd)
Initializes all coefficients with random bits

copy

public void copy(SquarePolyVec father)
Copies the coefficients from another polynomial vector

setCoeffs

public void setCoeffs(Field2_n[] inArray)
Sets all the coefficients by the given array. Does neither memory copy nor argument checking.

transform2poly

public void transform2poly(Transform2 inTransform)
Transforms an affine transformation into an affine polynomial vector.
Parameters:
inTransform - affine tranformation

add

public void add(SquarePolyVec a,
                SquarePolyVec b)
calculates this = a + b as polynomial addition

add

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

add

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

sub

public void sub(SquarePolyVec a,
                SquarePolyVec b)
calculates this = a - b as polynomial subtraction

sub

public void sub(SquarePolyVec whom)
calculate this -= whom as polynomial subtraction

apply

public void apply(Field2_n res,
                  int[] values)
Evaluate the polynomial using the given value vector The entry value[0] is _not_ uses, value[1] is the first valid entry.
Parameters:
res - value of the current polynimial vector.
values - array with varNum+1 entries

apply

public void apply(Field2_n res,
                  Field2_n value)
Evaluate the polynomial using the given value vector The entry value[0] is _not_ uses, value[1] is the first valid entry.
Parameters:
res - value of the current polynimial vector.
value - array with varNum entries as Field2_n element

mul

public void mul(Field2_n fac)
this *= fac in terms of quadratic polynomial vector multiplication

mul

public void mul(AffinePolyVec fac1,
                AffinePolyVec fac2)
res = fac1*fac2 in terms of affine polynomial vector multiplication

mulSlow

public void mulSlow(AffinePolyVec fac1,
                    AffinePolyVec fac2)
res = fac1*fac2 in terms of affine polynomial vector multiplication. Uses direct multiplication and is hence rather slow.

writeString

public void writeString()
Writes the polynomials as a string to stdout

testIt

public static void testIt()
Tests the functionality for the whole class. Reports errors to stdout.

speedIt

public static final void speedIt()
Tests how fast the package runs on the current hardware.

main

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