edu.jas.ps
Class MultiVarPowerSeries<C extends RingElem<C>>

java.lang.Object
  extended by edu.jas.ps.MultiVarPowerSeries<C>
Type Parameters:
C - ring element type
All Implemented Interfaces:
AbelianGroupElem<MultiVarPowerSeries<C>>, Element<MultiVarPowerSeries<C>>, MonoidElem<MultiVarPowerSeries<C>>, RingElem<MultiVarPowerSeries<C>>, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<MultiVarPowerSeries<C>>

public class MultiVarPowerSeries<C extends RingElem<C>>
extends java.lang.Object
implements RingElem<MultiVarPowerSeries<C>>

Multivariate power series implementation. Uses inner classes and lazy evaluated generating function for coefficients. All ring element methods use lazy evaluation except where noted otherwise. Eager evaluated methods are toString(), compareTo(), equals(), evaluate(), or methods which use the order() or orderExpVector() methods, like signum(), abs(), divide(), remainder() and gcd(). Note: Currently the term order is fixed to the order defined by the iterator over exponent vectors in class ExpVectorIterator.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
 MultiVarPowerSeriesRing<C> ring
          Power series ring factory.
 
Constructor Summary
MultiVarPowerSeries(MultiVarPowerSeriesRing<C> ring, MultiVarCoefficients<C> lazyCoeffs)
          Constructor.
MultiVarPowerSeries(MultiVarPowerSeriesRing<C> ring, MultiVarCoefficients<C> lazyCoeffs, int trunc)
          Constructor.
 
Method Summary
 MultiVarPowerSeries<C> abs()
          Absolute value.
 GenPolynomial<C> asPolynomial()
          Get a GenPolynomial<C> from this.
 MultiVarPowerSeries<C> clone()
          Clone this power series.
 C coefficient(ExpVector index)
          Get coefficient.
 int compareTo(MultiVarPowerSeries<C> ps)
          Compare to.
 MultiVarPowerSeries<C> differentiate(int r)
          Differentiate with respect to variable r.
 MultiVarPowerSeries<C> divide(MultiVarPowerSeries<C> ps)
          Divide by another power series.
 long ecart()
          Ecart.
 MultiVarPowerSeries<C>[] egcd(MultiVarPowerSeries<C> S)
          Power series extended greatest common divisor.
 boolean equals(java.lang.Object B)
          Comparison with any other object.
 C evaluate(java.util.List<C> a)
          Evaluate at given point.
 MultiVarPowerSeriesRing<C> factory()
          Get the corresponding element factory.
 MultiVarPowerSeries<C> gcd(MultiVarPowerSeries<C> ps)
          Power series greatest common divisor.
 int hashCode()
          Hash code for this polynomial.
 GenPolynomial<C> homogeneousPart(long tdeg)
          Homogeneous part.
 MultiVarPowerSeries<C> integrate(C c, int r)
          Integrate with respect to variable r and with given constant.
 MultiVarPowerSeries<C> inverse()
          Inverse power series.
 boolean isONE()
          Is power series one.
 boolean isUnit()
          Is unit.
 boolean isZERO()
          Is power series zero.
 C leadingCoefficient()
          Leading base coefficient.
 MultiVarPowerSeries<C> map(UnaryFunctor<? super C,C> f)
          Map a unary function to this power series.
 MultiVarPowerSeries<C> monic()
          Monic.
 MultiVarPowerSeries<C> multiply(C a)
          Multiply by coefficient.
 MultiVarPowerSeries<C> multiply(C c, ExpVector k)
          Multiply by exponent vector and coefficient.
 MultiVarPowerSeries<C> multiply(MultiVarPowerSeries<C> ps)
          Multiply by another power series.
 MultiVarPowerSeries<C> negate()
          Negate.
 int order()
          Order.
 ExpVector orderExpVector()
          Order ExpVector.
 java.util.Map.Entry<ExpVector,C> orderMonomial()
          Order monomial.
 MultiVarPowerSeries<C> prepend(C h, int r)
          Prepend a new leading coefficient.
 MultiVarPowerSeries<C> reductum()
          Reductum.
 MultiVarPowerSeries<C> reductum(int r)
          Reductum.
 MultiVarPowerSeries<C> remainder(MultiVarPowerSeries<C> ps)
          Power series remainder.
 MultiVarPowerSeries<C> select(Selector<? super C> sel)
          Select coefficients.
 int setTruncate(int t)
          Set truncate.
 MultiVarPowerSeries<C> shift(ExpVector k)
          Shift coefficients.
 MultiVarPowerSeries<C> shift(int k, int r)
          Shift coefficients.
 MultiVarPowerSeries<C> shiftSelect(Selector<? super C> sel)
          Shift select coefficients.
 int signum()
          Signum.
 MultiVarPowerSeries<C> subtract(C c, ExpVector k)
          Subtract exponent vector and coefficient.
 MultiVarPowerSeries<C> subtract(MultiVarPowerSeries<C> ps)
          Subtract a another power series.
 MultiVarPowerSeries<C> subtractZip(MultiVarPowerSeries<C> ps)
          Subtraction of two power series, using zip().
 MultiVarPowerSeries<C> sum(C c, ExpVector k)
          Sum exponent vector and coefficient.
 MultiVarPowerSeries<C> sum(java.util.Map.Entry<ExpVector,C> m)
          Sum monomial.
 MultiVarPowerSeries<C> sum(MultiVarCoefficients<C> mvc)
          Sum exponent vector and coefficient.
 MultiVarPowerSeries<C> sum(MultiVarPowerSeries<C> ps)
          Sum a another power series.
 MultiVarPowerSeries<C> sumZip(MultiVarPowerSeries<C> ps)
          Sum of two power series, using zip().
 java.lang.String toScript()
          Get a scripting compatible string representation.
 java.lang.String toScriptFactory()
          Get a scripting compatible string representation of the factory.
 java.lang.String toString()
          String representation of power series.
 java.lang.String toString(int trunc)
          To String with given truncate.
 int truncate()
          Truncate.
 MultiVarPowerSeries<C> zip(BinaryFunctor<? super C,? super C,C> f, MultiVarPowerSeries<C> ps)
          Map a binary function to this and another power series.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ring

public final MultiVarPowerSeriesRing<C extends RingElem<C>> ring
Power series ring factory.

Constructor Detail

MultiVarPowerSeries

public MultiVarPowerSeries(MultiVarPowerSeriesRing<C> ring,
                           MultiVarCoefficients<C> lazyCoeffs)
Constructor.

Parameters:
ring - power series ring.
lazyCoeffs - generating function for coefficients.

MultiVarPowerSeries

public MultiVarPowerSeries(MultiVarPowerSeriesRing<C> ring,
                           MultiVarCoefficients<C> lazyCoeffs,
                           int trunc)
Constructor.

Parameters:
ring - power series ring.
lazyCoeffs - generating function for coefficients.
trunc - truncate parameter for this power series.
Method Detail

factory

public MultiVarPowerSeriesRing<C> factory()
Get the corresponding element factory.

Specified by:
factory in interface Element<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
factory for this Element.
See Also:
Element.factory()

clone

public MultiVarPowerSeries<C> clone()
Clone this power series.

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

toString

public java.lang.String toString()
String representation of power series.

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

toString

public java.lang.String toString(int trunc)
To String with given truncate.

Parameters:
trunc - truncate parameter for this power series.
Returns:
string representation of this to given truncate.

toScript

public java.lang.String toScript()
Get a scripting compatible string representation.

Specified by:
toScript in interface Element<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
script compatible representation for this Element.
See Also:
Element.toScript()

toScriptFactory

public java.lang.String toScriptFactory()
Get a scripting compatible string representation of the factory.

Specified by:
toScriptFactory in interface Element<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
script compatible representation for this ElemFactory.
See Also:
Element.toScriptFactory()

coefficient

public C coefficient(ExpVector index)
Get coefficient.

Parameters:
index - number of requested coefficient.
Returns:
coefficient at index.

homogeneousPart

public GenPolynomial<C> homogeneousPart(long tdeg)
Homogeneous part.

Parameters:
tdeg - requested degree.
Returns:
polynomial part of given degree.

asPolynomial

public GenPolynomial<C> asPolynomial()
Get a GenPolynomial<C> from this.

Returns:
a GenPolynomial<C> from this up to truncate homogeneous parts.

leadingCoefficient

public C leadingCoefficient()
Leading base coefficient.

Returns:
first coefficient.

reductum

public MultiVarPowerSeries<C> reductum(int r)
Reductum.

Parameters:
r - variable for taking the reductum.
Returns:
this - leading monomial in the direction of r.

prepend

public MultiVarPowerSeries<C> prepend(C h,
                                      int r)
Prepend a new leading coefficient.

Parameters:
r - variable for the direction.
h - new coefficient.
Returns:
new power series.

shift

public MultiVarPowerSeries<C> shift(int k,
                                    int r)
Shift coefficients.

Parameters:
k - shift index.
r - variable for the direction.
Returns:
new power series with coefficient(i) = old.coefficient(i-k).

reductum

public MultiVarPowerSeries<C> reductum()
Reductum.

Returns:
this - leading monomial.

shift

public MultiVarPowerSeries<C> shift(ExpVector k)
Shift coefficients. Multiply by exponent vector.

Parameters:
k - shift ExpVector.
Returns:
new power series with coefficient(i) = old.coefficient(i-k).

multiply

public MultiVarPowerSeries<C> multiply(C c,
                                       ExpVector k)
Multiply by exponent vector and coefficient.

Parameters:
k - shift ExpVector.
c - coefficient multiplier.
Returns:
new power series with coefficient(i) = old.coefficient(i-k)*c.

sum

public MultiVarPowerSeries<C> sum(java.util.Map.Entry<ExpVector,C> m)
Sum monomial.

Parameters:
m - ExpVector , coeffcient pair
Returns:
this + ONE.multiply(m.coefficient,m.exponent).

sum

public MultiVarPowerSeries<C> sum(C c,
                                  ExpVector k)
Sum exponent vector and coefficient.

Parameters:
k - ExpVector.
c - coefficient.
Returns:
this + ONE.multiply(c,k).

subtract

public MultiVarPowerSeries<C> subtract(C c,
                                       ExpVector k)
Subtract exponent vector and coefficient.

Parameters:
k - ExpVector.
c - coefficient.
Returns:
this - ONE.multiply(c,k).

sum

public MultiVarPowerSeries<C> sum(MultiVarCoefficients<C> mvc)
Sum exponent vector and coefficient.

Parameters:
mvc - cached coefficients.
Returns:
this + mvc.

select

public MultiVarPowerSeries<C> select(Selector<? super C> sel)
Select coefficients.

Parameters:
sel - selector functor.
Returns:
new power series with selected coefficients.

shiftSelect

public MultiVarPowerSeries<C> shiftSelect(Selector<? super C> sel)
Shift select coefficients. Not selected coefficients are removed from the result series.

Parameters:
sel - selector functor.
Returns:
new power series with shifted selected coefficients.

map

public MultiVarPowerSeries<C> map(UnaryFunctor<? super C,C> f)
Map a unary function to this power series.

Parameters:
f - evaluation functor.
Returns:
new power series with coefficients f(this(i)).

zip

public MultiVarPowerSeries<C> zip(BinaryFunctor<? super C,? super C,C> f,
                                  MultiVarPowerSeries<C> ps)
Map a binary function to this and another power series.

Parameters:
f - evaluation functor with coefficients f(this(i),other(i)).
ps - other power series.
Returns:
new power series.

sumZip

public MultiVarPowerSeries<C> sumZip(MultiVarPowerSeries<C> ps)
Sum of two power series, using zip().

Parameters:
ps - other power series.
Returns:
this + ps.

subtractZip

public MultiVarPowerSeries<C> subtractZip(MultiVarPowerSeries<C> ps)
Subtraction of two power series, using zip().

Parameters:
ps - other power series.
Returns:
this - ps.

multiply

public MultiVarPowerSeries<C> multiply(C a)
Multiply by coefficient.

Parameters:
a - coefficient.
Returns:
this * a.

monic

public MultiVarPowerSeries<C> monic()
Monic.

Returns:
1/orderCoeff() * this.

negate

public MultiVarPowerSeries<C> negate()
Negate.

Specified by:
negate in interface AbelianGroupElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
- this.

abs

public MultiVarPowerSeries<C> abs()
Absolute value.

Specified by:
abs in interface AbelianGroupElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
abs(this).

evaluate

public C evaluate(java.util.List<C> a)
Evaluate at given point.

Returns:
ps(a).

order

public int order()
Order.

Returns:
index of first non zero coefficient.

orderExpVector

public ExpVector orderExpVector()
Order ExpVector.

Returns:
ExpVector of first non zero coefficient.

orderMonomial

public java.util.Map.Entry<ExpVector,C> orderMonomial()
Order monomial.

Returns:
first map entry or null.

truncate

public int truncate()
Truncate.

Returns:
truncate index of power series.

setTruncate

public int setTruncate(int t)
Set truncate.

Parameters:
t - new truncate index.
Returns:
old truncate index of power series.

ecart

public long ecart()
Ecart.

Returns:
ecart.

signum

public int signum()
Signum.

Specified by:
signum in interface AbelianGroupElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
sign of first non zero coefficient.

compareTo

public int compareTo(MultiVarPowerSeries<C> ps)
Compare to. Note: compare only up to max(truncates).

Specified by:
compareTo in interface Element<MultiVarPowerSeries<C extends RingElem<C>>>
Specified by:
compareTo in interface java.lang.Comparable<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
sign of first non zero coefficient of this-ps.

isZERO

public boolean isZERO()
Is power series zero. Note: compare only up to truncate.

Specified by:
isZERO in interface AbelianGroupElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
If this is 0 then true is returned, else false.
See Also:
AbelianGroupElem.isZERO()

isONE

public boolean isONE()
Is power series one. Note: compare only up to truncate.

Specified by:
isONE in interface MonoidElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
If this is 1 then true is returned, else false.
See Also:
MonoidElem.isONE()

equals

public boolean equals(java.lang.Object B)
Comparison with any other object. Note: compare only up to truncate.

Specified by:
equals in interface Element<MultiVarPowerSeries<C extends RingElem<C>>>
Overrides:
equals in class java.lang.Object
Returns:
true if this is equal to b, else false.
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Hash code for this polynomial. Note: only up to truncate.

Specified by:
hashCode in interface Element<MultiVarPowerSeries<C extends RingElem<C>>>
Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode.
See Also:
Object.hashCode()

isUnit

public boolean isUnit()
Is unit.

Specified by:
isUnit in interface MonoidElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
true, if this power series is invertible, else false.

sum

public MultiVarPowerSeries<C> sum(MultiVarPowerSeries<C> ps)
Sum a another power series.

Specified by:
sum in interface AbelianGroupElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
ps - other power series.
Returns:
this + ps.

subtract

public MultiVarPowerSeries<C> subtract(MultiVarPowerSeries<C> ps)
Subtract a another power series.

Specified by:
subtract in interface AbelianGroupElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
ps - other power series.
Returns:
this - ps.

multiply

public MultiVarPowerSeries<C> multiply(MultiVarPowerSeries<C> ps)
Multiply by another power series.

Specified by:
multiply in interface MonoidElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
ps - other power series.
Returns:
this * ps.

inverse

public MultiVarPowerSeries<C> inverse()
Inverse power series.

Specified by:
inverse in interface MonoidElem<MultiVarPowerSeries<C extends RingElem<C>>>
Returns:
ps with this * ps = 1.

divide

public MultiVarPowerSeries<C> divide(MultiVarPowerSeries<C> ps)
Divide by another power series.

Specified by:
divide in interface MonoidElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
ps - nonzero power series with invertible coefficient.
Returns:
this / ps.

remainder

public MultiVarPowerSeries<C> remainder(MultiVarPowerSeries<C> ps)
Power series remainder.

Specified by:
remainder in interface MonoidElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
ps - nonzero power series with invertible leading coefficient.
Returns:
remainder with this = quotient * ps + remainder.

differentiate

public MultiVarPowerSeries<C> differentiate(int r)
Differentiate with respect to variable r.

Parameters:
r - variable for the direction.
Returns:
differentiate(this).

integrate

public MultiVarPowerSeries<C> integrate(C c,
                                        int r)
Integrate with respect to variable r and with given constant.

Parameters:
c - integration constant.
r - variable for the direction.
Returns:
integrate(this).

gcd

public MultiVarPowerSeries<C> gcd(MultiVarPowerSeries<C> ps)
Power series greatest common divisor.

Specified by:
gcd in interface RingElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
ps - power series.
Returns:
gcd(this,ps).

egcd

public MultiVarPowerSeries<C>[] egcd(MultiVarPowerSeries<C> S)
Power series extended greatest common divisor. Note: not implemented.

Specified by:
egcd in interface RingElem<MultiVarPowerSeries<C extends RingElem<C>>>
Parameters:
S - power series.
Returns:
[ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).