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>
,Serializable
,Comparable<BigDecimalComplex>
public final class BigDecimalComplex
extends 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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigDecimalComplex
The constant i.final BigDecimal
Imaginary part of the data structure.private static final org.apache.logging.log4j.Logger
static final BigDecimalComplex
The constant 1.private static final Random
final BigDecimal
Real part of the data structure.static final BigDecimalComplex
The constant 0. -
Constructor Summary
ConstructorsConstructorDescriptionThe 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
(long r, long i) The constructor creates a BigDecimalComplex object from a long element as real part and the imaginary part.The constructor creates a BigDecimalComplex object from a BigComplex object.The constructor creates a BigDecimalComplex object from a BigDecimal object as real part, the imaginary part is set to 0.The constructor creates a BigDecimalComplex object from two BigDecimal objects real and imaginary part.The constructor creates a BigDecimalComplex 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 BigDecimalComplex, including a sign bit.static BigDecimal
Complex number absolute value.static BigDecimalComplex
Complex number conjugate.static BigDecimalComplex
Complex number difference.Characteristic of this ring.static BigDecimalComplex
Complex number inverse.static BigDecimalComplex
Complex number negative.int
Since complex numbers are unordered, we use lexicographical order of re and im.Complex number conjugate.copy()
Clone this.Copy BigDecimalComplex element c.static BigDecimalComplex
Complex number product.static BigDecimalComplex
Complex number quotient.static BigDecimalComplex
CRAND
(int n) Complex number, random.static BigDecimalComplex
Complex number sum.Complex number divide.BigDecimalComplex extended greatest common divisor.boolean
Comparison with any other object.factory()
Get the corresponding element factory.fromInteger
(long a) Get a BigDecimalComplex element from a long.Get a BigDecimalComplex element from a BigInteger.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 BigDecimalComplex.inverse()
Complex number inverse.boolean
Query if this ring is associative.boolean
Query if this ring is commutative.static boolean
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.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
-
BigDecimalComplex
The constructor creates a BigDecimalComplex object from two BigDecimal objects real and imaginary part.- Parameters:
r
- real part.i
- imaginary part.
-
BigDecimalComplex
public BigDecimalComplex()The constructor creates a BigDecimalComplex object with real part 0 and imaginary part 0. -
BigDecimalComplex
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(long r, long i) The constructor creates a BigDecimalComplex object from a long element as real part and the imaginary part.- Parameters:
r
- real part.i
- imaginary part.
-
BigDecimalComplex
The constructor creates a BigDecimalComplex object from a String representation.- Parameters:
s
- string of a BigDecimalComplex.- Throws:
NumberFormatException
-
BigDecimalComplex
The constructor creates a BigDecimalComplex object from a BigComplex object.- Parameters:
a
- rational BigComplex.
-
-
Method Details
-
factory
Get the corresponding element factory.- Specified by:
factory
in interfaceElement<BigDecimalComplex>
- Returns:
- factory for this Element.
- See Also:
-
generators
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<BigDecimalComplex>
- 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<BigDecimalComplex>
- Returns:
- true if this structure is finite, else false.
- See Also:
-
copy
Clone this.- Specified by:
copy
in interfaceElement<BigDecimalComplex>
- Returns:
- Creates and returns a copy of this Element.
- See Also:
-
copy
Copy BigDecimalComplex element c.- Specified by:
copy
in interfaceElemFactory<BigDecimalComplex>
- Parameters:
c
- BigDecimalComplex.- Returns:
- a copy of c.
-
getZERO
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<BigDecimalComplex>
- Returns:
- 0 as BigDecimalComplex.
-
getONE
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<BigDecimalComplex>
- Returns:
- 1 as BigDecimalComplex.
-
getIMAG
Get the i element.- Returns:
- i as BigDecimalComplex.
-
isCommutative
public boolean isCommutative()Query if this ring is commutative.- Specified by:
isCommutative
in interfaceMonoidFactory<BigDecimalComplex>
- Returns:
- true.
-
isAssociative
public boolean isAssociative()Query if this ring is associative.- Specified by:
isAssociative
in interfaceMonoidFactory<BigDecimalComplex>
- Returns:
- true.
-
isField
public boolean isField()Query if this ring is a field.- Specified by:
isField
in interfaceRingFactory<BigDecimalComplex>
- Returns:
- true.
-
characteristic
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<BigDecimalComplex>
- Returns:
- characteristic of this ring.
-
fromInteger
Get a BigDecimalComplex element from a BigInteger.- Specified by:
fromInteger
in interfaceElemFactory<BigDecimalComplex>
- Parameters:
a
- BigInteger.- Returns:
- a BigDecimalComplex.
-
fromInteger
Get a BigDecimalComplex element from a long.- Specified by:
fromInteger
in interfaceElemFactory<BigDecimalComplex>
- Parameters:
a
- long.- Returns:
- a BigDecimalComplex.
-
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<BigDecimalComplex>
- Specified by:
toScript
in interfaceElemFactory<BigDecimalComplex>
- Returns:
- script compatible representation for this Element.
- See Also:
-
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactory
in interfaceElement<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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 BigDecimalComplex.- Specified by:
hashCode
in interfaceElement<BigDecimalComplex>
- 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<BigDecimalComplex>
- Specified by:
compareTo
in interfaceElement<BigDecimalComplex>
- 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<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:
-
sum
Complex number summation.- Specified by:
sum
in interfaceAbelianGroupElem<BigDecimalComplex>
- Parameters:
B
- a BigDecimalComplex 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<BigDecimalComplex>
- Parameters:
B
- a BigDecimalComplex 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- Returns:
- the complex conjugate of this.
-
norm
Complex number norm.- Specified by:
norm
in interfaceStarRingElem<BigDecimalComplex>
- Returns:
- ||this||.
- See Also:
-
abs
Complex number absolute value.- Specified by:
abs
in interfaceAbelianGroupElem<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- Returns:
- S with S*this = 1.
- See Also:
-
remainder
Complex number inverse.- Specified by:
remainder
in interfaceMonoidElem<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- 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<BigDecimalComplex>
- Parameters:
s
- String.- Returns:
- BigDecimalComplex from s.
-
parse
Parse complex number from Reader.- Specified by:
parse
in interfaceElemFactory<BigDecimalComplex>
- Parameters:
r
- Reader.- Returns:
- next BigDecimalComplex from r.
-
gcd
Complex number greatest common divisor.- Specified by:
gcd
in interfaceRingElem<BigDecimalComplex>
- Parameters:
S
- BigDecimalComplex.- Returns:
- gcd(this,S).
-
egcd
BigDecimalComplex extended greatest common divisor.- Specified by:
egcd
in 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.
-