edu.jas.poly
Class GenPolynomialRing<C extends RingElem<C>>

java.lang.Object
  extended by edu.jas.poly.GenPolynomialRing<C>
All Implemented Interfaces:
AbelianGroupFactory<GenPolynomial<C>>, ElemFactory<GenPolynomial<C>>, MonoidFactory<GenPolynomial<C>>, RingFactory<GenPolynomial<C>>, java.io.Serializable
Direct Known Subclasses:
GenSolvablePolynomialRing

public class GenPolynomialRing<C extends RingElem<C>>
extends java.lang.Object
implements RingFactory<GenPolynomial<C>>

GenPolynomialRing generic polynomial factory implementing RingFactory; Factory for n-variate ordered polynomials over C. Almost immutable object, except variable names.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
 RingFactory<C> coFac
          The factory for the coefficients.
 ExpVector evzero
          The constant exponent vector 0 for this ring.
protected  int isField
          Indicator if this ring is a field.
 int nvar
          The number of variables.
 GenPolynomial<C> ONE
          The constant polynomial 1 for this ring.
protected  boolean partial
          True for partially reversed variables.
protected static java.util.Random random
          A default random sequence generator.
 TermOrder tord
          The term order.
protected  java.lang.String[] vars
          The names of the variables.
 GenPolynomial<C> ZERO
          The constant polynomial 0 for this ring.
 
Constructor Summary
GenPolynomialRing(RingFactory<C> cf, int n)
          The constructor creates a polynomial factory object with the default term order.
GenPolynomialRing(RingFactory<C> cf, int n, java.lang.String[] v)
          The constructor creates a polynomial factory object.
GenPolynomialRing(RingFactory<C> cf, int n, TermOrder t)
          The constructor creates a polynomial factory object.
GenPolynomialRing(RingFactory<C> cf, int n, TermOrder t, java.lang.String[] v)
          The constructor creates a polynomial factory object.
 
Method Summary
 java.math.BigInteger characteristic()
          Characteristic of this ring.
 GenPolynomialRing<C> contract(int i)
          Contract variables.
 GenPolynomial<C> copy(GenPolynomial<C> c)
          Copy polynomial c.
 boolean equals(java.lang.Object other)
          Comparison with any other object.
 GenPolynomialRing<C> extend(int i)
          Extend variables.
 GenPolynomial<C> fromInteger(java.math.BigInteger a)
          Get a (constant) GenPolynomial element from a BigInteger value.
 GenPolynomial<C> fromInteger(long a)
          Get a (constant) GenPolynomial element from a long value.
 GenPolynomial<C> getONE()
          Get the one element.
 C getONECoefficient()
          Get the one element from the coefficients.
 java.lang.String[] getVars()
          Get the variable names.
 GenPolynomial<C> getZERO()
          Get the zero element.
 C getZEROCoefficient()
          Get the zero element from the coefficients.
 int hashCode()
          Hash code for this polynomial ring.
 boolean isAssociative()
          Query if this ring is associative.
 boolean isCommutative()
          Query if this ring is commutative.
 boolean isField()
          Query if this ring is a field.
 GenPolynomial<C> parse(java.io.Reader r)
          Parse a polynomial with the use of GenPolynomialTokenizer.
 GenPolynomial<C> parse(java.lang.String s)
          Parse a polynomial with the use of GenPolynomialTokenizer.
 GenPolynomial<C> random(int n)
          Random polynomial.
 GenPolynomial<C> random(int k, int l, int d, float q)
          Generate a random polynomial.
 GenPolynomial<C> random(int k, int l, int d, float q, java.util.Random rnd)
          Generate a random polynomial.
 GenPolynomial<C> random(int n, java.util.Random rnd)
          Random polynomial.
 GenPolynomialRing<C> reverse()
          Reverse variables.
 GenPolynomialRing<C> reverse(boolean partial)
          Reverse variables.
 java.lang.String[] setVars(java.lang.String[] v)
          Set the variable names.
 java.lang.String toString()
          Get the String representation.
 GenPolynomial<C> univariate(int i)
          Generate univariate polynomial in a given variable.
 GenPolynomial<C> univariate(int modv, int i, long e)
          Generate univariate polynomial in a given variable with given exponent.
 GenPolynomial<C> univariate(int i, long e)
          Generate univariate polynomial in a given variable with given exponent.
 java.util.List<? extends GenPolynomial<C>> univariateList()
          Generate list of univariate polynomials in all variables.
 java.util.List<? extends GenPolynomial<C>> univariateList(int modv)
          Generate list of univariate polynomials in all variables.
 java.util.List<? extends GenPolynomial<C>> univariateList(int modv, long e)
          Generate list of univariate polynomials in all variables with given exponent.
 java.lang.String varsToString()
          Get a String representation of the variable names.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

coFac

public final RingFactory<C extends RingElem<C>> coFac
The factory for the coefficients.


nvar

public final int nvar
The number of variables.


tord

public final TermOrder tord
The term order.


partial

protected boolean partial
True for partially reversed variables.


vars

protected java.lang.String[] vars
The names of the variables. This value can be modified.


ZERO

public final GenPolynomial<C extends RingElem<C>> ZERO
The constant polynomial 0 for this ring.


ONE

public final GenPolynomial<C extends RingElem<C>> ONE
The constant polynomial 1 for this ring.


evzero

public final ExpVector evzero
The constant exponent vector 0 for this ring.


random

protected static final java.util.Random random
A default random sequence generator.


isField

protected int isField
Indicator if this ring is a field.

Constructor Detail

GenPolynomialRing

public GenPolynomialRing(RingFactory<C> cf,
                         int n)
The constructor creates a polynomial factory object with the default term order.

Parameters:
cf - factory for coefficients of type C.
n - number of variables.

GenPolynomialRing

public GenPolynomialRing(RingFactory<C> cf,
                         int n,
                         TermOrder t)
The constructor creates a polynomial factory object.

Parameters:
cf - factory for coefficients of type C.
n - number of variables.
t - a term order.

GenPolynomialRing

public GenPolynomialRing(RingFactory<C> cf,
                         int n,
                         java.lang.String[] v)
The constructor creates a polynomial factory object.

Parameters:
cf - factory for coefficients of type C.
n - number of variables.
v - names for the variables.

GenPolynomialRing

public GenPolynomialRing(RingFactory<C> cf,
                         int n,
                         TermOrder t,
                         java.lang.String[] v)
The constructor creates a polynomial factory object.

Parameters:
cf - factory for coefficients of type C.
n - number of variables.
t - a term order.
v - names for the variables.
Method Detail

toString

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

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

equals

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

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

hashCode

public int hashCode()
Hash code for this polynomial ring.

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

getVars

public java.lang.String[] getVars()
Get the variable names.

Returns:
vars.

setVars

public java.lang.String[] setVars(java.lang.String[] v)
Set the variable names.

Returns:
old vars.

varsToString

public java.lang.String varsToString()
Get a String representation of the variable names.

Returns:
names seperated by commas.

getZEROCoefficient

public C getZEROCoefficient()
Get the zero element from the coefficients.

Returns:
0 as C.

getONECoefficient

public C getONECoefficient()
Get the one element from the coefficients.

Returns:
1 as C.

getZERO

public GenPolynomial<C> getZERO()
Get the zero element.

Specified by:
getZERO in interface AbelianGroupFactory<GenPolynomial<C extends RingElem<C>>>
Returns:
0 as GenPolynomial.

getONE

public GenPolynomial<C> getONE()
Get the one element.

Specified by:
getONE in interface MonoidFactory<GenPolynomial<C extends RingElem<C>>>
Returns:
1 as GenPolynomial.

isCommutative

public boolean isCommutative()
Query if this ring is commutative.

Specified by:
isCommutative in interface MonoidFactory<GenPolynomial<C extends RingElem<C>>>
Returns:
true if this ring is commutative, else false.

isAssociative

public boolean isAssociative()
Query if this ring is associative.

Specified by:
isAssociative in interface MonoidFactory<GenPolynomial<C extends RingElem<C>>>
Returns:
true if this ring is associative, else false.

isField

public boolean isField()
Query if this ring is a field.

Specified by:
isField in interface RingFactory<GenPolynomial<C extends RingElem<C>>>
Returns:
false.

characteristic

public java.math.BigInteger characteristic()
Characteristic of this ring.

Specified by:
characteristic in interface RingFactory<GenPolynomial<C extends RingElem<C>>>
Returns:
characteristic of this ring.

fromInteger

public GenPolynomial<C> fromInteger(long a)
Get a (constant) GenPolynomial element from a long value.

Specified by:
fromInteger in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
a - long.
Returns:
a GenPolynomial.

fromInteger

public GenPolynomial<C> fromInteger(java.math.BigInteger a)
Get a (constant) GenPolynomial element from a BigInteger value.

Specified by:
fromInteger in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
a - BigInteger.
Returns:
a GenPolynomial.

random

public GenPolynomial<C> random(int n)
Random polynomial. Generates a random polynomial with k = 5, l = n, d = (nvar == 1) ? n : 3, q = (nvar == 1) ? 0.7 : 0.3.

Specified by:
random in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
n - number of terms.
Returns:
a random polynomial.

random

public GenPolynomial<C> random(int n,
                               java.util.Random rnd)
Random polynomial. Generates a random polynomial with k = 5, l = n, d = (nvar == 1) ? n : 3, q = (nvar == 1) ? 0.7 : 0.3.

Specified by:
random in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
n - number of terms.
rnd - is a source for random bits.
Returns:
a random polynomial.

random

public GenPolynomial<C> random(int k,
                               int l,
                               int d,
                               float q)
Generate a random polynomial.

Parameters:
k - bitsize of random coefficients.
l - number of terms.
d - maximal degree in each variable.
q - density of nozero exponents.
Returns:
a random polynomial.

random

public GenPolynomial<C> random(int k,
                               int l,
                               int d,
                               float q,
                               java.util.Random rnd)
Generate a random polynomial.

Parameters:
k - bitsize of random coefficients.
l - number of terms.
d - maximal degree in each variable.
q - density of nozero exponents.
rnd - is a source for random bits.
Returns:
a random polynomial.

copy

public GenPolynomial<C> copy(GenPolynomial<C> c)
Copy polynomial c.

Specified by:
copy in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
c -
Returns:
a copy of c.

parse

public GenPolynomial<C> parse(java.lang.String s)
Parse a polynomial with the use of GenPolynomialTokenizer.

Specified by:
parse in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
s - String.
Returns:
GenPolynomial from s.

parse

public GenPolynomial<C> parse(java.io.Reader r)
Parse a polynomial with the use of GenPolynomialTokenizer.

Specified by:
parse in interface ElemFactory<GenPolynomial<C extends RingElem<C>>>
Parameters:
r - Reader.
Returns:
next GenPolynomial from r.

univariate

public GenPolynomial<C> univariate(int i)
Generate univariate polynomial in a given variable.

Type parameter:
C coefficient type.
Parameters:
i - the index of the variable.
Returns:
X_i as univariate polynomial.

univariate

public GenPolynomial<C> univariate(int i,
                                   long e)
Generate univariate polynomial in a given variable with given exponent.

Type parameter:
C coefficient type.
Parameters:
i - the index of the variable.
e - the exponent of the variable.
Returns:
X_i^e as univariate polynomial.

univariate

public GenPolynomial<C> univariate(int modv,
                                   int i,
                                   long e)
Generate univariate polynomial in a given variable with given exponent.

Type parameter:
C coefficient type.
Parameters:
modv - number of module variables.
i - the index of the variable.
e - the exponent of the variable.
Returns:
X_i^e as univariate polynomial.

univariateList

public java.util.List<? extends GenPolynomial<C>> univariateList()
Generate list of univariate polynomials in all variables.

Type parameter:
C coefficient type.
Returns:
List(X_1,...,X_n) a list of univariate polynomials.

univariateList

public java.util.List<? extends GenPolynomial<C>> univariateList(int modv)
Generate list of univariate polynomials in all variables.

Type parameter:
C coefficient type.
Parameters:
modv - number of module variables.
Returns:
List(X_1,...,X_n) a list of univariate polynomials.

univariateList

public java.util.List<? extends GenPolynomial<C>> univariateList(int modv,
                                                                 long e)
Generate list of univariate polynomials in all variables with given exponent.

Type parameter:
C coefficient type.
Parameters:
modv - number of module variables.
e - the exponent of the variables.
Returns:
List(X_1^e,...,X_n^e) a list of univariate polynomials.

extend

public GenPolynomialRing<C> extend(int i)
Extend variables. Used e.g. in module embedding. Extend number of variables by i.

Parameters:
i - number of variables to extend.
Returns:
extended polynomial ring factory.

contract

public GenPolynomialRing<C> contract(int i)
Contract variables. Used e.g. in module embedding. Contract number of variables by i.

Parameters:
i - number of variables to remove.
Returns:
contracted polynomial ring factory.

reverse

public GenPolynomialRing<C> reverse()
Reverse variables. Used e.g. in opposite rings.

Returns:
polynomial ring factory with reversed variables.

reverse

public GenPolynomialRing<C> reverse(boolean partial)
Reverse variables. Used e.g. in opposite rings.

Parameters:
partial - true for partialy reversed term orders.
Returns:
polynomial ring factory with reversed variables.