Package edu.jas.poly
Class Complex<C extends RingElem<C>>
- java.lang.Object
-
- edu.jas.poly.Complex<C>
-
- Type Parameters:
C
- base type of RingElem (for complex polynomials).
- All Implemented Interfaces:
AbelianGroupElem<Complex<C>>
,Element<Complex<C>>
,GcdRingElem<Complex<C>>
,MonoidElem<Complex<C>>
,RingElem<Complex<C>>
,StarRingElem<Complex<C>>
,java.io.Serializable
,java.lang.Comparable<Complex<C>>
public class Complex<C extends RingElem<C>> extends java.lang.Object implements StarRingElem<Complex<C>>, GcdRingElem<Complex<C>>
Generic Complex class implementing the RingElem interface. Objects of this class are immutable.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Complex(ComplexRing<C> ring)
The constructor creates a Complex object with real part 0 and imaginary part 0.Complex(ComplexRing<C> ring, long r)
The constructor creates a Complex object from a long element as real part, the imaginary part is set to 0.Complex(ComplexRing<C> ring, C r)
The constructor creates a Complex object from a C object as real part, the imaginary part is set to 0.Complex(ComplexRing<C> ring, C r, C i)
The constructor creates a Complex object from two C objects as real and imaginary part.Complex(ComplexRing<C> ring, java.lang.String s)
The constructor creates a Complex object from a String representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Complex<C>
abs()
Complex number absolute value.int
compareTo(Complex<C> b)
Since complex numbers are unordered, we use lexicographical order of re and im.Complex<C>
conjugate()
Complex number conjugate.Complex<C>
copy()
Copy this.Complex<C>
divide(Complex<C> B)
Complex number divide.Complex<C>[]
egcd(Complex<C> S)
Complex extended greatest common divisor.boolean
equals(java.lang.Object b)
Comparison with any other object.ComplexRing<C>
factory()
Get the corresponding element factory.Complex<C>
gcd(Complex<C> S)
Complex number greatest common divisor.C
getIm()
Get the imaginary part.C
getRe()
Get the real part.int
hashCode()
Hash code for this Complex.Complex<C>
inverse()
Complex number inverse.boolean
isIMAG()
Is Complex imaginary one.boolean
isONE()
Is Complex number one.boolean
isUnit()
Is Complex unit element.boolean
isZERO()
Is Complex number zero.Complex<C>
multiply(Complex<C> B)
Complex number product.Complex<C>
negate()
Complex number negative.Complex<C>
norm()
Complex number norm.Complex<C>[]
quotientRemainder(Complex<C> S)
Complex number quotient and remainder.Complex<C>
remainder(Complex<C> S)
Complex number remainder.int
signum()
Since complex numbers are unordered, we use lexicographical order of re and im.Complex<C>
subtract(Complex<C> B)
Complex number subtract.Complex<C>
sum(Complex<C> B)
Complex number 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.-
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
-
-
-
-
Constructor Detail
-
Complex
public Complex(ComplexRing<C> ring, C r, C i)
The constructor creates a Complex object from two C objects as real and imaginary part.- Parameters:
ring
- factory for Complex objects.r
- real part.i
- imaginary part.
-
Complex
public Complex(ComplexRing<C> ring, C r)
The constructor creates a Complex object from a C object as real part, the imaginary part is set to 0.- Parameters:
r
- real part.
-
Complex
public Complex(ComplexRing<C> ring, long r)
The constructor creates a Complex object from a long element as real part, the imaginary part is set to 0.- Parameters:
r
- real part.
-
Complex
public Complex(ComplexRing<C> ring)
The constructor creates a Complex object with real part 0 and imaginary part 0.
-
Complex
public Complex(ComplexRing<C> ring, java.lang.String s) throws java.lang.NumberFormatException
The constructor creates a Complex object from a String representation.- Parameters:
s
- string of a Complex.- Throws:
java.lang.NumberFormatException
-
-
Method Detail
-
factory
public ComplexRing<C> factory()
Get the corresponding element factory.
-
toString
public java.lang.String toString()
Get the String representation.- Overrides:
toString
in classjava.lang.Object
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.
-
toScriptFactory
public java.lang.String toScriptFactory()
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactory
in interfaceElement<C extends RingElem<C>>
- Returns:
- script compatible representation for this ElemFactory.
- See Also:
Element.toScriptFactory()
-
isZERO
public boolean isZERO()
Is Complex number zero.- Specified by:
isZERO
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- If this is 0 then true is returned, else false.
- See Also:
AbelianGroupElem.isZERO()
-
isONE
public boolean isONE()
Is Complex number one.- Specified by:
isONE
in interfaceMonoidElem<C extends RingElem<C>>
- Returns:
- If this is 1 then true is returned, else false.
- See Also:
MonoidElem.isONE()
-
isIMAG
public boolean isIMAG()
Is Complex imaginary one.- Returns:
- If this is i then true is returned, else false.
-
isUnit
public boolean isUnit()
Is Complex unit element.- Specified by:
isUnit
in interfaceMonoidElem<C extends RingElem<C>>
- Returns:
- If this is a unit then true is returned, else false.
- See Also:
MonoidElem.isUnit()
-
equals
public boolean equals(java.lang.Object b)
Comparison with any other object.
-
hashCode
public int hashCode()
Hash code for this Complex.
-
compareTo
public int compareTo(Complex<C> b)
Since complex numbers are unordered, we use lexicographical order of re and im.
-
signum
public int signum()
Since complex numbers are unordered, we use lexicographical order of re and im.- Specified by:
signum
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- 0 if this is equal to 0; 1 if re > 0, or re == 0 and im > 0; -1 if re < 0, or re == 0 and im < 0
- See Also:
AbelianGroupElem.signum()
-
sum
public Complex<C> sum(Complex<C> B)
Complex number summation.- Specified by:
sum
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Parameters:
B
- a Complexnumber. - Returns:
- this+B.
-
subtract
public Complex<C> subtract(Complex<C> B)
Complex number subtract.- Specified by:
subtract
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Parameters:
B
- a Complexnumber. - Returns:
- this-B.
-
negate
public Complex<C> negate()
Complex number negative.- Specified by:
negate
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- -this.
- See Also:
AbelianGroupElem.negate()
-
conjugate
public Complex<C> conjugate()
Complex number conjugate.- Specified by:
conjugate
in interfaceStarRingElem<C extends RingElem<C>>
- Returns:
- the complex conjugate of this.
-
norm
public Complex<C> norm()
Complex number norm.- Specified by:
norm
in interfaceStarRingElem<C extends RingElem<C>>
- Returns:
- ||this||.
- See Also:
StarRingElem.norm()
-
abs
public Complex<C> abs()
Complex number absolute value.- Specified by:
abs
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- |this|^2. Note: The square root is not jet implemented.
- See Also:
AbelianGroupElem.abs()
-
multiply
public Complex<C> multiply(Complex<C> B)
Complex number product.- Specified by:
multiply
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
B
- is a complex number.- Returns:
- this*B.
-
inverse
public Complex<C> inverse()
Complex number inverse.- Specified by:
inverse
in interfaceMonoidElem<C extends RingElem<C>>
- Returns:
- S with S*this = 1, if it is defined.
- See Also:
MonoidElem.inverse()
-
remainder
public Complex<C> remainder(Complex<C> S)
Complex number remainder.- Specified by:
remainder
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
S
- is a complex number.- Returns:
- 0.
-
divide
public Complex<C> divide(Complex<C> B)
Complex number divide.- Specified by:
divide
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
B
- is a complex number, non-zero.- Returns:
- this/B.
-
quotientRemainder
public Complex<C>[] quotientRemainder(Complex<C> S)
Complex number quotient and remainder.- Specified by:
quotientRemainder
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
S
- Complex.- Returns:
- Complex[] { q, r } with q = this/S and r = rem(this,S).
-
-