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

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

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

Univariate 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 they use the order() method, like signum(), abs(), divide(), remainder() and gcd().

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
 UnivPowerSeriesRing<C> ring
          Power series ring factory.
 
Constructor Summary
UnivPowerSeries(UnivPowerSeriesRing<C> ring, Coefficients<C> lazyCoeffs)
          Constructor.
 
Method Summary
 UnivPowerSeries<C> abs()
          Absolute value.
 GenPolynomial<C> asPolynomial()
          Get a GenPolynomial<C> from this.
 UnivPowerSeries<C> clone()
          Clone this power series.
 C coefficient(int index)
          Get coefficient.
 int compareTo(UnivPowerSeries<C> ps)
          Compare to.
 UnivPowerSeries<C> differentiate()
          Differentiate.
 UnivPowerSeries<C> divide(UnivPowerSeries<C> ps)
          Divide by another power series.
 UnivPowerSeries<C>[] egcd(UnivPowerSeries<C> S)
          Power series extended greatest common divisor.
 boolean equals(java.lang.Object B)
          Comparison with any other object.
 C evaluate(C e)
          Evaluate at given point.
 UnivPowerSeriesRing<C> factory()
          Get the corresponding element factory.
 UnivPowerSeries<C> gcd(UnivPowerSeries<C> ps)
          Power series greatest common divisor.
 int hashCode()
          Hash code for this polynomial.
 UnivPowerSeries<C> integrate(C c)
          Integrate with given constant.
 UnivPowerSeries<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.
 UnivPowerSeries<C> map(UnaryFunctor<? super C,C> f)
          Map a unary function to this power series.
 UnivPowerSeries<C> multiply(C c)
          Multiply by coefficient.
 UnivPowerSeries<C> multiply(UnivPowerSeries<C> ps)
          Multiply by another power series.
 UnivPowerSeries<C> negate()
          Negate.
 int order()
          Order.
 UnivPowerSeries<C> prepend(C h)
          Prepend a new leading coefficient.
 UnivPowerSeries<C> reductum()
          Reductum.
 UnivPowerSeries<C> remainder(UnivPowerSeries<C> ps)
          Power series remainder.
 UnivPowerSeries<C> select(Selector<? super C> sel)
          Select coefficients.
 int setTruncate(int t)
          Set truncate.
 UnivPowerSeries<C> shift(int k)
          Shift coefficients.
 UnivPowerSeries<C> shiftSelect(Selector<? super C> sel)
          Shift select coefficients.
 int signum()
          Signum.
 UnivPowerSeries<C> subtract(UnivPowerSeries<C> ps)
          Subtraction of two power series.
 UnivPowerSeries<C> sum(UnivPowerSeries<C> ps)
          Sum of two power series.
 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 truncate)
          To String with given truncate.
 int truncate()
          Truncate.
<C2 extends RingElem<C2>>
UnivPowerSeries<C>
zip(BinaryFunctor<? super C,? super C2,C> f, UnivPowerSeries<C2> 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 UnivPowerSeriesRing<C extends RingElem<C>> ring
Power series ring factory.

Constructor Detail

UnivPowerSeries

public UnivPowerSeries(UnivPowerSeriesRing<C> ring,
                       Coefficients<C> lazyCoeffs)
Constructor.

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

factory

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

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

clone

public UnivPowerSeries<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 truncate)
To String with given truncate.

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<UnivPowerSeries<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<UnivPowerSeries<C extends RingElem<C>>>
Returns:
script compatible representation for this ElemFactory.
See Also:
Element.toScriptFactory()

coefficient

public C coefficient(int index)
Get coefficient.

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

asPolynomial

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

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

leadingCoefficient

public C leadingCoefficient()
Leading base coefficient.

Returns:
first coefficient.

reductum

public UnivPowerSeries<C> reductum()
Reductum.

Returns:
this - leading monomial.

prepend

public UnivPowerSeries<C> prepend(C h)
Prepend a new leading coefficient.

Parameters:
h - new coefficient.
Returns:
new power series.

shift

public UnivPowerSeries<C> shift(int k)
Shift coefficients.

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

select

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

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

shiftSelect

public UnivPowerSeries<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 UnivPowerSeries<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 <C2 extends RingElem<C2>> UnivPowerSeries<C> zip(BinaryFunctor<? super C,? super C2,C> f,
                                                        UnivPowerSeries<C2> 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.

sum

public UnivPowerSeries<C> sum(UnivPowerSeries<C> ps)
Sum of two power series.

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

subtract

public UnivPowerSeries<C> subtract(UnivPowerSeries<C> ps)
Subtraction of two power series.

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

multiply

public UnivPowerSeries<C> multiply(C c)
Multiply by coefficient.

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

negate

public UnivPowerSeries<C> negate()
Negate.

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

abs

public UnivPowerSeries<C> abs()
Absolute value.

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

evaluate

public C evaluate(C e)
Evaluate at given point.

Returns:
ps(c).

order

public int order()
Order.

Returns:
index of first non zero coefficient.

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.

signum

public int signum()
Signum.

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

compareTo

public int compareTo(UnivPowerSeries<C> ps)
Compare to. Note: compare only up to truncate.

Specified by:
compareTo in interface Element<UnivPowerSeries<C extends RingElem<C>>>
Specified by:
compareTo in interface java.lang.Comparable<UnivPowerSeries<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<UnivPowerSeries<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<UnivPowerSeries<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<UnivPowerSeries<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<UnivPowerSeries<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<UnivPowerSeries<C extends RingElem<C>>>
Returns:
true, if this power series is invertible, else false.

multiply

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

Specified by:
multiply in interface MonoidElem<UnivPowerSeries<C extends RingElem<C>>>
Returns:
this * ps.

inverse

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

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

divide

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

Specified by:
divide in interface MonoidElem<UnivPowerSeries<C extends RingElem<C>>>
Returns:
this / ps.

remainder

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

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

differentiate

public UnivPowerSeries<C> differentiate()
Differentiate.

Returns:
differentiate(this).

integrate

public UnivPowerSeries<C> integrate(C c)
Integrate with given constant.

Parameters:
c - integration constant.
Returns:
integrate(this).

gcd

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

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

egcd

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

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