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.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description ComplexRing<C>ringComplex class factory data structure.
-
Constructor Summary
Constructors Constructor and Description Complex(ComplexRing<C> ring)The constructor creates a Complex object with real part 0 and imaginary part 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, 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, java.lang.String s)The constructor creates a Complex object from a String representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description Complex<C>abs()Complex number absolute value.intcompareTo(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()Clone this.Complex<C>divide(Complex<C> B)Complex number divide.Complex<C>[]divideAndRemainder(Complex<C> S)Deprecated.use quotientRemainder()Complex<C>[]egcd(Complex<C> S)Complex extended greatest common divisor.booleanequals(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.CgetIm()Get the imaginary part.CgetRe()Get the real part.inthashCode()Hash code for this Complex.Complex<C>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<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.intsignum()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.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.
-
-
-
Field Detail
-
ring
public final ComplexRing<C extends RingElem<C>> ring
Complex class factory data structure.
-
-
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.
-
getRe
public C getRe()
Get the real part.- Returns:
- re.
-
getIm
public C getIm()
Get the imaginary part.- Returns:
- im.
-
toString
public java.lang.String toString()
Get the String representation.- Overrides:
toStringin 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:
toScriptFactoryin interfaceElement<Complex<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:
isZEROin interfaceAbelianGroupElem<Complex<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:
isONEin interfaceMonoidElem<Complex<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:
isUnitin interfaceMonoidElem<Complex<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:
signumin interfaceAbelianGroupElem<Complex<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()
-
negate
public Complex<C> negate()
Complex number negative.- Specified by:
negatein interfaceAbelianGroupElem<Complex<C extends RingElem<C>>>- Returns:
- -this.
- See Also:
AbelianGroupElem.negate()
-
norm
public Complex<C> norm()
Complex number norm.- Specified by:
normin interfaceStarRingElem<Complex<C extends RingElem<C>>>- Returns:
- ||this||.
- See Also:
StarRingElem.norm()
-
abs
public Complex<C> abs()
Complex number absolute value.- Specified by:
absin interfaceAbelianGroupElem<Complex<C extends RingElem<C>>>- Returns:
- |this|^2. Note: The square root is not jet implemented.
- See Also:
AbelianGroupElem.abs()
-
inverse
public Complex<C> inverse()
Complex number inverse.- Specified by:
inversein interfaceMonoidElem<Complex<C extends RingElem<C>>>- Returns:
- S with S*this = 1, if it is defined.
- See Also:
MonoidElem.inverse()
-
quotientRemainder
public Complex<C>[] quotientRemainder(Complex<C> S)
Complex number quotient and remainder.- Parameters:
S- Complex.- Returns:
- Complex[] { q, r } with q = this/S and r = rem(this,S).
-
divideAndRemainder
@Deprecated public Complex<C>[] divideAndRemainder(Complex<C> S)
Deprecated. use quotientRemainder()Complex number quotient and remainder.- Parameters:
S- Complex.- Returns:
- Complex[] { q, r } with q = this/S and r = rem(this,S).
-
-
DMelt 3.0 © DataMelt by jWork.ORG