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 BigComplexThe constant i.final BigRationalImaginary part of the data structure.private static final org.apache.logging.log4j.Loggerstatic final BigComplexThe constant 1.private static final Randomfinal BigRationalReal part of the data structure.static final BigComplexThe 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.longReturns 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.Characteristic of this ring.static BigComplexCINV(BigComplex A) Complex number inverse.static BigComplexCNEG(BigComplex A) Complex number negative.intSince 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 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.divide(BigComplex B) Complex number divide.egcd(BigComplex S) BigComplex extended greatest common divisor.booleanComparison 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.inthashCode()Hash code for this BigComplex.inverse()Complex number inverse.booleanQuery if this ring is associative.booleanQuery if this ring is commutative.static booleanisCONE(BigComplex A) Complex number one.static booleanComplex 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.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.intsignum()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 interface ElemFactory
valueOfMethods inherited from interface 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:
factoryin interfaceElement<BigComplex>- Returns:
- factory for this Element.
- See Also:
-
generators
Get a list of the generating elements.- Specified by:
generatorsin interfaceElemFactory<BigComplex>- Returns:
- list of generators for the algebraic structure.
- See Also:
-
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:
-
copy
Clone this.- Specified by:
copyin interfaceElement<BigComplex>- Returns:
- Creates and returns a copy of this Element.
- See Also:
-
copy
Copy BigComplex element c.- Specified by:
copyin interfaceElemFactory<BigComplex>- Parameters:
c- BigComplex.- Returns:
- a copy of c.
-
getZERO
Get the zero element.- Specified by:
getZEROin interfaceAbelianGroupFactory<BigComplex>- Returns:
- 0 as BigComplex.
-
getONE
Get the one element.- Specified by:
getONEin interfaceMonoidFactory<BigComplex>- Returns:
- 1 as BigComplex.
-
getIMAG
-
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
Characteristic of this ring.- Specified by:
characteristicin interfaceRingFactory<BigComplex>- Returns:
- characteristic of this ring.
-
fromInteger
Get a BigComplex element from a BigInteger.- Specified by:
fromIntegerin interfaceElemFactory<BigComplex>- Parameters:
a- BigInteger.- Returns:
- a BigComplex.
-
fromInteger
Get a BigComplex element from a long.- Specified by:
fromIntegerin interfaceElemFactory<BigComplex>- Parameters:
a- long.- Returns:
- a BigComplex.
-
getRe
-
getIm
-
toString
-
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:
-
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactoryin 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:
isZEROin 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:
isONEin 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:
isUnitin interfaceMonoidElem<BigComplex>- Returns:
- If this is a unit then true is returned, else false.
- See Also:
-
equals
-
hashCode
public int hashCode()Hash code for this BigComplex.- Specified by:
hashCodein interfaceElement<BigComplex>- Overrides:
hashCodein classObject- Returns:
- the hashCode.
- See Also:
-
compareTo
Since complex numbers are unordered, we use lexicographical order of re and im.- Specified by:
compareToin interfaceComparable<BigComplex>- Specified by:
compareToin 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:
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:
-
sum
Complex number summation.- Specified by:
sumin 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:
subtractin 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:
negatein 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:
conjugatein interfaceStarRingElem<BigComplex>- Returns:
- the complex conjugate of this.
-
norm
Complex number norm.- Specified by:
normin interfaceStarRingElem<BigComplex>- Returns:
- ||this||.
- See Also:
-
abs
Complex number absolute value.- Specified by:
absin 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:
multiplyin 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:
inversein interfaceMonoidElem<BigComplex>- Returns:
- S with S*this = 1.
- See Also:
-
remainder
Complex number inverse.- Specified by:
remainderin 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:
dividein 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:
quotientRemainderin 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:
randomin 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:
randomin 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:
parsein interfaceElemFactory<BigComplex>- Parameters:
s- String.- Returns:
- BigComplex from s.
-
parse
Parse complex number from Reader.- Specified by:
parsein interfaceElemFactory<BigComplex>- Parameters:
r- Reader.- Returns:
- next BigComplex from r.
-
gcd
Complex number greatest common divisor.- Specified by:
gcdin interfaceRingElem<BigComplex>- Parameters:
S- BigComplex.- Returns:
- gcd(this,S).
-
egcd
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.
-