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. -1 is unknown, 1 is unit, 0 not 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.
 AlgebraicNumberRing<C> factory()
          Get the corresponding element factory.
 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> multiply(C c)
          AlgebraicNumber multiplication.
 AlgebraicNumber<C> multiply(GenPolynomial<C> c)
          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.
 AlgebraicNumber<C> sum(C c)
          AlgebraicNumber summation.
 AlgebraicNumber<C> sum(GenPolynomial<C> c)
          AlgebraicNumber 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 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.

factory

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

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

clone

public AlgebraicNumber<C> clone()
Clone this.

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

isZERO

public boolean isZERO()
Is AlgebraicNumber zero.

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

isONE

public boolean isONE()
Is AlgebraicNumber one.

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

isUnit

public boolean isUnit()
Is AlgebraicNumber unit.

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

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

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
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 AlgebraicNumber.

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

abs

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

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

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.

sum

public AlgebraicNumber<C> sum(GenPolynomial<C> c)
AlgebraicNumber summation.

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

sum

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

Parameters:
c - polynomial.
Returns:
this+c.

negate

public AlgebraicNumber<C> negate()
AlgebraicNumber negate.

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

signum

public int signum()
AlgebraicNumber signum.

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

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>>>
Returns:
S with S = 1/this if defined.
Throws:
NotInvertibleException - if the element is not invertible.
See Also:
MonoidElem.inverse()

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.

multiply

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

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

multiply

public AlgebraicNumber<C> multiply(GenPolynomial<C> c)
AlgebraicNumber multiplication.

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

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).