Package edu.jas.root
Class RealAlgebraicNumber<C extends GcdRingElem<C> & Rational>
- java.lang.Object
-
- 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.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
Fields Modifier and Type Field Description AlgebraicNumber<C>
number
Representing AlgebraicNumber.RealAlgebraicRing<C>
ring
Ring part of the data structure.
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RealAlgebraicNumber<C>
abs()
RealAlgebraicNumber absolute value.int
compareTo(AlgebraicNumber<C> b)
RealAlgebraicNumber comparison.int
compareTo(RealAlgebraicNumber<C> b)
RealAlgebraicNumber comparison.RealAlgebraicNumber<C>
copy()
Copy this.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.java.math.BigInteger
floor()
RealAlgebraicNumber floor.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
isRootOfUnity()
Is RealAlgebraicNumber a root of unity.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>[]
quotientRemainder(RealAlgebraicNumber<C> S)
Quotient and remainder by division of this by S.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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.jas.structure.MonoidElem
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
-
-
-
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 interfaceElement<C extends GcdRingElem<C> & Rational>
- Returns:
- factory for this Element.
- See Also:
Element.factory()
-
copy
public RealAlgebraicNumber<C> copy()
Copy this.- Specified by:
copy
in interfaceElement<C extends GcdRingElem<C> & Rational>
- Returns:
- Creates and returns a copy of this Element.
- See Also:
Element.copy()
-
getRational
public BigRational getRational()
Return a BigRational approximation of this Element.- Specified by:
getRational
in interfaceRational
- Returns:
- a BigRational approximation of this.
- See Also:
Rational.getRational()
-
isZERO
public boolean isZERO()
Is RealAlgebraicNumber zero.- Specified by:
isZERO
in interfaceAbelianGroupElem<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 interfaceMonoidElem<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 interfaceMonoidElem<C extends GcdRingElem<C> & Rational>
- Returns:
- If this is a unit then true is returned, else false.
- See Also:
MonoidElem.isUnit()
-
isRootOfUnity
public boolean isRootOfUnity()
Is RealAlgebraicNumber a root of unity.- Returns:
- true if |this**i| == 1, for some 0 < i ≤ deg(modul), else false.
-
toString
public java.lang.String toString()
Get the String representation as RingElem.- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.- Specified by:
toScript
in interfaceElement<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 interfaceElement<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 interfacejava.lang.Comparable<C extends GcdRingElem<C> & Rational>
- Specified by:
compareTo
in interfaceElement<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.
-
hashCode
public int hashCode()
Hash code for this RealAlgebraicNumber.
-
abs
public RealAlgebraicNumber<C> abs()
RealAlgebraicNumber absolute value.- Specified by:
abs
in interfaceAbelianGroupElem<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 interfaceAbelianGroupElem<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 interfaceAbelianGroupElem<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 interfaceAbelianGroupElem<C extends GcdRingElem<C> & Rational>
- Returns:
- real signum(this).
- See Also:
AbelianGroupElem.signum()
-
halfInterval
public void halfInterval()
RealAlgebraicNumber half interval.
-
floor
public java.math.BigInteger floor()
RealAlgebraicNumber floor.- Returns:
- floor of this.
-
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 interfaceAbelianGroupElem<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 interfaceMonoidElem<C extends GcdRingElem<C> & Rational>
- Parameters:
S
- RealAlgebraicNumber.- Returns:
- this/S.
-
inverse
public RealAlgebraicNumber<C> inverse()
RealAlgebraicNumber inverse.- Specified by:
inverse
in interfaceMonoidElem<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 interfaceMonoidElem<C extends GcdRingElem<C> & Rational>
- Parameters:
S
- RealAlgebraicNumber.- Returns:
- this - (this/S)*S.
-
quotientRemainder
public RealAlgebraicNumber<C>[] quotientRemainder(RealAlgebraicNumber<C> S)
Quotient and remainder by division of this by S.- Specified by:
quotientRemainder
in interfaceMonoidElem<C extends GcdRingElem<C> & Rational>
- Parameters:
S
- a RealAlgebraicNumber- Returns:
- [this/S, this - (this/S)*S].
-
multiply
public RealAlgebraicNumber<C> multiply(RealAlgebraicNumber<C> S)
RealAlgebraicNumber multiplication.- Specified by:
multiply
in interfaceMonoidElem<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.
-
egcd
public RealAlgebraicNumber<C>[] egcd(RealAlgebraicNumber<C> S)
RealAlgebraicNumber extended greatest common divisor.
-
-