edu.jas.poly
Class ExpVector

java.lang.Object
  extended by edu.jas.poly.ExpVector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class ExpVector
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

ExpVector implements exponent vectors for polynomials. Exponent vectors are implemented as arrays of longs with the familiar MAS static method names. The implementation is only tested for nonnegative exponents but should work also for negative exponents. Objects of this class are intended to be immutable, but exponents can be set (during construction). Will be made generic in the future, e.g. ExpVector<long>.

Author:
Heinz Kredel
See Also:
Serialized Form

Constructor Summary
  ExpVector(int n)
          Constructor for ExpVector.
  ExpVector(int n, int i, long e)
          Constructor for ExpVector.
protected ExpVector(long[] v)
          Constructor for ExpVector.
  ExpVector(java.lang.String s)
          Constructor for ExpVector.
 
Method Summary
 java.lang.Object clone()
          Clone this.
 ExpVector combine(ExpVector V)
          Combine with ExpVector.
 ExpVector contract(int i, int len)
          Contract variables.
 int[] dependencyOnVariables()
          ExpVector dependency on variables.
 ExpVector dif(ExpVector V)
          ExpVector difference.
 boolean equals(java.lang.Object B)
          Comparison with any other object.
static ExpVector EVDIF(ExpVector U, ExpVector V)
          ExpVector difference.
static int[] EVDOV(ExpVector U)
          ExpVector dependency on variables.
static ExpVector EVGCD(ExpVector U, ExpVector V)
          ExpVector greatest common divisor.
static int EVIGLC(ExpVector U, ExpVector V)
          Inverse graded lexicographical compare.
static int EVIGLC(ExpVector U, ExpVector V, int begin, int end)
          Inverse graded lexicographical compare part.
static int EVILCP(ExpVector U, ExpVector V)
          Inverse lexicographical compare.
static int EVILCP(ExpVector U, ExpVector V, int begin, int end)
          Inverse lexicographical compare part.
static int EVIWLC(long[][] w, ExpVector U, ExpVector V)
          Inverse weighted lexicographical compare.
static int EVIWLC(long[][] w, ExpVector U, ExpVector V, int begin, int end)
          Inverse weighted lexicographical compare part.
static ExpVector EVLCM(ExpVector U, ExpVector V)
          ExpVector least common multiple.
static long EVMDEG(ExpVector U)
          ExpVector maximal degree.
static boolean EVMT(ExpVector U, ExpVector V)
          ExpVector multiple test.
static ExpVector EVRAND(int r, long k, float q)
          Generate a random ExpVector.
static ExpVector EVRAND(int r, long k, float q, java.util.Random rnd)
          Generate a random ExpVector.
static int EVRIGLC(ExpVector U, ExpVector V)
          Reverse inverse graded lexicographical compare.
static int EVRIGLC(ExpVector U, ExpVector V, int begin, int end)
          Reverse inverse graded lexicographical compare part.
static int EVRILCP(ExpVector U, ExpVector V)
          Reverse inverse lexicographical compare.
static int EVRILCP(ExpVector U, ExpVector V, int begin, int end)
          Reverse inverse lexicographical compare part.
static int EVSIGN(ExpVector U)
          ExpVector sign.
static ExpVector EVSU(ExpVector U, int i, long d)
          ExpVector substitution.
static ExpVector EVSUM(ExpVector U, ExpVector V)
          ExpVector summation.
static long EVTDEG(ExpVector U)
          ExpVector total degree.
static long EVWDEG(long[][] w, ExpVector U)
          ExpVector weighted degree.
 ExpVector extend(int i, int j, long e)
          Extend variables.
 long getVal(int i)
          Get the exponent at position i.
 int hashCode()
          hashCode.
 boolean isZERO()
          Is ExpVector zero.
 int length()
          Get the length of this exponent vector.
static ExpVector random(int r, long k, float q)
          Generate a random ExpVector.
static ExpVector random(int r, long k, float q, java.util.Random rnd)
          Generate a random ExpVector.
 ExpVector reverse()
          Reverse variables.
 ExpVector reverse(int j)
          Reverse j variables.
protected  long setVal(int i, long e)
          Set the exponent at position i to e.
 java.lang.String[] stdVars()
          Standard variable names.
static java.lang.String[] STDVARS(int n)
          Standard variable names.
 java.lang.String[] stdVars(java.lang.String prefix)
          Generate variable names.
static java.lang.String[] STDVARS(java.lang.String prefix, int n)
          Generate variable names.
 ExpVector subst(int i, long d)
          ExpVector substitution.
 ExpVector sum(ExpVector V)
          ExpVector summation.
 java.lang.String toString()
          Get the string representation.
 java.lang.String toString(java.lang.String[] vars)
          Get the string representation with variable names.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpVector

public ExpVector(int n)
Constructor for ExpVector.

Parameters:
n - length of exponent vector.

ExpVector

public ExpVector(int n,
                 int i,
                 long e)
Constructor for ExpVector. Sets exponent i to e.

Parameters:
n - length of exponent vector.
i - index of exponent to be set.
e - exponent to be set.

ExpVector

protected ExpVector(long[] v)
Constructor for ExpVector. Sets val.

Parameters:
v - other exponent vector.

ExpVector

public ExpVector(java.lang.String s)
          throws java.lang.NumberFormatException
Constructor for ExpVector. Converts a String representation to an ExpVector. Accepted format = (1,2,3,4,5,6,7).

Throws:
java.lang.NumberFormatException
Parameters:
s - String representation.
Method Detail

clone

public java.lang.Object clone()
Clone this.

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

getVal

public long getVal(int i)
Get the exponent at position i.

Parameters:
i - position.
Returns:
val[i].

setVal

protected long setVal(int i,
                      long e)
Set the exponent at position i to e.

Parameters:
i -
e -
Returns:
old val[i].

length

public int length()
Get the length of this exponent vector.

Returns:
val.length.

extend

public ExpVector extend(int i,
                        int j,
                        long e)
Extend variables. Used e.g. in module embedding. Extend this by i elements and set val[j] to e.

Parameters:
i - number of elements to extend.
j - index of element to be set.
e - new exponent for val[j].
Returns:
extended exponent vector.

contract

public ExpVector contract(int i,
                          int len)
Contract variables. Used e.g. in module embedding. Contract this to len elements.

Parameters:
i - position of first element to be copied.
len - new length.
Returns:
contracted exponent vector.

reverse

public ExpVector reverse()
Reverse variables. Used e.g. in opposite rings.

Returns:
reversed exponent vector.

reverse

public ExpVector reverse(int j)
Reverse j variables. Used e.g. in opposite rings. Reverses the first j-1 variables, the rest is unchanged.

Parameters:
j - index of first variable not reversed.
Returns:
reversed exponent vector.

combine

public ExpVector combine(ExpVector V)
Combine with ExpVector. Combine this with the other ExpVector V.

Parameters:
V - the other exponent vector.
Returns:
combined exponent vector.

toString

public java.lang.String toString()
Get the string representation.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

toString

public java.lang.String toString(java.lang.String[] vars)
Get the string representation with variable names.

See Also:
Object.toString()
Parameters:
vars - names of variables.

equals

public boolean equals(java.lang.Object B)
Comparison with any other object.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
hashCode. Optimized for small exponents, i.e. ≤ 24 and small number of variables, i.e. ≤ 8.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isZERO

public boolean isZERO()
Is ExpVector zero.

Returns:
If this has all elements 0 then true is returned, else false.

stdVars

public java.lang.String[] stdVars()
Standard variable names. Generate standard names for variables, i.e. x0 to x(n-1).

Returns:
standard names.

stdVars

public java.lang.String[] stdVars(java.lang.String prefix)
Generate variable names. Generate names for variables, i.e. prefix0 to prefix(n-1).

Parameters:
prefix - name prefix.
Returns:
standard names.

STDVARS

public static java.lang.String[] STDVARS(int n)
Standard variable names. Generate standard names for variables, i.e. x0 to x(n-1).

Parameters:
n - size of names array
Returns:
standard names.

STDVARS

public static java.lang.String[] STDVARS(java.lang.String prefix,
                                         int n)
Generate variable names. Generate names for variables from given prefix. i.e. prefix0 to prefix(n-1).

Parameters:
n - size of names array.
prefix - name prefix.
Returns:
vatiable names.

EVSUM

public static ExpVector EVSUM(ExpVector U,
                              ExpVector V)
ExpVector summation.

Parameters:
U -
V -
Returns:
U+V.

sum

public ExpVector sum(ExpVector V)
ExpVector summation.

Parameters:
V -
Returns:
this+V.

EVDIF

public static ExpVector EVDIF(ExpVector U,
                              ExpVector V)
ExpVector difference. Result may have negative entries.

Parameters:
U -
V -
Returns:
U-V.

dif

public ExpVector dif(ExpVector V)
ExpVector difference. Result may have negative entries.

Parameters:
V -
Returns:
this-V.

EVSU

public static ExpVector EVSU(ExpVector U,
                             int i,
                             long d)
ExpVector substitution. Clone and set exponent to d at position i.

Parameters:
U -
i - position.
d - new exponent.
Returns:
substituted ExpVector.

subst

public ExpVector subst(int i,
                       long d)
ExpVector substitution. Clone and set exponent to d at position i.

Parameters:
i - position.
d - new exponent.
Returns:
substituted ExpVector.

EVRAND

public static ExpVector EVRAND(int r,
                               long k,
                               float q)
Generate a random ExpVector.

Parameters:
r - length of new ExpVector.
k - maximal degree in each exponent.
q - density of nozero exponents.
Returns:
random ExpVector.

EVRAND

public static ExpVector EVRAND(int r,
                               long k,
                               float q,
                               java.util.Random rnd)
Generate a random ExpVector.

Parameters:
r - length of new ExpVector.
k - maximal degree in each exponent.
q - density of nozero exponents.
rnd - is a source for random bits.
Returns:
random ExpVector.

random

public static ExpVector random(int r,
                               long k,
                               float q)
Generate a random ExpVector.

Parameters:
r - length of new ExpVector.
k - maximal degree in each exponent.
q - density of nozero exponents.
Returns:
random ExpVector.

random

public static ExpVector random(int r,
                               long k,
                               float q,
                               java.util.Random rnd)
Generate a random ExpVector.

Parameters:
r - length of new ExpVector.
k - maximal degree in each exponent.
q - density of nozero exponents.
rnd - is a source for random bits.
Returns:
random ExpVector.

EVSIGN

public static int EVSIGN(ExpVector U)
ExpVector sign.

Parameters:
U -
Returns:
0 if U is zero, -1 if some entry is negative, 1 if no entry is negativ and at least one entry is positive.

EVTDEG

public static long EVTDEG(ExpVector U)
ExpVector total degree.

Parameters:
U -
Returns:
sum of all exponents.

EVMDEG

public static long EVMDEG(ExpVector U)
ExpVector maximal degree.

Parameters:
U -
Returns:
maximal exponent.

EVWDEG

public static long EVWDEG(long[][] w,
                          ExpVector U)
ExpVector weighted degree.

Parameters:
w - weights.
U -
Returns:
weighted sum of all exponents.

EVLCM

public static ExpVector EVLCM(ExpVector U,
                              ExpVector V)
ExpVector least common multiple.

Parameters:
U -
V -
Returns:
component wise maximum of U and V.

EVGCD

public static ExpVector EVGCD(ExpVector U,
                              ExpVector V)
ExpVector greatest common divisor.

Parameters:
U -
V -
Returns:
component wise minimum of U and V.

EVDOV

public static int[] EVDOV(ExpVector U)
ExpVector dependency on variables.

Parameters:
U -
Returns:
array of indices where U has positive exponents.

dependencyOnVariables

public int[] dependencyOnVariables()
ExpVector dependency on variables.

Returns:
array of indices where val has positive exponents.

EVMT

public static boolean EVMT(ExpVector U,
                           ExpVector V)
ExpVector multiple test. Test if U is component wise greater or equal to V.

Parameters:
U -
V -
Returns:
true if U is a multiple of V, else false.

EVILCP

public static int EVILCP(ExpVector U,
                         ExpVector V)
Inverse lexicographical compare.

Parameters:
U -
V -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVILCP

public static int EVILCP(ExpVector U,
                         ExpVector V,
                         int begin,
                         int end)
Inverse lexicographical compare part. Compare entries between begin and end (-1).

Parameters:
U -
V -
begin -
end -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVIGLC

public static int EVIGLC(ExpVector U,
                         ExpVector V)
Inverse graded lexicographical compare.

Parameters:
U -
V -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVIGLC

public static int EVIGLC(ExpVector U,
                         ExpVector V,
                         int begin,
                         int end)
Inverse graded lexicographical compare part. Compare entries between begin and end (-1).

Parameters:
U -
V -
begin -
end -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVRILCP

public static int EVRILCP(ExpVector U,
                          ExpVector V)
Reverse inverse lexicographical compare.

Parameters:
U -
V -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVRILCP

public static int EVRILCP(ExpVector U,
                          ExpVector V,
                          int begin,
                          int end)
Reverse inverse lexicographical compare part. Compare entries between begin and end (-1).

Parameters:
U -
V -
begin -
end -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVRIGLC

public static int EVRIGLC(ExpVector U,
                          ExpVector V)
Reverse inverse graded lexicographical compare.

Parameters:
U -
V -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVRIGLC

public static int EVRIGLC(ExpVector U,
                          ExpVector V,
                          int begin,
                          int end)
Reverse inverse graded lexicographical compare part. Compare entries between begin and end (-1).

Parameters:
U -
V -
begin -
end -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVIWLC

public static int EVIWLC(long[][] w,
                         ExpVector U,
                         ExpVector V)
Inverse weighted lexicographical compare.

Parameters:
w - weight array.
U -
V -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.

EVIWLC

public static int EVIWLC(long[][] w,
                         ExpVector U,
                         ExpVector V,
                         int begin,
                         int end)
Inverse weighted lexicographical compare part. Compare entries between begin and end (-1).

Parameters:
w - weight array.
U -
V -
begin -
end -
Returns:
0 if U == V, -1 if U < V, 1 if U > V.