Package edu.jas.arith
Class BigDecimalComplex
- java.lang.Object
-
- edu.jas.arith.BigDecimalComplex
-
- All Implemented Interfaces:
AbelianGroupElem<BigDecimalComplex>,AbelianGroupFactory<BigDecimalComplex>,Element<BigDecimalComplex>,ElemFactory<BigDecimalComplex>,GcdRingElem<BigDecimalComplex>,MonoidElem<BigDecimalComplex>,MonoidFactory<BigDecimalComplex>,RingElem<BigDecimalComplex>,RingFactory<BigDecimalComplex>,StarRingElem<BigDecimalComplex>,java.io.Serializable,java.lang.Comparable<BigDecimalComplex>
public final class BigDecimalComplex extends java.lang.Object implements StarRingElem<BigDecimalComplex>, GcdRingElem<BigDecimalComplex>, RingFactory<BigDecimalComplex>
BigComplex class based on BigDecimal implementing the RingElem respectively the StarRingElem interface. Objects of this class are immutable.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static BigDecimalComplexIThe constant i.BigDecimalimImaginary part of the data structure.static BigDecimalComplexONEThe constant 1.BigDecimalreReal part of the data structure.static BigDecimalComplexZEROThe constant 0.
-
Constructor Summary
Constructors Constructor Description BigDecimalComplex()The constructor creates a BigDecimalComplex object with real part 0 and imaginary part 0.BigDecimalComplex(long r)The constructor creates a BigDecimalComplex object from a long element as real part, the imaginary part is set to 0.BigDecimalComplex(BigComplex a)The constructor creates a BigDecimalComplex object from a BigComplex object.BigDecimalComplex(BigDecimal r)The constructor creates a BigDecimalComplex object from a BigDecimal object as real part, the imaginary part is set to 0.BigDecimalComplex(BigDecimal r, BigDecimal i)The constructor creates a BigDecimalComplex object from two BigDecimal objects real and imaginary part.BigDecimalComplex(java.lang.String s)The constructor creates a BigDecimalComplex object from a String representation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BigDecimalComplexabs()Complex number absolute value.longbitLength()Returns the number of bits in the representation of this BigDecimalComplex, including a sign bit.static BigDecimalCABS(BigDecimalComplex A)Complex number absolute value.static BigDecimalComplexCCON(BigDecimalComplex A)Complex number conjugate.static BigDecimalComplexCDIF(BigDecimalComplex A, BigDecimalComplex B)Complex number difference.java.math.BigIntegercharacteristic()Characteristic of this ring.static BigDecimalComplexCINV(BigDecimalComplex A)Complex number inverse.static BigDecimalComplexCNEG(BigDecimalComplex A)Complex number negative.intcompareTo(BigDecimalComplex b)Since complex numbers are unordered, we use lexicographical order of re and im.BigDecimalComplexconjugate()Complex number conjugate.BigDecimalComplexcopy()Clone this.BigDecimalComplexcopy(BigDecimalComplex c)Copy BigDecimalComplex element c.static BigDecimalComplexCPROD(BigDecimalComplex A, BigDecimalComplex B)Complex number product.static BigDecimalComplexCQ(BigDecimalComplex A, BigDecimalComplex B)Complex number quotient.static BigDecimalComplexCRAND(int n)Complex number, random.static BigDecimalComplexCSUM(BigDecimalComplex A, BigDecimalComplex B)Complex number sum.BigDecimalComplexdivide(BigDecimalComplex B)Complex number divide.BigDecimalComplex[]egcd(BigDecimalComplex S)BigDecimalComplex extended greatest common divisor.booleanequals(java.lang.Object b)Comparison with any other object.BigDecimalComplexfactory()Get the corresponding element factory.BigDecimalComplexfromInteger(long a)Get a BigDecimalComplex element from a long.BigDecimalComplexfromInteger(java.math.BigInteger a)Get a BigDecimalComplex element from a BigInteger.BigDecimalComplexgcd(BigDecimalComplex S)Complex number greatest common divisor.java.util.List<BigDecimalComplex>generators()Get a list of the generating elements.BigDecimalgetIm()Get the imaginary part.BigDecimalComplexgetIMAG()Get the i element.BigDecimalComplexgetONE()Get the one element.BigDecimalgetRe()Get the real part.BigDecimalComplexgetZERO()Get the zero element.inthashCode()Hash code for this BigDecimalComplex.BigDecimalComplexinverse()Complex number inverse.booleanisAssociative()Query if this ring is associative.booleanisCommutative()Query if this ring is commutative.static booleanisCONE(BigDecimalComplex A)Complex number one.static booleanisCZERO(BigDecimalComplex 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.BigDecimalComplexmultiply(BigDecimalComplex B)Complex number product.BigDecimalComplexnegate()Complex number negative.BigDecimalComplexnorm()Complex number norm.BigDecimalComplexparse(java.io.Reader r)Parse complex number from Reader.BigDecimalComplexparse(java.lang.String s)Parse complex number from string.BigDecimalComplex[]quotientRemainder(BigDecimalComplex S)Quotient and remainder by division of this by S.BigDecimalComplexrandom(int n)Complex number, random.BigDecimalComplexrandom(int n, java.util.Random rnd)Complex number, random.BigDecimalComplexremainder(BigDecimalComplex S)Complex number inverse.intsignum()Since complex numbers are unordered, we use lexicographical order of re and im.BigDecimalComplexsubtract(BigDecimalComplex B)Complex number subtract.BigDecimalComplexsum(BigDecimalComplex 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 BigDecimal re
Real part of the data structure.
-
im
public final BigDecimal im
Imaginary part of the data structure.
-
ZERO
public static final BigDecimalComplex ZERO
The constant 0.
-
ONE
public static final BigDecimalComplex ONE
The constant 1.
-
I
public static final BigDecimalComplex I
The constant i.
-
-
Constructor Detail
-
BigDecimalComplex
public BigDecimalComplex(BigDecimal r, BigDecimal i)
The constructor creates a BigDecimalComplex object from two BigDecimal objects real and imaginary part.- Parameters:
r- real part.i- imaginary part.
-
BigDecimalComplex
public BigDecimalComplex(BigDecimal r)
The constructor creates a BigDecimalComplex object from a BigDecimal object as real part, the imaginary part is set to 0.- Parameters:
r- real part.
-
BigDecimalComplex
public BigDecimalComplex(long r)
The constructor creates a BigDecimalComplex object from a long element as real part, the imaginary part is set to 0.- Parameters:
r- real part.
-
BigDecimalComplex
public BigDecimalComplex()
The constructor creates a BigDecimalComplex object with real part 0 and imaginary part 0.
-
BigDecimalComplex
public BigDecimalComplex(java.lang.String s) throws java.lang.NumberFormatException
The constructor creates a BigDecimalComplex object from a String representation.- Parameters:
s- string of a BigDecimalComplex.- Throws:
java.lang.NumberFormatException
-
BigDecimalComplex
public BigDecimalComplex(BigComplex a)
The constructor creates a BigDecimalComplex object from a BigComplex object.- Parameters:
a- rational BigComplex.
-
-
Method Detail
-
factory
public BigDecimalComplex factory()
Get the corresponding element factory.- Specified by:
factoryin interfaceElement<BigDecimalComplex>- Returns:
- factory for this Element.
- See Also:
Element.factory()
-
generators
public java.util.List<BigDecimalComplex> generators()
Get a list of the generating elements.- Specified by:
generatorsin interfaceElemFactory<BigDecimalComplex>- 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<BigDecimalComplex>- Returns:
- true if this structure is finite, else false.
- See Also:
ElemFactory.isFinite()
-
copy
public BigDecimalComplex copy()
Clone this.- Specified by:
copyin interfaceElement<BigDecimalComplex>- Returns:
- Creates and returns a copy of this Element.
- See Also:
Object.clone()
-
copy
public BigDecimalComplex copy(BigDecimalComplex c)
Copy BigDecimalComplex element c.- Specified by:
copyin interfaceElemFactory<BigDecimalComplex>- Parameters:
c- BigDecimalComplex.- Returns:
- a copy of c.
-
getZERO
public BigDecimalComplex getZERO()
Get the zero element.- Specified by:
getZEROin interfaceAbelianGroupFactory<BigDecimalComplex>- Returns:
- 0 as BigDecimalComplex.
-
getONE
public BigDecimalComplex getONE()
Get the one element.- Specified by:
getONEin interfaceMonoidFactory<BigDecimalComplex>- Returns:
- 1 as BigDecimalComplex.
-
getIMAG
public BigDecimalComplex getIMAG()
Get the i element.- Returns:
- i as BigDecimalComplex.
-
isCommutative
public boolean isCommutative()
Query if this ring is commutative.- Specified by:
isCommutativein interfaceMonoidFactory<BigDecimalComplex>- Returns:
- true.
-
isAssociative
public boolean isAssociative()
Query if this ring is associative.- Specified by:
isAssociativein interfaceMonoidFactory<BigDecimalComplex>- Returns:
- true.
-
isField
public boolean isField()
Query if this ring is a field.- Specified by:
isFieldin interfaceRingFactory<BigDecimalComplex>- Returns:
- true.
-
characteristic
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristicin interfaceRingFactory<BigDecimalComplex>- Returns:
- characteristic of this ring.
-
fromInteger
public BigDecimalComplex fromInteger(java.math.BigInteger a)
Get a BigDecimalComplex element from a BigInteger.- Specified by:
fromIntegerin interfaceElemFactory<BigDecimalComplex>- Parameters:
a- BigInteger.- Returns:
- a BigDecimalComplex.
-
fromInteger
public BigDecimalComplex fromInteger(long a)
Get a BigDecimalComplex element from a long.- Specified by:
fromIntegerin interfaceElemFactory<BigDecimalComplex>- Parameters:
a- long.- Returns:
- a BigDecimalComplex.
-
getRe
public BigDecimal getRe()
Get the real part.- Returns:
- re.
-
getIm
public BigDecimal 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<BigDecimalComplex>- Specified by:
toScriptin interfaceElemFactory<BigDecimalComplex>- 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<BigDecimalComplex>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
Element.toScriptFactory()
-
isCZERO
public static boolean isCZERO(BigDecimalComplex 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<BigDecimalComplex>- Returns:
- If this is 0 then true is returned, else false.
- See Also:
AbelianGroupElem.isZERO()
-
isCONE
public static boolean isCONE(BigDecimalComplex 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<BigDecimalComplex>- 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<BigDecimalComplex>- 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<BigDecimalComplex>- 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 BigDecimalComplex.- Specified by:
hashCodein interfaceElement<BigDecimalComplex>- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashCode.
- See Also:
Object.hashCode()
-
compareTo
public int compareTo(BigDecimalComplex b)
Since complex numbers are unordered, we use lexicographical order of re and im.- Specified by:
compareToin interfacejava.lang.Comparable<BigDecimalComplex>- Specified by:
compareToin interfaceElement<BigDecimalComplex>- 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<BigDecimalComplex>- 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 BigDecimalComplex sum(BigDecimalComplex B)
Complex number summation.- Specified by:
sumin interfaceAbelianGroupElem<BigDecimalComplex>- Parameters:
B- a BigDecimalComplex number.- Returns:
- this+B.
-
CSUM
public static BigDecimalComplex CSUM(BigDecimalComplex A, BigDecimalComplex B)
Complex number sum.- Parameters:
A- and B are complex numbers.- Returns:
- A+B.
-
CDIF
public static BigDecimalComplex CDIF(BigDecimalComplex A, BigDecimalComplex B)
Complex number difference.- Parameters:
A- and B are complex numbers.- Returns:
- A-B.
-
subtract
public BigDecimalComplex subtract(BigDecimalComplex B)
Complex number subtract.- Specified by:
subtractin interfaceAbelianGroupElem<BigDecimalComplex>- Parameters:
B- a BigDecimalComplex number.- Returns:
- this-B.
-
CNEG
public static BigDecimalComplex CNEG(BigDecimalComplex A)
Complex number negative.- Parameters:
A- is a complex number.- Returns:
- -A
-
negate
public BigDecimalComplex negate()
Complex number negative.- Specified by:
negatein interfaceAbelianGroupElem<BigDecimalComplex>- Returns:
- -this.
- See Also:
AbelianGroupElem.negate()
-
CCON
public static BigDecimalComplex CCON(BigDecimalComplex A)
Complex number conjugate.- Parameters:
A- is a complex number.- Returns:
- the complex conjugate of A.
-
conjugate
public BigDecimalComplex conjugate()
Complex number conjugate.- Specified by:
conjugatein interfaceStarRingElem<BigDecimalComplex>- Returns:
- the complex conjugate of this.
-
norm
public BigDecimalComplex norm()
Complex number norm.- Specified by:
normin interfaceStarRingElem<BigDecimalComplex>- Returns:
- ||this||.
- See Also:
StarRingElem.norm()
-
abs
public BigDecimalComplex abs()
Complex number absolute value.- Specified by:
absin interfaceAbelianGroupElem<BigDecimalComplex>- Returns:
- |this|.
- See Also:
AbelianGroupElem.abs()
-
CABS
public static BigDecimal CABS(BigDecimalComplex 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 BigDecimalComplex CPROD(BigDecimalComplex A, BigDecimalComplex B)
Complex number product.- Parameters:
A- and B are complex numbers.- Returns:
- A*B.
-
multiply
public BigDecimalComplex multiply(BigDecimalComplex B)
Complex number product.- Specified by:
multiplyin interfaceMonoidElem<BigDecimalComplex>- Parameters:
B- is a complex number.- Returns:
- this*B.
-
CINV
public static BigDecimalComplex CINV(BigDecimalComplex A)
Complex number inverse.- Parameters:
A- is a non-zero complex number.- Returns:
- S with S*A = 1.
-
inverse
public BigDecimalComplex inverse()
Complex number inverse.- Specified by:
inversein interfaceMonoidElem<BigDecimalComplex>- Returns:
- S with S*this = 1.
- See Also:
MonoidElem.inverse()
-
remainder
public BigDecimalComplex remainder(BigDecimalComplex S)
Complex number inverse.- Specified by:
remainderin interfaceMonoidElem<BigDecimalComplex>- Parameters:
S- is a complex number.- Returns:
- 0.
-
CQ
public static BigDecimalComplex CQ(BigDecimalComplex A, BigDecimalComplex B)
Complex number quotient.- Parameters:
A- and B are complex numbers, B non-zero.- Returns:
- A/B.
-
divide
public BigDecimalComplex divide(BigDecimalComplex B)
Complex number divide.- Specified by:
dividein interfaceMonoidElem<BigDecimalComplex>- Parameters:
B- is a complex number, non-zero.- Returns:
- this/B.
-
quotientRemainder
public BigDecimalComplex[] quotientRemainder(BigDecimalComplex S)
Quotient and remainder by division of this by S.- Specified by:
quotientRemainderin interfaceMonoidElem<BigDecimalComplex>- Parameters:
S- a complex number- Returns:
- [this/S, this - (this/S)*S].
-
random
public BigDecimalComplex 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<BigDecimalComplex>- Parameters:
n- such that 0 ≤ A, B ≤ (2n-1).- Returns:
- R.
-
random
public BigDecimalComplex 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<BigDecimalComplex>- Parameters:
n- such that 0 ≤ A, B ≤ (2n-1).rnd- is a source for random bits.- Returns:
- R.
-
CRAND
public static BigDecimalComplex 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 BigDecimalComplex parse(java.lang.String s)
Parse complex number from string.- Specified by:
parsein interfaceElemFactory<BigDecimalComplex>- Parameters:
s- String.- Returns:
- BigDecimalComplex from s.
-
parse
public BigDecimalComplex parse(java.io.Reader r)
Parse complex number from Reader.- Specified by:
parsein interfaceElemFactory<BigDecimalComplex>- Parameters:
r- Reader.- Returns:
- next BigDecimalComplex from r.
-
gcd
public BigDecimalComplex gcd(BigDecimalComplex S)
Complex number greatest common divisor.- Specified by:
gcdin interfaceRingElem<BigDecimalComplex>- Parameters:
S- BigDecimalComplex.- Returns:
- gcd(this,S).
-
egcd
public BigDecimalComplex[] egcd(BigDecimalComplex S)
BigDecimalComplex extended greatest common divisor.- Specified by:
egcdin interfaceRingElem<BigDecimalComplex>- Parameters:
S- BigDecimalComplex.- 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 BigDecimalComplex, including a sign bit. It is equivalent tore.bitLength() + im.bitLength().)- Returns:
- number of bits in the representation of this BigDecimalComplex, including a sign bit.
-
-