edu.jas.poly
Class AlgebraicNumber<C extends GcdRingElem<C>>

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

public class AlgebraicNumber<C extends GcdRingElem<C>>
extends java.lang.Object
implements GcdRingElem<AlgebraicNumber<C>>

Algebraic number class based on GenPolynomial with RingElem interface. Objects of this class are immutable.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
protected  int isunit
          Flag to remember if this algebraic number is a unit
 AlgebraicNumberRing<C> ring
          Ring part of the data structure.
 GenPolynomial<C> val
          Value part of the element data structure.
 
Constructor Summary
AlgebraicNumber(AlgebraicNumberRing<C> r)
          The constructor creates a AlgebraicNumber object from a GenPolynomial object module.
AlgebraicNumber(AlgebraicNumberRing<C> r, GenPolynomial<C> a)
          The constructor creates a AlgebraicNumber object from AlgebraicNumberRing modul and a GenPolynomial value.
 
Method Summary
 AlgebraicNumber<C> abs()
          AlgebraicNumber absolute value.
 AlgebraicNumber<C> clone()
          Clone this.
 int compareTo(AlgebraicNumber<C> b)
          AlgebraicNumber comparison.
 AlgebraicNumber<C> divide(AlgebraicNumber<C> S)
          AlgebraicNumber division.
 AlgebraicNumber<C>[] egcd(AlgebraicNumber<C> S)
          AlgebraicNumber extended greatest common divisor.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 AlgebraicNumber<C> gcd(AlgebraicNumber<C> S)
          AlgebraicNumber greatest common divisor.
 GenPolynomial<C> getVal()
          Get the value part.
 int hashCode()
          Hash code for this AlgebraicNumber.
 AlgebraicNumber<C> inverse()
          AlgebraicNumber inverse.
 boolean isONE()
          Is AlgebraicNumber one.
 boolean isUnit()
          Is AlgebraicNumber unit.
 boolean isZERO()
          Is AlgebraicNumber zero.
 AlgebraicNumber<C> monic()
          AlgebraicNumber monic.
 AlgebraicNumber<C> multiply(AlgebraicNumber<C> S)
          AlgebraicNumber multiplication.
 AlgebraicNumber<C> negate()
          AlgebraicNumber negate.
 AlgebraicNumber<C> remainder(AlgebraicNumber<C> S)
          AlgebraicNumber remainder.
 int signum()
          AlgebraicNumber signum.
 AlgebraicNumber<C> subtract(AlgebraicNumber<C> S)
          AlgebraicNumber subtraction.
 AlgebraicNumber<C> sum(AlgebraicNumber<C> S)
          AlgebraicNumber summation.
 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 AlgebraicNumberRing<C extends GcdRingElem<C>> ring
Ring part of the data structure.


val

public final GenPolynomial<C extends GcdRingElem<C>> val
Value part of the element data structure.


isunit

protected int isunit
Flag to remember if this algebraic number is a unit. -1 is unknown, 1 is unit, 0 not a unit.

Constructor Detail

AlgebraicNumber

public AlgebraicNumber(AlgebraicNumberRing<C> r,
                       GenPolynomial<C> a)
The constructor creates a AlgebraicNumber object from AlgebraicNumberRing modul and a GenPolynomial value.

Parameters:
r - ring AlgebraicNumberRing.
a - value GenPolynomial.

AlgebraicNumber

public AlgebraicNumber(AlgebraicNumberRing<C> r)
The constructor creates a AlgebraicNumber object from a GenPolynomial object module.

Parameters:
r - ring AlgebraicNumberRing.
Method Detail

getVal

public GenPolynomial<C> getVal()
Get the value part.

Returns:
val.

clone

public AlgebraicNumber<C> clone()
Clone this.

Specified by:
clone in interface Element<AlgebraicNumber<C extends GcdRingElem<C>>>
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()
Returns:
Creates and returns a copy of this Elemnt.

isZERO

public boolean isZERO()
Is AlgebraicNumber zero.

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

isONE

public boolean isONE()
Is AlgebraicNumber one.

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

isUnit

public boolean isUnit()
Is AlgebraicNumber unit.

Specified by:
isUnit in interface MonoidElem<AlgebraicNumber<C extends GcdRingElem<C>>>
See Also:
MonoidElem.isUnit()
Returns:
If this is a unit 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()

compareTo

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

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

equals

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

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

hashCode

public int hashCode()
Hash code for this AlgebraicNumber.

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

abs

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

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

sum

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

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

negate

public AlgebraicNumber<C> negate()
AlgebraicNumber negate.

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

signum

public int signum()
AlgebraicNumber signum.

Specified by:
signum in interface AbelianGroupElem<AlgebraicNumber<C extends GcdRingElem<C>>>
See Also:
AbelianGroupElem.signum()
Returns:
signum(this).

subtract

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

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

divide

public AlgebraicNumber<C> divide(AlgebraicNumber<C> S)
AlgebraicNumber division.

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

inverse

public AlgebraicNumber<C> inverse()
AlgebraicNumber inverse.

Specified by:
inverse in interface MonoidElem<AlgebraicNumber<C extends GcdRingElem<C>>>
Throws:
NotInvertibleException - if the element is not invertible.
See Also:
MonoidElem.inverse()
Returns:
S with S = 1/this if defined.

remainder

public AlgebraicNumber<C> remainder(AlgebraicNumber<C> S)
AlgebraicNumber remainder.

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

multiply

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

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

monic

public AlgebraicNumber<C> monic()
AlgebraicNumber monic.

Returns:
this with monic value part.

gcd

public AlgebraicNumber<C> gcd(AlgebraicNumber<C> S)
AlgebraicNumber greatest common divisor.

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

egcd

public AlgebraicNumber<C>[] egcd(AlgebraicNumber<C> S)
AlgebraicNumber extended greatest common divisor.

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