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>numberRepresenting AlgebraicNumber.RealAlgebraicRing<C>ringRing 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.intcompareTo(AlgebraicNumber<C> b)RealAlgebraicNumber comparison.intcompareTo(RealAlgebraicNumber<C> b)RealAlgebraicNumber comparison.RealAlgebraicNumber<C>copy()Copy this.BigDecimaldecimalMagnitude()RealAlgebraicNumber magnitude.RealAlgebraicNumber<C>divide(RealAlgebraicNumber<C> S)RealAlgebraicNumber division.RealAlgebraicNumber<C>[]egcd(RealAlgebraicNumber<C> S)RealAlgebraicNumber extended greatest common divisor.booleanequals(java.lang.Object b)Comparison with any other object.RealAlgebraicRing<C>factory()Get the corresponding element factory.java.math.BigIntegerfloor()RealAlgebraicNumber floor.RealAlgebraicNumber<C>gcd(RealAlgebraicNumber<C> S)RealAlgebraicNumber greatest common divisor.BigRationalgetRational()Return a BigRational approximation of this Element.voidhalfInterval()RealAlgebraicNumber half interval.inthashCode()Hash code for this RealAlgebraicNumber.RealAlgebraicNumber<C>inverse()RealAlgebraicNumber inverse.booleanisONE()Is RealAlgebraicNumber one.booleanisRootOfUnity()Is RealAlgebraicNumber a root of unity.booleanisUnit()Is RealAlgebraicNumber unit.booleanisZERO()Is RealAlgebraicNumber zero.BigRationalmagnitude()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.intsignum()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.StringtoScript()Get a scripting compatible string representation.java.lang.StringtoScriptFactory()Get a scripting compatible string representation of the factory.java.lang.StringtoString()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:
factoryin interfaceElement<C extends GcdRingElem<C> & Rational>- Returns:
- factory for this Element.
- See Also:
Element.factory()
-
copy
public RealAlgebraicNumber<C> copy()
Copy this.- Specified by:
copyin 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:
getRationalin interfaceRational- Returns:
- a BigRational approximation of this.
- See Also:
Rational.getRational()
-
isZERO
public boolean isZERO()
Is RealAlgebraicNumber zero.- Specified by:
isZEROin 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:
isONEin 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:
isUnitin 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:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.- Specified by:
toScriptin 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:
toScriptFactoryin 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:
compareToin interfacejava.lang.Comparable<C extends GcdRingElem<C> & Rational>- Specified by:
compareToin 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:
absin 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:
sumin 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:
negatein 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:
signumin 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:
subtractin interfaceAbelianGroupElem<C extends GcdRingElem<C> & Rational>- Parameters:
S- RealAlgebraicNumber.- Returns:
- this-S.
-
divide
public RealAlgebraicNumber<C> divide(RealAlgebraicNumber<C> S)
RealAlgebraicNumber division.- Specified by:
dividein interfaceMonoidElem<C extends GcdRingElem<C> & Rational>- Parameters:
S- RealAlgebraicNumber.- Returns:
- this/S.
-
inverse
public RealAlgebraicNumber<C> inverse()
RealAlgebraicNumber inverse.- Specified by:
inversein 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:
remainderin 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:
quotientRemainderin 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:
multiplyin 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.
-
-