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 BigComplexIThe constant i.BigRationalimImaginary part of the data structure.static BigComplexONEThe constant 1.BigRationalreReal part of the data structure.static BigComplexZEROThe 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 BigComplexabs()Complex number absolute value.longbitLength()Returns the number of bits in the representation of this BigComplex, including a sign bit.static BigRationalCABS(BigComplex A)Complex number absolute value.static BigComplexCCON(BigComplex A)Complex number conjugate.static BigComplexCDIF(BigComplex A, BigComplex B)Complex number difference.java.math.BigIntegercharacteristic()Characteristic of this ring.static BigComplexCINV(BigComplex A)Complex number inverse.static BigComplexCNEG(BigComplex A)Complex number negative.intcompareTo(BigComplex b)Since complex numbers are unordered, we use lexicographical order of re and im.BigComplexconjugate()Complex number conjugate.BigComplexcopy()Clone this.BigComplexcopy(BigComplex c)Copy BigComplex element c.static BigComplexCPROD(BigComplex A, BigComplex B)Complex number product.static BigComplexCQ(BigComplex A, BigComplex B)Complex number quotient.static BigComplexCRAND(int n)Complex number, random.static BigComplexCSUM(BigComplex A, BigComplex B)Complex number sum.BigComplexdivide(BigComplex B)Complex number divide.BigComplex[]egcd(BigComplex S)BigComplex extended greatest common divisor.booleanequals(java.lang.Object b)Comparison with any other object.BigComplexfactory()Get the corresponding element factory.BigComplexfromInteger(long a)Get a BigComplex element from a long.BigComplexfromInteger(java.math.BigInteger a)Get a BigComplex element from a BigInteger.BigComplexgcd(BigComplex S)Complex number greatest common divisor.java.util.List<BigComplex>generators()Get a list of the generating elements.BigRationalgetIm()Get the imaginary part.BigComplexgetIMAG()Get the i element.BigComplexgetONE()Get the one element.BigRationalgetRe()Get the real part.BigComplexgetZERO()Get the zero element.inthashCode()Hash code for this BigComplex.BigComplexinverse()Complex number inverse.booleanisAssociative()Query if this ring is associative.booleanisCommutative()Query if this ring is commutative.static booleanisCONE(BigComplex A)Complex number one.static booleanisCZERO(BigComplex A)Complex number zero.booleanisField()Query if this ring is a field.booleanisFinite()Is this structure finite or infinite.booleanisIMAG()Is Complex imaginary one.booleanisONE()Is Complex number one.booleanisUnit()Is Complex unit element.booleanisZERO()Is Complex number zero.BigComplexmultiply(BigComplex B)Complex number product.BigComplexnegate()Complex number negative.BigComplexnorm()Complex number norm.BigComplexparse(java.io.Reader r)Parse complex number from Reader.BigComplexparse(java.lang.String s)Parse complex number from string.BigComplex[]quotientRemainder(BigComplex S)Quotient and remainder by division of this by S.BigComplexrandom(int n)Complex number, random.BigComplexrandom(int n, java.util.Random rnd)Complex number, random.BigComplexremainder(BigComplex S)Complex number inverse.intsignum()Since complex numbers are unordered, we use lexicographical order of re and im.BigComplexsubtract(BigComplex B)Complex number subtract.BigComplexsum(BigComplex 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.-
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:
factoryin 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:
generatorsin 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:
isFinitein interfaceElemFactory<BigComplex>- Returns:
- true if this structure is finite, else false.
- See Also:
ElemFactory.isFinite()
-
copy
public BigComplex copy()
Clone this.- Specified by:
copyin 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:
copyin interfaceElemFactory<BigComplex>- Parameters:
c- BigComplex.- Returns:
- a copy of c.
-
getZERO
public BigComplex getZERO()
Get the zero element.- Specified by:
getZEROin interfaceAbelianGroupFactory<BigComplex>- Returns:
- 0 as BigComplex.
-
getONE
public BigComplex getONE()
Get the one element.- Specified by:
getONEin 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:
isCommutativein interfaceMonoidFactory<BigComplex>- Returns:
- true.
-
isAssociative
public boolean isAssociative()
Query if this ring is associative.- Specified by:
isAssociativein interfaceMonoidFactory<BigComplex>- Returns:
- true.
-
isField
public boolean isField()
Query if this ring is a field.- Specified by:
isFieldin interfaceRingFactory<BigComplex>- Returns:
- true.
-
characteristic
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristicin interfaceRingFactory<BigComplex>- Returns:
- characteristic of this ring.
-
fromInteger
public BigComplex fromInteger(java.math.BigInteger a)
Get a BigComplex element from a BigInteger.- Specified by:
fromIntegerin interfaceElemFactory<BigComplex>- Parameters:
a- BigInteger.- Returns:
- a BigComplex.
-
fromInteger
public BigComplex fromInteger(long a)
Get a BigComplex element from a long.- Specified by:
fromIntegerin 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:
toStringin classjava.lang.Object
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElement<BigComplex>- Specified by:
toScriptin 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:
toScriptFactoryin 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:
isZEROin 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:
isONEin 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:
isUnitin 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:
equalsin interfaceElement<BigComplex>- Overrides:
equalsin 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:
hashCodein interfaceElement<BigComplex>- Overrides:
hashCodein 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:
compareToin interfacejava.lang.Comparable<BigComplex>- Specified by:
compareToin 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:
signumin 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:
sumin 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:
subtractin 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:
negatein 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:
conjugatein interfaceStarRingElem<BigComplex>- Returns:
- the complex conjugate of this.
-
norm
public BigComplex norm()
Complex number norm.- Specified by:
normin interfaceStarRingElem<BigComplex>- Returns:
- ||this||.
- See Also:
StarRingElem.norm()
-
abs
public BigComplex abs()
Complex number absolute value.- Specified by:
absin 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:
multiplyin 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:
inversein interfaceMonoidElem<BigComplex>- Returns:
- S with S*this = 1.
- See Also:
MonoidElem.inverse()
-
remainder
public BigComplex remainder(BigComplex S)
Complex number inverse.- Specified by:
remainderin 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:
dividein 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:
quotientRemainderin 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:
randomin 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:
randomin 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:
parsein interfaceElemFactory<BigComplex>- Parameters:
s- String.- Returns:
- BigComplex from s.
-
parse
public BigComplex parse(java.io.Reader r)
Parse complex number from Reader.- Specified by:
parsein interfaceElemFactory<BigComplex>- Parameters:
r- Reader.- Returns:
- next BigComplex from r.
-
gcd
public BigComplex gcd(BigComplex S)
Complex number greatest common divisor.- Specified by:
gcdin interfaceRingElem<BigComplex>- Parameters:
S- BigComplex.- Returns:
- gcd(this,S).
-
egcd
public BigComplex[] egcd(BigComplex S)
BigComplex extended greatest common divisor.- Specified by:
egcdin 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.
-
-