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>>,Serializable,Comparable<Complex<C>>
public class Complex<C extends RingElem<C>>
extends Object
implements StarRingElem<Complex<C>>, GcdRingElem<Complex<C>>
Generic Complex class implementing the RingElem interface. Objects of this
class are immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprotected final CImaginary part of the data structure.private static final org.apache.logging.log4j.Loggerprotected final CReal part of the data structure.final ComplexRing<C> Complex class factory data structure. -
Constructor Summary
ConstructorsConstructorDescriptionComplex(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, String s) The constructor creates a Complex object from a String representation. -
Method Summary
Modifier and TypeMethodDescriptionabs()Complex number absolute value.intSince complex numbers are unordered, we use lexicographical order of re and im.Complex number conjugate.copy()Copy this.Complex number divide.Complex extended greatest common divisor.booleanComparison with any other object.factory()Get the corresponding element factory.Complex number greatest common divisor.getIm()Get the imaginary part.getRe()Get the real part.inthashCode()Hash code for this Complex.inverse()Complex number inverse.booleanisIMAG()Is Complex imaginary one.booleanisONE()Is Complex number one.booleanisUnit()Is Complex unit element.booleanisZERO()Is Complex number zero.Complex number product.negate()Complex number negative.norm()Complex number norm.Complex number quotient and remainder.Complex number remainder.intsignum()Since complex numbers are unordered, we use lexicographical order of re and im.Complex number subtract.Complex number summation.toScript()Get a scripting compatible string representation.Get a scripting compatible string representation of the factory.toString()Get the String representation.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface edu.jas.structure.MonoidElem
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
debug
private static final boolean debug -
ring
Complex class factory data structure. -
re
Real part of the data structure. -
im
Imaginary part of the data structure.
-
-
Constructor Details
-
Complex
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
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
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
The constructor creates a Complex object with real part 0 and imaginary part 0. -
Complex
The constructor creates a Complex object from a String representation.- Parameters:
s- string of a Complex.- Throws:
NumberFormatException
-
-
Method Details
-
factory
Get the corresponding element factory. -
getRe
Get the real part.- Returns:
- re.
-
getIm
Get the imaginary part.- Returns:
- im.
-
copy
Copy this. -
toString
Get the String representation. -
toScript
Get a scripting compatible string representation. -
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactoryin interfaceElement<C extends RingElem<C>>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
isZERO
public boolean isZERO()Is Complex number zero.- Specified by:
isZEROin interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- If this is 0 then true is returned, else false.
- See Also:
-
isONE
public boolean isONE()Is Complex number one.- Specified by:
isONEin interfaceMonoidElem<C extends RingElem<C>>- Returns:
- If this is 1 then true is returned, else false.
- See Also:
-
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:
isUnitin interfaceMonoidElem<C extends RingElem<C>>- Returns:
- If this is a unit then true is returned, else false.
- See Also:
-
equals
Comparison with any other object. -
hashCode
public int hashCode()Hash code for this Complex. -
compareTo
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:
signumin 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:
-
sum
Complex number summation.- Specified by:
sumin interfaceAbelianGroupElem<C extends RingElem<C>>- Parameters:
B- a Complexnumber. - Returns:
- this+B.
-
subtract
Complex number subtract.- Specified by:
subtractin interfaceAbelianGroupElem<C extends RingElem<C>>- Parameters:
B- a Complexnumber. - Returns:
- this-B.
-
negate
Complex number negative.- Specified by:
negatein interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- -this.
- See Also:
-
conjugate
Complex number conjugate.- Specified by:
conjugatein interfaceStarRingElem<C extends RingElem<C>>- Returns:
- the complex conjugate of this.
-
norm
Complex number norm.- Specified by:
normin interfaceStarRingElem<C extends RingElem<C>>- Returns:
- ||this||.
- See Also:
-
abs
Complex number absolute value.- Specified by:
absin interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- |this|^2. Note: The square root is not jet implemented.
- See Also:
-
multiply
Complex number product.- Specified by:
multiplyin interfaceMonoidElem<C extends RingElem<C>>- Parameters:
B- is a complex number.- Returns:
- this*B.
-
inverse
Complex number inverse.- Specified by:
inversein interfaceMonoidElem<C extends RingElem<C>>- Returns:
- S with S*this = 1, if it is defined.
- See Also:
-
remainder
Complex number remainder.- Specified by:
remainderin interfaceMonoidElem<C extends RingElem<C>>- Parameters:
S- is a complex number.- Returns:
- 0.
-
divide
Complex number divide.- Specified by:
dividein interfaceMonoidElem<C extends RingElem<C>>- Parameters:
B- is a complex number, non-zero.- Returns:
- this/B.
-
quotientRemainder
Complex number quotient and remainder.- Specified by:
quotientRemainderin interfaceMonoidElem<C extends RingElem<C>>- Parameters:
S- Complex.- Returns:
- Complex[] { q, r } with q = this/S and r = rem(this,S).
-
gcd
Complex number greatest common divisor. -
egcd
Complex extended greatest common divisor.
-