edu.jas.root
Class RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>

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

public class RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>
extends java.lang.Object
implements GcdRingElem<RealAlgebraicNumber<C>>, Rational

Real algebraic number class based on AlgebraicNumber. Objects of this class are immutable.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
 AlgebraicNumber<C> number
          Representing AlgebraicNumber.
 RealAlgebraicRing<C> ring
          Ring part of the data structure.
 
Constructor Summary
RealAlgebraicNumber(RealAlgebraicRing<C> r)
          The constructor creates a RealAlgebraicNumber object from a GenPolynomial object module.
RealAlgebraicNumber(RealAlgebraicRing<C> r, AlgebraicNumber<C> a)
          The constructor creates a RealAlgebraicNumber object from RealAlgebraicRing modul and a AlgebraicNumber value.
RealAlgebraicNumber(RealAlgebraicRing<C> r, GenPolynomial<C> a)
          The constructor creates a RealAlgebraicNumber object from RealAlgebraicRing modul and a GenPolynomial value.
 
Method Summary
 RealAlgebraicNumber<C> abs()
          RealAlgebraicNumber absolute value.
 RealAlgebraicNumber<C> clone()
          Clone this.
 int compareTo(AlgebraicNumber<C> b)
          RealAlgebraicNumber comparison.
 int compareTo(RealAlgebraicNumber<C> b)
          RealAlgebraicNumber comparison.
 BigDecimal decimalMagnitude()
          RealAlgebraicNumber magnitude.
 RealAlgebraicNumber<C> divide(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber division.
 RealAlgebraicNumber<C>[] egcd(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber extended greatest common divisor.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 RealAlgebraicRing<C> factory()
          Get the corresponding element factory.
 RealAlgebraicNumber<C> gcd(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber greatest common divisor.
 BigRational getRational()
          Return a BigRational approximation of this Element.
 void halfInterval()
          RealAlgebraicNumber half interval.
 int hashCode()
          Hash code for this RealAlgebraicNumber.
 RealAlgebraicNumber<C> inverse()
          RealAlgebraicNumber inverse.
 boolean isONE()
          Is RealAlgebraicNumber one.
 boolean isUnit()
          Is RealAlgebraicNumber unit.
 boolean isZERO()
          Is RealAlgebraicNumber zero.
 BigRational magnitude()
          RealAlgebraicNumber magnitude.
 RealAlgebraicNumber<C> monic()
          RealAlgebraicNumber monic.
 RealAlgebraicNumber<C> multiply(C c)
          RealAlgebraicNumber multiplication.
 RealAlgebraicNumber<C> multiply(GenPolynomial<C> c)
          RealAlgebraicNumber multiplication.
 RealAlgebraicNumber<C> multiply(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber multiplication.
 RealAlgebraicNumber<C> negate()
          RealAlgebraicNumber negate.
 RealAlgebraicNumber<C> remainder(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber remainder.
 int signum()
          RealAlgebraicNumber signum.
 RealAlgebraicNumber<C> subtract(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber subtraction.
 RealAlgebraicNumber<C> sum(C c)
          RealAlgebraicNumber summation.
 RealAlgebraicNumber<C> sum(GenPolynomial<C> c)
          RealAlgebraicNumber summation.
 RealAlgebraicNumber<C> sum(RealAlgebraicNumber<C> S)
          RealAlgebraicNumber 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

number

public final AlgebraicNumber<C extends GcdRingElem<C> & Rational> number
Representing AlgebraicNumber.


ring

public final RealAlgebraicRing<C extends GcdRingElem<C> & Rational> ring
Ring part of the data structure.

Constructor Detail

RealAlgebraicNumber

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

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

RealAlgebraicNumber

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

Parameters:
r - ring RealAlgebraicRing.
a - value AlgebraicNumber.

RealAlgebraicNumber

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

Parameters:
r - ring RealAlgebraicRing.
Method Detail

factory

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

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

clone

public RealAlgebraicNumber<C> clone()
Clone this.

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

getRational

public BigRational getRational()
Return a BigRational approximation of this Element.

Specified by:
getRational in interface Rational
Returns:
a BigRational approximation of this.
See Also:
Rational.getRational()

isZERO

public boolean isZERO()
Is RealAlgebraicNumber zero.

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

isONE

public boolean isONE()
Is RealAlgebraicNumber one.

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

isUnit

public boolean isUnit()
Is RealAlgebraicNumber unit.

Specified by:
isUnit in interface MonoidElem<RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>>
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<RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>>
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<RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>>
Returns:
script compatible representation for this ElemFactory.
See Also:
Element.toScriptFactory()

compareTo

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

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

compareTo

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

Parameters:
b - AlgebraicNumber.
Returns:
polynomial sign(this-b).

equals

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

Specified by:
equals in interface Element<RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>>
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 RealAlgebraicNumber.

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

abs

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

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

sum

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

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

sum

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

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

sum

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

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

negate

public RealAlgebraicNumber<C> negate()
RealAlgebraicNumber negate.

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

signum

public int signum()
RealAlgebraicNumber signum. Note: Modifies ring.root eventually.

Specified by:
signum in interface AbelianGroupElem<RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>>
Returns:
real signum(this).
See Also:
AbelianGroupElem.signum()

halfInterval

public void halfInterval()
RealAlgebraicNumber half interval.


magnitude

public BigRational magnitude()
RealAlgebraicNumber magnitude.

Returns:
|this|.

decimalMagnitude

public BigDecimal decimalMagnitude()
RealAlgebraicNumber magnitude.

Returns:
|this| as big decimal.

subtract

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

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

divide

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

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

inverse

public RealAlgebraicNumber<C> inverse()
RealAlgebraicNumber inverse.

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

remainder

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

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

multiply

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

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

multiply

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

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

multiply

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

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

monic

public RealAlgebraicNumber<C> monic()
RealAlgebraicNumber monic.

Returns:
this with monic value part.

gcd

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

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

egcd

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

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