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>
,Serializable
,Comparable<BigComplex>
public final class BigComplex
extends 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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigComplex
The constant i.final BigRational
Imaginary part of the data structure.private static final org.apache.logging.log4j.Logger
static final BigComplex
The constant 1.private static final Random
final BigRational
Real part of the data structure.static final BigComplex
The constant 0. -
Constructor Summary
ConstructorsConstructorDescriptionThe 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.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
(String s) The constructor creates a BigComplex object from a String representation. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Complex number absolute value.long
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.Characteristic of this ring.static BigComplex
CINV
(BigComplex A) Complex number inverse.static BigComplex
CNEG
(BigComplex A) Complex number negative.int
Since complex numbers are unordered, we use lexicographical order of re and im.Complex number conjugate.copy()
Clone this.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.divide
(BigComplex B) Complex number divide.egcd
(BigComplex S) BigComplex extended greatest common divisor.boolean
Comparison with any other object.factory()
Get the corresponding element factory.fromInteger
(long a) Get a BigComplex element from a long.Get a BigComplex element from a BigInteger.gcd
(BigComplex S) Complex number greatest common divisor.Get a list of the generating elements.getIm()
Get the imaginary part.getIMAG()
Get the i element.getONE()
Get the one element.getRe()
Get the real part.getZERO()
Get the zero element.int
hashCode()
Hash code for this BigComplex.inverse()
Complex number inverse.boolean
Query if this ring is associative.boolean
Query if this ring is commutative.static boolean
isCONE
(BigComplex A) Complex number one.static boolean
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.Complex number product.negate()
Complex number negative.norm()
Complex number norm.Parse complex number from Reader.Parse complex number from string.Quotient and remainder by division of this by S.random
(int n) Complex number, random.Complex number, random.Complex number inverse.int
signum()
Since complex numbers are unordered, we use lexicographical order of re and im.Complex number subtract.sum
(BigComplex B) 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, 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 Details
-
re
Real part of the data structure. -
im
Imaginary part of the data structure. -
random
-
logger
private static final org.apache.logging.log4j.Logger logger -
ZERO
The constant 0. -
ONE
The constant 1. -
I
The constant i.
-
-
Constructor Details
-
BigComplex
The constructor creates a BigComplex object from two BigRational objects real and imaginary part.- Parameters:
r
- real part.i
- imaginary part.
-
BigComplex
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
The constructor creates a BigComplex object from a String representation.- Parameters:
s
- string of a BigComplex.- Throws:
NumberFormatException
-
-
Method Details
-
factory
Get the corresponding element factory.- Specified by:
factory
in interfaceElement<BigComplex>
- Returns:
- factory for this Element.
- See Also:
-
generators
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<BigComplex>
- Returns:
- list of generators for the algebraic structure.
- See Also:
-
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:
-
copy
Clone this.- Specified by:
copy
in interfaceElement<BigComplex>
- Returns:
- Creates and returns a copy of this Element.
- See Also:
-
copy
Copy BigComplex element c.- Specified by:
copy
in interfaceElemFactory<BigComplex>
- Parameters:
c
- BigComplex.- Returns:
- a copy of c.
-
getZERO
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<BigComplex>
- Returns:
- 0 as BigComplex.
-
getONE
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<BigComplex>
- Returns:
- 1 as 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
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<BigComplex>
- Returns:
- characteristic of this ring.
-
fromInteger
Get a BigComplex element from a BigInteger.- Specified by:
fromInteger
in interfaceElemFactory<BigComplex>
- Parameters:
a
- BigInteger.- Returns:
- a BigComplex.
-
fromInteger
Get a BigComplex element from a long.- Specified by:
fromInteger
in interfaceElemFactory<BigComplex>
- Parameters:
a
- long.- Returns:
- a BigComplex.
-
getRe
Get the real part.- Returns:
- re.
-
getIm
Get the imaginary part.- Returns:
- im.
-
toString
Get the String representation. -
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:
-
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:
-
isCZERO
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:
-
isCONE
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:
-
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:
-
equals
Comparison with any other object.- Specified by:
equals
in interfaceElement<BigComplex>
- Overrides:
equals
in classObject
- Parameters:
b
-- Returns:
- true if this is equal to b, else false.
- See Also:
-
hashCode
public int hashCode()Hash code for this BigComplex.- Specified by:
hashCode
in interfaceElement<BigComplex>
- Overrides:
hashCode
in classObject
- Returns:
- the hashCode.
- See Also:
-
compareTo
Since complex numbers are unordered, we use lexicographical order of re and im.- Specified by:
compareTo
in interfaceComparable<BigComplex>
- Specified by:
compareTo
in interfaceElement<BigComplex>
- Parameters:
b
-- 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:
-
sum
Complex number summation.- Specified by:
sum
in interfaceAbelianGroupElem<BigComplex>
- Parameters:
B
- a BigComplex number.- Returns:
- this+B.
-
CSUM
Complex number sum.- Parameters:
A
- and B are complex numbers.- Returns:
- A+B.
-
CDIF
Complex number difference.- Parameters:
A
- and B are complex numbers.- Returns:
- A-B.
-
subtract
Complex number subtract.- Specified by:
subtract
in interfaceAbelianGroupElem<BigComplex>
- Parameters:
B
- a BigComplex number.- Returns:
- this-B.
-
CNEG
Complex number negative.- Parameters:
A
- is a complex number.- Returns:
- -A
-
negate
Complex number negative.- Specified by:
negate
in interfaceAbelianGroupElem<BigComplex>
- Returns:
- -this.
- See Also:
-
CCON
Complex number conjugate.- Parameters:
A
- is a complex number.- Returns:
- the complex conjugate of A.
-
conjugate
Complex number conjugate.- Specified by:
conjugate
in interfaceStarRingElem<BigComplex>
- Returns:
- the complex conjugate of this.
-
norm
Complex number norm.- Specified by:
norm
in interfaceStarRingElem<BigComplex>
- Returns:
- ||this||.
- See Also:
-
abs
Complex number absolute value.- Specified by:
abs
in interfaceAbelianGroupElem<BigComplex>
- Returns:
- |this|.
- See Also:
-
CABS
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
Complex number product.- Parameters:
A
- and B are complex numbers.- Returns:
- A*B.
-
multiply
Complex number product.- Specified by:
multiply
in interfaceMonoidElem<BigComplex>
- Parameters:
B
- is a complex number.- Returns:
- this*B.
-
CINV
Complex number inverse.- Parameters:
A
- is a non-zero complex number.- Returns:
- S with S*A = 1.
-
inverse
Complex number inverse.- Specified by:
inverse
in interfaceMonoidElem<BigComplex>
- Returns:
- S with S*this = 1.
- See Also:
-
remainder
Complex number inverse.- Specified by:
remainder
in interfaceMonoidElem<BigComplex>
- Parameters:
S
- is a complex number.- Returns:
- 0.
-
CQ
Complex number quotient.- Parameters:
A
- and B are complex numbers, B non-zero.- Returns:
- A/B.
-
divide
Complex number divide.- Specified by:
divide
in interfaceMonoidElem<BigComplex>
- Parameters:
B
- is a complex number, non-zero.- Returns:
- this/B.
-
quotientRemainder
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
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
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
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
Parse complex number from string.- Specified by:
parse
in interfaceElemFactory<BigComplex>
- Parameters:
s
- String.- Returns:
- BigComplex from s.
-
parse
Parse complex number from Reader.- Specified by:
parse
in interfaceElemFactory<BigComplex>
- Parameters:
r
- Reader.- Returns:
- next BigComplex from r.
-
gcd
Complex number greatest common divisor.- Specified by:
gcd
in interfaceRingElem<BigComplex>
- Parameters:
S
- BigComplex.- Returns:
- gcd(this,S).
-
egcd
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.
-