Package edu.jas.arith
Class BigComplex
- java.lang.Object
-
- edu.jas.arith.BigComplex
-
- All Implemented Interfaces:
AbelianGroupElem<BigComplex>
,AbelianGroupFactory<BigComplex>
,Element<BigComplex>
,ElemFactory<BigComplex>
,GcdRingElem<BigComplex>
,MonoidElem<BigComplex>
,MonoidFactory<BigComplex>
,RingElem<BigComplex>
,RingFactory<BigComplex>
,StarRingElem<BigComplex>
,java.io.Serializable
,java.lang.Comparable<BigComplex>
public final class BigComplex extends java.lang.Object implements StarRingElem<BigComplex>, GcdRingElem<BigComplex>, RingFactory<BigComplex>
BigComplex class based on BigRational implementing the RingElem respectively the StarRingElem interface. Objects of this class are immutable. The SAC2 static methods are also provided.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static BigComplex
I
The constant i.BigRational
im
Imaginary part of the data structure.static BigComplex
ONE
The constant 1.BigRational
re
Real part of the data structure.static BigComplex
ZERO
The constant 0.
-
Constructor Summary
Constructors Constructor Description BigComplex()
The constructor creates a BigComplex object with real part 0 and imaginary part 0.BigComplex(long r)
The constructor creates a BigComplex object from a long element as real part, the imaginary part is set to 0.BigComplex(BigRational r)
The constructor creates a BigComplex object from a BigRational object as real part, the imaginary part is set to 0.BigComplex(BigRational r, BigRational i)
The constructor creates a BigComplex object from two BigRational objects real and imaginary part.BigComplex(java.lang.String s)
The constructor creates a BigComplex object from a String representation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BigComplex
abs()
Complex number absolute value.long
bitLength()
Returns the number of bits in the representation of this BigComplex, including a sign bit.static BigRational
CABS(BigComplex A)
Complex number absolute value.static BigComplex
CCON(BigComplex A)
Complex number conjugate.static BigComplex
CDIF(BigComplex A, BigComplex B)
Complex number difference.java.math.BigInteger
characteristic()
Characteristic of this ring.static BigComplex
CINV(BigComplex A)
Complex number inverse.static BigComplex
CNEG(BigComplex A)
Complex number negative.int
compareTo(BigComplex b)
Since complex numbers are unordered, we use lexicographical order of re and im.BigComplex
conjugate()
Complex number conjugate.BigComplex
copy()
Clone this.BigComplex
copy(BigComplex c)
Copy BigComplex element c.static BigComplex
CPROD(BigComplex A, BigComplex B)
Complex number product.static BigComplex
CQ(BigComplex A, BigComplex B)
Complex number quotient.static BigComplex
CRAND(int n)
Complex number, random.static BigComplex
CSUM(BigComplex A, BigComplex B)
Complex number sum.BigComplex
divide(BigComplex B)
Complex number divide.BigComplex[]
egcd(BigComplex S)
BigComplex extended greatest common divisor.boolean
equals(java.lang.Object b)
Comparison with any other object.BigComplex
factory()
Get the corresponding element factory.BigComplex
fromInteger(long a)
Get a BigComplex element from a long.BigComplex
fromInteger(java.math.BigInteger a)
Get a BigComplex element from a BigInteger.BigComplex
gcd(BigComplex S)
Complex number greatest common divisor.java.util.List<BigComplex>
generators()
Get a list of the generating elements.BigRational
getIm()
Get the imaginary part.BigComplex
getIMAG()
Get the i element.BigComplex
getONE()
Get the one element.BigRational
getRe()
Get the real part.BigComplex
getZERO()
Get the zero element.int
hashCode()
Hash code for this BigComplex.BigComplex
inverse()
Complex number inverse.boolean
isAssociative()
Query if this ring is associative.boolean
isCommutative()
Query if this ring is commutative.static boolean
isCONE(BigComplex A)
Complex number one.static boolean
isCZERO(BigComplex A)
Complex number zero.boolean
isField()
Query if this ring is a field.boolean
isFinite()
Is this structure finite or infinite.boolean
isIMAG()
Is Complex imaginary one.boolean
isONE()
Is Complex number one.boolean
isUnit()
Is Complex unit element.boolean
isZERO()
Is Complex number zero.BigComplex
multiply(BigComplex B)
Complex number product.BigComplex
negate()
Complex number negative.BigComplex
norm()
Complex number norm.BigComplex
parse(java.io.Reader r)
Parse complex number from Reader.BigComplex
parse(java.lang.String s)
Parse complex number from string.BigComplex[]
quotientRemainder(BigComplex S)
Quotient and remainder by division of this by S.BigComplex
random(int n)
Complex number, random.BigComplex
random(int n, java.util.Random rnd)
Complex number, random.BigComplex
remainder(BigComplex S)
Complex number inverse.int
signum()
Since complex numbers are unordered, we use lexicographical order of re and im.BigComplex
subtract(BigComplex B)
Complex number subtract.BigComplex
sum(BigComplex 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.ElemFactory
valueOf
-
Methods inherited from interface edu.jas.structure.MonoidElem
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
-
-
-
Field Detail
-
re
public final BigRational re
Real part of the data structure.
-
im
public final BigRational im
Imaginary part of the data structure.
-
ZERO
public static final BigComplex ZERO
The constant 0.
-
ONE
public static final BigComplex ONE
The constant 1.
-
I
public static final BigComplex I
The constant i.
-
-
Constructor Detail
-
BigComplex
public BigComplex(BigRational r, BigRational i)
The constructor creates a BigComplex object from two BigRational objects real and imaginary part.- Parameters:
r
- real part.i
- imaginary part.
-
BigComplex
public BigComplex(BigRational r)
The constructor creates a BigComplex object from a BigRational object as real part, the imaginary part is set to 0.- Parameters:
r
- real part.
-
BigComplex
public BigComplex(long r)
The constructor creates a BigComplex object from a long element as real part, the imaginary part is set to 0.- Parameters:
r
- real part.
-
BigComplex
public BigComplex()
The constructor creates a BigComplex object with real part 0 and imaginary part 0.
-
BigComplex
public BigComplex(java.lang.String s) throws java.lang.NumberFormatException
The constructor creates a BigComplex object from a String representation.- Parameters:
s
- string of a BigComplex.- Throws:
java.lang.NumberFormatException
-
-
Method Detail
-
factory
public BigComplex factory()
Get the corresponding element factory.- Specified by:
factory
in interfaceElement<BigComplex>
- Returns:
- factory for this Element.
- See Also:
Element.factory()
-
generators
public java.util.List<BigComplex> generators()
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<BigComplex>
- Returns:
- list of generators for the algebraic structure.
- See Also:
ElemFactory.generators()
-
isFinite
public boolean isFinite()
Is this structure finite or infinite.- Specified by:
isFinite
in interfaceElemFactory<BigComplex>
- Returns:
- true if this structure is finite, else false.
- See Also:
ElemFactory.isFinite()
-
copy
public BigComplex copy()
Clone this.- Specified by:
copy
in interfaceElement<BigComplex>
- Returns:
- Creates and returns a copy of this Element.
- See Also:
Object.clone()
-
copy
public BigComplex copy(BigComplex c)
Copy BigComplex element c.- Specified by:
copy
in interfaceElemFactory<BigComplex>
- Parameters:
c
- BigComplex.- Returns:
- a copy of c.
-
getZERO
public BigComplex getZERO()
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<BigComplex>
- Returns:
- 0 as BigComplex.
-
getONE
public BigComplex getONE()
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<BigComplex>
- Returns:
- 1 as BigComplex.
-
getIMAG
public BigComplex getIMAG()
Get the i element.- Returns:
- i as BigComplex.
-
isCommutative
public boolean isCommutative()
Query if this ring is commutative.- Specified by:
isCommutative
in interfaceMonoidFactory<BigComplex>
- Returns:
- true.
-
isAssociative
public boolean isAssociative()
Query if this ring is associative.- Specified by:
isAssociative
in interfaceMonoidFactory<BigComplex>
- Returns:
- true.
-
isField
public boolean isField()
Query if this ring is a field.- Specified by:
isField
in interfaceRingFactory<BigComplex>
- Returns:
- true.
-
characteristic
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<BigComplex>
- Returns:
- characteristic of this ring.
-
fromInteger
public BigComplex fromInteger(java.math.BigInteger a)
Get a BigComplex element from a BigInteger.- Specified by:
fromInteger
in interfaceElemFactory<BigComplex>
- Parameters:
a
- BigInteger.- Returns:
- a BigComplex.
-
fromInteger
public BigComplex fromInteger(long a)
Get a BigComplex element from a long.- Specified by:
fromInteger
in interfaceElemFactory<BigComplex>
- Parameters:
a
- long.- Returns:
- a BigComplex.
-
getRe
public BigRational getRe()
Get the real part.- Returns:
- re.
-
getIm
public BigRational getIm()
Get the imaginary part.- Returns:
- im.
-
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.- Specified by:
toScript
in interfaceElement<BigComplex>
- Specified by:
toScript
in interfaceElemFactory<BigComplex>
- 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<BigComplex>
- Returns:
- script compatible representation for this ElemFactory.
- See Also:
Element.toScriptFactory()
-
isCZERO
public static boolean isCZERO(BigComplex A)
Complex number zero.- Parameters:
A
- is a complex number.- Returns:
- If A is 0 then true is returned, else false.
-
isZERO
public boolean isZERO()
Is Complex number zero.- Specified by:
isZERO
in interfaceAbelianGroupElem<BigComplex>
- Returns:
- If this is 0 then true is returned, else false.
- See Also:
AbelianGroupElem.isZERO()
-
isCONE
public static boolean isCONE(BigComplex A)
Complex number one.- Parameters:
A
- is a complex number.- Returns:
- If A is 1 then true is returned, else false.
-
isONE
public boolean isONE()
Is Complex number one.- Specified by:
isONE
in interfaceMonoidElem<BigComplex>
- 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<BigComplex>
- 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.- Specified by:
equals
in interfaceElement<BigComplex>
- Overrides:
equals
in classjava.lang.Object
- Returns:
- true if this is equal to b, else false.
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Hash code for this BigComplex.- Specified by:
hashCode
in interfaceElement<BigComplex>
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashCode.
- See Also:
Object.hashCode()
-
compareTo
public int compareTo(BigComplex b)
Since complex numbers are unordered, we use lexicographical order of re and im.- Specified by:
compareTo
in interfacejava.lang.Comparable<BigComplex>
- Specified by:
compareTo
in interfaceElement<BigComplex>
- Returns:
- 0 if this is equal to b; 1 if re > b.re, or re == b.re and im > b.im; -1 if re < b.re, or re == b.re and im < b.im
-
signum
public int signum()
Since complex numbers are unordered, we use lexicographical order of re and im.- Specified by:
signum
in interfaceAbelianGroupElem<BigComplex>
- 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 BigComplex sum(BigComplex B)
Complex number summation.- Specified by:
sum
in interfaceAbelianGroupElem<BigComplex>
- Parameters:
B
- a BigComplex number.- Returns:
- this+B.
-
CSUM
public static BigComplex CSUM(BigComplex A, BigComplex B)
Complex number sum.- Parameters:
A
- and B are complex numbers.- Returns:
- A+B.
-
CDIF
public static BigComplex CDIF(BigComplex A, BigComplex B)
Complex number difference.- Parameters:
A
- and B are complex numbers.- Returns:
- A-B.
-
subtract
public BigComplex subtract(BigComplex B)
Complex number subtract.- Specified by:
subtract
in interfaceAbelianGroupElem<BigComplex>
- Parameters:
B
- a BigComplex number.- Returns:
- this-B.
-
CNEG
public static BigComplex CNEG(BigComplex A)
Complex number negative.- Parameters:
A
- is a complex number.- Returns:
- -A
-
negate
public BigComplex negate()
Complex number negative.- Specified by:
negate
in interfaceAbelianGroupElem<BigComplex>
- Returns:
- -this.
- See Also:
AbelianGroupElem.negate()
-
CCON
public static BigComplex CCON(BigComplex A)
Complex number conjugate.- Parameters:
A
- is a complex number.- Returns:
- the complex conjugate of A.
-
conjugate
public BigComplex conjugate()
Complex number conjugate.- Specified by:
conjugate
in interfaceStarRingElem<BigComplex>
- Returns:
- the complex conjugate of this.
-
norm
public BigComplex norm()
Complex number norm.- Specified by:
norm
in interfaceStarRingElem<BigComplex>
- Returns:
- ||this||.
- See Also:
StarRingElem.norm()
-
abs
public BigComplex abs()
Complex number absolute value.- Specified by:
abs
in interfaceAbelianGroupElem<BigComplex>
- Returns:
- |this|.
- See Also:
AbelianGroupElem.abs()
-
CABS
public static BigRational CABS(BigComplex A)
Complex number absolute value.- Parameters:
A
- is a complex number.- Returns:
- the absolute value of A, a rational number. Note: The square root is not jet implemented.
-
CPROD
public static BigComplex CPROD(BigComplex A, BigComplex B)
Complex number product.- Parameters:
A
- and B are complex numbers.- Returns:
- A*B.
-
multiply
public BigComplex multiply(BigComplex B)
Complex number product.- Specified by:
multiply
in interfaceMonoidElem<BigComplex>
- Parameters:
B
- is a complex number.- Returns:
- this*B.
-
CINV
public static BigComplex CINV(BigComplex A)
Complex number inverse.- Parameters:
A
- is a non-zero complex number.- Returns:
- S with S*A = 1.
-
inverse
public BigComplex inverse()
Complex number inverse.- Specified by:
inverse
in interfaceMonoidElem<BigComplex>
- Returns:
- S with S*this = 1.
- See Also:
MonoidElem.inverse()
-
remainder
public BigComplex remainder(BigComplex S)
Complex number inverse.- Specified by:
remainder
in interfaceMonoidElem<BigComplex>
- Parameters:
S
- is a complex number.- Returns:
- 0.
-
CQ
public static BigComplex CQ(BigComplex A, BigComplex B)
Complex number quotient.- Parameters:
A
- and B are complex numbers, B non-zero.- Returns:
- A/B.
-
divide
public BigComplex divide(BigComplex B)
Complex number divide.- Specified by:
divide
in interfaceMonoidElem<BigComplex>
- Parameters:
B
- is a complex number, non-zero.- Returns:
- this/B.
-
quotientRemainder
public BigComplex[] quotientRemainder(BigComplex S)
Quotient and remainder by division of this by S.- Specified by:
quotientRemainder
in interfaceMonoidElem<BigComplex>
- Parameters:
S
- a complex number- Returns:
- [this/S, this - (this/S)*S].
-
random
public BigComplex random(int n)
Complex number, random. Random rational numbers A and B are generated using random(n). Then R is the complex number with real part A and imaginary part B.- Specified by:
random
in interfaceElemFactory<BigComplex>
- Parameters:
n
- such that 0 ≤ A, B ≤ (2n-1).- Returns:
- R.
-
random
public BigComplex random(int n, java.util.Random rnd)
Complex number, random. Random rational numbers A and B are generated using random(n). Then R is the complex number with real part A and imaginary part B.- Specified by:
random
in interfaceElemFactory<BigComplex>
- Parameters:
n
- such that 0 ≤ A, B ≤ (2n-1).rnd
- is a source for random bits.- Returns:
- R.
-
CRAND
public static BigComplex CRAND(int n)
Complex number, random. Random rational numbers A and B are generated using random(n). Then R is the complex number with real part A and imaginary part B.- Parameters:
n
- such that 0 ≤ A, B ≤ (2n-1).- Returns:
- R.
-
parse
public BigComplex parse(java.lang.String s)
Parse complex number from string.- Specified by:
parse
in interfaceElemFactory<BigComplex>
- Parameters:
s
- String.- Returns:
- BigComplex from s.
-
parse
public BigComplex parse(java.io.Reader r)
Parse complex number from Reader.- Specified by:
parse
in interfaceElemFactory<BigComplex>
- Parameters:
r
- Reader.- Returns:
- next BigComplex from r.
-
gcd
public BigComplex gcd(BigComplex S)
Complex number greatest common divisor.- Specified by:
gcd
in interfaceRingElem<BigComplex>
- Parameters:
S
- BigComplex.- Returns:
- gcd(this,S).
-
egcd
public BigComplex[] egcd(BigComplex S)
BigComplex extended greatest common divisor.- Specified by:
egcd
in interfaceRingElem<BigComplex>
- Parameters:
S
- BigComplex.- Returns:
- [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).
-
bitLength
public long bitLength()
Returns the number of bits in the representation of this BigComplex, including a sign bit. It is equivalent tore.bitLength() + im.bitLength()
.)- Returns:
- number of bits in the representation of this BigComplex, including a sign bit.
-
-