edu.jas.arith
Class Product<C extends RingElem<C>>

java.lang.Object
  extended by edu.jas.arith.Product<C>
All Implemented Interfaces:
AbelianGroupElem<Product<C>>, Element<Product<C>>, GcdRingElem<Product<C>>, MonoidElem<Product<C>>, RegularRingElem<Product<C>>, RingElem<Product<C>>, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Product<C>>

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

Direct product element based on RingElem. Objects of this class are (nearly) immutable.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
protected  int isunit
          Flag to remember if this product element is a unit in each cmponent
 ProductRing<C> ring
          Product class factory data structure.
 java.util.SortedMap<java.lang.Integer,C> val
          Value part of the element data structure.
 
Constructor Summary
Product(ProductRing<C> r)
          The constructor creates a Product object from a ring factory.
Product(ProductRing<C> r, java.util.SortedMap<java.lang.Integer,C> a)
          The constructor creates a Product object from a ring factory and a ring element.
Product(ProductRing<C> r, java.util.SortedMap<java.lang.Integer,C> a, int u)
          The constructor creates a Product object from a ring factory, a ring element and an indicator if a is a unit.
 
Method Summary
 Product<C> abs()
          Product absolute value.
 Product<C> clone()
          Clone this.
 int compareTo(Product<C> b)
          Product comparison.
 Product<C> divide(Product<C> S)
          Product quasi-division.
 Product<C>[] egcd(Product<C> S)
          Extended greatest common divisor.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 Product<C> extend(int i, int j)
          Product extend.
 ProductRing<C> factory()
          Get the corresponding element factory.
 Product<C> fillIdempotent(Product<C> S)
          Product fill with idempotent.
 Product<C> fillOne()
          Product fill with one.
 Product<C> gcd(Product<C> S)
          Greatest common divisor.
 C get(int i)
          Get component.
 int hashCode()
          Hash code for this local.
 Product<C> idemComplement()
          Product idempotent complement.
 Product<C> idempotent()
          Product idempotent.
 Product<C> idempotentAnd(Product<C> S)
          Product idempotent and.
 Product<C> idempotentOr(Product<C> S)
          Product idempotent or.
 Product<C> inverse()
          Product quasi-inverse.
 boolean isFull()
          Is Product full.
 boolean isIdempotent()
          Is Product idempotent.
 boolean isONE()
          Is Product one.
 boolean isUnit()
          Is Product unit.
 boolean isZERO()
          Is Product zero.
 Product<C> multiply(C c)
          Product multiply by coefficient.
 Product<C> multiply(Product<C> S)
          Product multiplication.
 Product<C> negate()
          Product negate.
 Product<C> remainder(Product<C> S)
          Product quasi-remainder.
 int signum()
          Product signum.
 Product<C> subtract(Product<C> S)
          Product subtraction.
 Product<C> sum(Product<C> S)
          Product summation.
 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()
          Get the String representation as RingElem.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ring

public final ProductRing<C extends RingElem<C>> ring
Product class factory data structure.


val

public final java.util.SortedMap<java.lang.Integer,C extends RingElem<C>> val
Value part of the element data structure.


isunit

protected int isunit
Flag to remember if this product element is a unit in each cmponent. -1 is unknown, 1 is unit, 0 not a unit.

Constructor Detail

Product

public Product(ProductRing<C> r)
The constructor creates a Product object from a ring factory.

Parameters:
r - ring factory.

Product

public Product(ProductRing<C> r,
               java.util.SortedMap<java.lang.Integer,C> a)
The constructor creates a Product object from a ring factory and a ring element.

Parameters:
r - ring factory.
a - ring element.

Product

public Product(ProductRing<C> r,
               java.util.SortedMap<java.lang.Integer,C> a,
               int u)
The constructor creates a Product object from a ring factory, a ring element and an indicator if a is a unit.

Parameters:
r - ring factory.
a - ring element.
u - isunit indicator, -1, 0, 1.
Method Detail

get

public C get(int i)
Get component.

Parameters:
i - index of component.
Returns:
val(i).

factory

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

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

clone

public Product<C> clone()
Clone this.

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

isZERO

public boolean isZERO()
Is Product zero.

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

isONE

public boolean isONE()
Is Product one.

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

isFull

public boolean isFull()
Is Product full.

Specified by:
isFull in interface RegularRingElem<Product<C extends RingElem<C>>>
Returns:
If every component is non-zero, then true is returned, else false.

isUnit

public boolean isUnit()
Is Product unit.

Specified by:
isUnit in interface MonoidElem<Product<C extends RingElem<C>>>
Returns:
If this is a unit then true is returned, else false.
See Also:
MonoidElem.isUnit()

isIdempotent

public boolean isIdempotent()
Is Product idempotent.

Specified by:
isIdempotent in interface RegularRingElem<Product<C extends RingElem<C>>>
Returns:
If this is a idempotent element then true is returned, else false.

toString

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

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

toScript

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

Specified by:
toScript in interface Element<Product<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<Product<C extends RingElem<C>>>
Returns:
script compatible representation for this ElemFactory.
See Also:
Element.toScriptFactory()

compareTo

public int compareTo(Product<C> b)
Product comparison.

Specified by:
compareTo in interface Element<Product<C extends RingElem<C>>>
Specified by:
compareTo in interface java.lang.Comparable<Product<C extends RingElem<C>>>
Parameters:
b - Product.
Returns:
sign(this-b).

equals

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

Specified by:
equals in interface Element<Product<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 local.

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

extend

public Product<C> extend(int i,
                         int j)
Product extend. Add new component j with value of component i.

Parameters:
i - from index.
j - to index.
Returns:
the extended value of this.

abs

public Product<C> abs()
Product absolute value.

Specified by:
abs in interface AbelianGroupElem<Product<C extends RingElem<C>>>
Returns:
the absolute value of this.
See Also:
AbelianGroupElem.abs()

sum

public Product<C> sum(Product<C> S)
Product summation.

Specified by:
sum in interface AbelianGroupElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this+S.

negate

public Product<C> negate()
Product negate.

Specified by:
negate in interface AbelianGroupElem<Product<C extends RingElem<C>>>
Returns:
-this.
See Also:
AbelianGroupElem.negate()

signum

public int signum()
Product signum.

Specified by:
signum in interface AbelianGroupElem<Product<C extends RingElem<C>>>
Returns:
signum of first non-zero component.
See Also:
AbelianGroupElem.signum()

subtract

public Product<C> subtract(Product<C> S)
Product subtraction.

Specified by:
subtract in interface AbelianGroupElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this-S.

inverse

public Product<C> inverse()
Product quasi-inverse.

Specified by:
inverse in interface MonoidElem<Product<C extends RingElem<C>>>
Returns:
S with S = 1/this if defined.
See Also:
MonoidElem.inverse()

idempotent

public Product<C> idempotent()
Product idempotent.

Specified by:
idempotent in interface RegularRingElem<Product<C extends RingElem<C>>>
Returns:
smallest S with this*S = this.

idemComplement

public Product<C> idemComplement()
Product idempotent complement.

Specified by:
idemComplement in interface RegularRingElem<Product<C extends RingElem<C>>>
Returns:
1-this.idempotent().

idempotentAnd

public Product<C> idempotentAnd(Product<C> S)
Product idempotent and.

Specified by:
idempotentAnd in interface RegularRingElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this.idempotent() and S.idempotent().

idempotentOr

public Product<C> idempotentOr(Product<C> S)
Product idempotent or.

Specified by:
idempotentOr in interface RegularRingElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this.idempotent() or S.idempotent().

fillIdempotent

public Product<C> fillIdempotent(Product<C> S)
Product fill with idempotent.

Specified by:
fillIdempotent in interface RegularRingElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
fill this with S.idempotent().

fillOne

public Product<C> fillOne()
Product fill with one.

Specified by:
fillOne in interface RegularRingElem<Product<C extends RingElem<C>>>
Returns:
fill this with one.

divide

public Product<C> divide(Product<C> S)
Product quasi-division.

Specified by:
divide in interface MonoidElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this/S.

remainder

public Product<C> remainder(Product<C> S)
Product quasi-remainder.

Specified by:
remainder in interface MonoidElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this - (this/S)*S.

multiply

public Product<C> multiply(Product<C> S)
Product multiplication.

Specified by:
multiply in interface MonoidElem<Product<C extends RingElem<C>>>
Parameters:
S - Product.
Returns:
this*S.

multiply

public Product<C> multiply(C c)
Product multiply by coefficient.

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

gcd

public Product<C> gcd(Product<C> S)
Greatest common divisor.

Specified by:
gcd in interface RingElem<Product<C extends RingElem<C>>>
Parameters:
S - other element.
Returns:
gcd(this,S).

egcd

public Product<C>[] egcd(Product<C> S)
Extended greatest common divisor.

Specified by:
egcd in interface RingElem<Product<C extends RingElem<C>>>
Parameters:
S - other element.
Returns:
[ gcd(this,S), c1, c2 ] with c1*this + c2*b = gcd(this,S).