edu.jas.arith
Class BigComplex

java.lang.Object
  extended by 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.Cloneable, 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 interface and with the familiar SAC static method names. Objects of this class are immutable.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
static BigComplex I
          The constant i.
protected  BigRational im
          Imaginary part of the data structure.
static BigComplex ONE
          The constant 1.
protected  BigRational re
          Real part of the data structure.
static BigComplex ZERO
          The constant 0.
 
Constructor Summary
BigComplex()
          The constructor creates a BigComplex object with real part 0 and imaginary part 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(long r)
          The constructor creates a BigComplex object from a long element as real part, the imaginary part is set to 0.
BigComplex(java.lang.String s)
          The constructor creates a BigComplex object from a String representation.
 
Method Summary
 BigComplex abs()
          Complex number absolute value.
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.
 java.math.BigInteger characteristic()
          Characteristic of this ring.
static BigComplex CINV(BigComplex A)
          Complex number inverse.
 BigComplex clone()
          Clone this.
static BigComplex CNEG(BigComplex A)
          Complex number negative.
 int compareTo(BigComplex b)
          Since complex numbers are unordered, we use lexicographical order of re and im.
 BigComplex conjugate()
          Complex number conjugate.
 BigComplex 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.
 BigComplex divide(BigComplex B)
          Complex number divide.
 BigComplex[] egcd(BigComplex S)
          BigComplex extended greatest common divisor.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 BigComplex factory()
          Get the corresponding element factory.
 BigComplex fromInteger(java.math.BigInteger a)
          Get a BigComplex element from a BigInteger.
 BigComplex fromInteger(long a)
          Get a BigComplex element from a long.
 BigComplex gcd(BigComplex S)
          Complex number greatest common divisor.
 java.util.List<BigComplex> generators()
          Get a list of the generating elements.
 BigRational getIm()
          Get the imaginary part.
 BigComplex getIMAG()
          Get the i element.
 BigComplex getONE()
          Get the one element.
 BigRational getRe()
          Get the real part.
 BigComplex getZERO()
          Get the zero element.
 int hashCode()
          Hash code for this BigComplex.
 BigComplex inverse()
          Complex number inverse.
 boolean isAssociative()
          Query if this ring is associative.
 boolean isCommutative()
          Query if this ring is commutative.
static boolean isCONE(BigComplex A)
          Complex number one.
static boolean isCZERO(BigComplex A)
          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.
 BigComplex multiply(BigComplex B)
          Complex number product.
 BigComplex negate()
          Complex number negative.
 BigComplex norm()
          Complex number norm.
 BigComplex parse(java.io.Reader r)
          Parse complex number from Reader.
 BigComplex parse(java.lang.String s)
          Parse complex number from string.
 BigComplex random(int n)
          Complex number, random.
 BigComplex random(int n, java.util.Random rnd)
          Complex number, random.
 BigComplex remainder(BigComplex S)
          Complex number inverse.
 int signum()
          Since complex numbers are unordered, we use lexicographical order of re and im.
 BigComplex subtract(BigComplex B)
          Complex number subtract.
 BigComplex sum(BigComplex B)
          Complex number summation.
 java.lang.String toScript()
          Get a scripting compatible string representation.
 java.lang.String toScriptFactory()
          Get a scripting compatible string representation of the factory.
 java.lang.String toString()
          Get the String representation.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

re

protected final BigRational re
Real part of the data structure.


im

protected 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:
factory in interface Element<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:
generators in interface ElemFactory<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:
isFinite in interface ElemFactory<BigComplex>
Returns:
true if this structure is finite, else false.
See Also:
ElemFactory.isFinite()

clone

public BigComplex clone()
Clone this.

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

copy

public BigComplex copy(BigComplex c)
Copy BigComplex element c.

Specified by:
copy in interface ElemFactory<BigComplex>
Parameters:
c - BigComplex.
Returns:
a copy of c.

getZERO

public BigComplex getZERO()
Get the zero element.

Specified by:
getZERO in interface AbelianGroupFactory<BigComplex>
Returns:
0 as BigComplex.

getONE

public BigComplex getONE()
Get the one element.

Specified by:
getONE in interface MonoidFactory<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:
isCommutative in interface MonoidFactory<BigComplex>
Returns:
true.

isAssociative

public boolean isAssociative()
Query if this ring is associative.

Specified by:
isAssociative in interface MonoidFactory<BigComplex>
Returns:
true.

isField

public boolean isField()
Query if this ring is a field.

Specified by:
isField in interface RingFactory<BigComplex>
Returns:
true.

characteristic

public java.math.BigInteger characteristic()
Characteristic of this ring.

Specified by:
characteristic in interface RingFactory<BigComplex>
Returns:
characteristic of this ring.

fromInteger

public BigComplex fromInteger(java.math.BigInteger a)
Get a BigComplex element from a BigInteger.

Specified by:
fromInteger in interface ElemFactory<BigComplex>
Parameters:
a - BigInteger.
Returns:
a BigComplex.

fromInteger

public BigComplex fromInteger(long a)
Get a BigComplex element from a long.

Specified by:
fromInteger in interface ElemFactory<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:
toString in class java.lang.Object

toScript

public java.lang.String toScript()
Get a scripting compatible string representation.

Specified by:
toScript in interface Element<BigComplex>
Specified by:
toScript in interface ElemFactory<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:
toScriptFactory in interface Element<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:
isZERO in interface AbelianGroupElem<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:
isONE in interface MonoidElem<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:
isUnit in interface MonoidElem<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:
equals in interface Element<BigComplex>
Overrides:
equals in class java.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:
hashCode in interface Element<BigComplex>
Overrides:
hashCode in class java.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:
compareTo in interface Element<BigComplex>
Specified by:
compareTo in interface java.lang.Comparable<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:
signum in interface AbelianGroupElem<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:
sum in interface AbelianGroupElem<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:
subtract in interface AbelianGroupElem<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:
negate in interface AbelianGroupElem<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:
conjugate in interface StarRingElem<BigComplex>
Returns:
the complex conjugate of this.

norm

public BigComplex norm()
Complex number norm.

Specified by:
norm in interface StarRingElem<BigComplex>
Returns:
||this||.
See Also:
StarRingElem.norm()

abs

public BigComplex abs()
Complex number absolute value.

Specified by:
abs in interface AbelianGroupElem<BigComplex>
Returns:
|this|^2. Note: The square root is not jet implemented.
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:
multiply in interface MonoidElem<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:
inverse in interface MonoidElem<BigComplex>
Returns:
S with S*this = 1.
See Also:
MonoidElem.inverse()

remainder

public BigComplex remainder(BigComplex S)
Complex number inverse.

Specified by:
remainder in interface MonoidElem<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:
divide in interface MonoidElem<BigComplex>
Parameters:
B - is a complex number, non-zero.
Returns:
this/B.

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:
random in interface ElemFactory<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:
random in interface ElemFactory<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:
parse in interface ElemFactory<BigComplex>
Parameters:
s - String.
Returns:
BigComplex from s.

parse

public BigComplex parse(java.io.Reader r)
Parse complex number from Reader.

Specified by:
parse in interface ElemFactory<BigComplex>
Parameters:
r - Reader.
Returns:
next BigComplex from r.

gcd

public BigComplex gcd(BigComplex S)
Complex number greatest common divisor.

Specified by:
gcd in interface RingElem<BigComplex>
Parameters:
S - BigComplex.
Returns:
gcd(this,S).

egcd

public BigComplex[] egcd(BigComplex S)
BigComplex extended greatest common divisor.

Specified by:
egcd in interface RingElem<BigComplex>
Parameters:
S - BigComplex.
Returns:
[ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).