vmm.core
Class Complex

java.lang.Object
  extended by vmm.core.Complex

public class Complex
extends java.lang.Object

A complex number, with a real and an imaginary part. (Possibley to be replaced with a class that has better support for complex arithmetic and functions of a complex variable.)


Field Summary
static Complex I_C
           
 double im
           
static Complex ONE_C
           
 double re
           
static Complex ZERO_C
           
 
Constructor Summary
Complex()
          Create a complex number initially equal to zero
Complex(Complex c)
          Create a new complex number that is initially equal to a given complex number.
Complex(double x)
          Create a complex number initially equal to the real number x.
Complex(double x, double y)
          Create a complex number initially equal to x + iy
 
Method Summary
 double abs2()
          Returns the absolute value squared of this.
 void assign_PlusTimes(Complex a, Complex b)
           
 void assign_PlusTimes(Complex a, double d)
           
 void assign(Complex c)
           
 void assign(double x, double y)
           
 void assignDivide(Complex c)
           
 void assignInvert()
           
 void assignMinus(Complex c)
           
 void assignPlus(Complex c)
           
 void assignPlus(Complex a, Complex b)
           
 void assignPlusTimes(Complex a, Complex b)
           
 void assignPow(Complex z, double x)
           
 void assignTimes_PlusTimes(Complex a, Complex b, double d)
           
 void assignTimes(Complex c)
           
 void assignTimes(Complex a, Complex b)
           
 void assignTimes(Complex c, double d)
           
 void assignTimes(double d)
           
 void assignTimesPlus(Complex a, Complex b)
           
 void assignTimesTimes(Complex a, double d)
           
 Complex complexLinComb(Complex a, Complex b, Complex c)
          z.complexLinComb(a,b,c) returns a*z+b*c, Complex a,b;
 Complex conj()
          Computes the conjugate of a complex number.
 double cosh(double x)
           
 double det(Complex c)
           
 Complex dividedBy(Complex c)
          Returns this / c; c must be non-null.
 Complex dividedBy(double x)
           
 double dot(Complex c)
          z.dot(c) returns the scalar product z.re*c.re + z.im*c.im
 boolean equals(java.lang.Object obj)
          Returns true if obj is equal to this complex number.
 Complex exponential()
          Computes the complex exponential function, e^z, where z is this complex number.
 Complex integerPower(int k)
          Returns new Complex(this^k), for |k|< 9 using multiplication, for larger |k| using exp(k*log(this))
 Complex integerRoot(int k)
          Returns a complex k-th root of this complex number.
 Complex inverse()
          Computes the complex reciprocal function, 1/z, where z is this complex number.
 Complex invert()
           
 Complex log()
           
 Complex logNearer(Complex previous)
          Computes that complex logarithm of this complex number that is nearest to previous.
 Complex minus(Complex c)
          Returns this - c; c must be non-null.
 Complex minus(double x)
           
 Complex mobius1_1(double r)
          The Moebius transformation ((1+r)z + r)/(rz + 1+r) has +1,-1 as fixed points.
 Complex plus(Complex c)
          Returns this + c; c must be non-null.
 Complex plus(double x)
           
static Complex polar(double r, double theta)
          Returns the complex number (r*cos(theta)) + i*(r*sin(theta)).
 Complex power(double x)
           
 double r()
          Returns the absolute value, "r" in polar coordinates, of this.
 Complex realLinComb(double a, double b, Complex c)
          z.realLinComb(a,b,c) returns a*z+b*c, double a,b;
 Complex sine()
           
 double sinh(double x)
           
 Complex squareRootNearer(Complex previous)
          Computes that square root of this complex number that is nearer to previous than to minus previous.
 double[] stereographicProjection()
           
 double theta()
          Returns arg(this), the angular polar coordinate of this complex number, in the range -pi to pi.
 Complex times(Complex c)
          Returns this * c; c must be non-null.
 Complex times(double x)
           
 java.lang.String toString()
          Returns a string representation of the form a, i, -i, i*b, -i*b, a + i, a - i, a + i*b, or a - i*b.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO_C

public static final Complex ZERO_C

ONE_C

public static final Complex ONE_C

I_C

public static final Complex I_C

re

public double re

im

public double im
Constructor Detail

Complex

public Complex()
Create a complex number initially equal to zero


Complex

public Complex(double x)
Create a complex number initially equal to the real number x.


Complex

public Complex(double x,
               double y)
Create a complex number initially equal to x + iy


Complex

public Complex(Complex c)
Create a new complex number that is initially equal to a given complex number.

Parameters:
c - The complex number to be copied. If null, it is treated as zero.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Returns true if obj is equal to this complex number. If obj is null or is not of type Complex, the return value is false.

Overrides:
equals in class java.lang.Object

conj

public Complex conj()
Computes the conjugate of a complex number.


polar

public static Complex polar(double r,
                            double theta)
Returns the complex number (r*cos(theta)) + i*(r*sin(theta)).


plus

public Complex plus(Complex c)
Returns this + c; c must be non-null.


minus

public Complex minus(Complex c)
Returns this - c; c must be non-null.


times

public Complex times(Complex c)
Returns this * c; c must be non-null.


dividedBy

public Complex dividedBy(Complex c)
Returns this / c; c must be non-null.


times

public Complex times(double x)

plus

public Complex plus(double x)

minus

public Complex minus(double x)

dividedBy

public Complex dividedBy(double x)

realLinComb

public Complex realLinComb(double a,
                           double b,
                           Complex c)
z.realLinComb(a,b,c) returns a*z+b*c, double a,b;


complexLinComb

public Complex complexLinComb(Complex a,
                              Complex b,
                              Complex c)
z.complexLinComb(a,b,c) returns a*z+b*c, Complex a,b;


dot

public double dot(Complex c)
z.dot(c) returns the scalar product z.re*c.re + z.im*c.im


abs2

public double abs2()
Returns the absolute value squared of this.

Returns:
real part squared plus imaginary part squared

r

public double r()
Returns the absolute value, "r" in polar coordinates, of this.

Returns:
the square root of (real part squared plus imaginary part squared)

theta

public double theta()
Returns arg(this), the angular polar coordinate of this complex number, in the range -pi to pi. The return value is simply Math.atan2(imaginary part, real part).


exponential

public Complex exponential()
Computes the complex exponential function, e^z, where z is this complex number.


inverse

public Complex inverse()
Computes the complex reciprocal function, 1/z, where z is this complex number.


log

public Complex log()

logNearer

public Complex logNearer(Complex previous)
Computes that complex logarithm of this complex number that is nearest to previous. A test code is in fractals.TestAnalyticContinuation.


sinh

public double sinh(double x)

cosh

public double cosh(double x)

sine

public Complex sine()

power

public Complex power(double x)

integerPower

public Complex integerPower(int k)
Returns new Complex(this^k), for |k|< 9 using multiplication, for larger |k| using exp(k*log(this))


integerRoot

public Complex integerRoot(int k)
Returns a complex k-th root of this complex number. The root that is returned is the one with the smallest positive arg. (If k is 0, the return value is 1. If k is negative, the value is 1/integerRoot(-k).)


squareRootNearer

public Complex squareRootNearer(Complex previous)
Computes that square root of this complex number that is nearer to previous than to minus previous. A test code is in fractals.TestAnalyticContinuation.


mobius1_1

public Complex mobius1_1(double r)
The Moebius transformation ((1+r)z + r)/(rz + 1+r) has +1,-1 as fixed points. It maps the real line and the unit circle to itsself


stereographicProjection

public double[] stereographicProjection()

assign

public void assign(double x,
                   double y)

toString

public java.lang.String toString()
Returns a string representation of the form a, i, -i, i*b, -i*b, a + i, a - i, a + i*b, or a - i*b. (Except when the real or imaginary part is undefined or infinite, the form is "(re) + i*(im)" where NaN, +INF, and -INF are used to indicate undefined and infinite values.)

Overrides:
toString in class java.lang.Object

assign

public void assign(Complex c)

det

public double det(Complex c)

assignTimes

public void assignTimes(double d)

assignInvert

public void assignInvert()

assignPow

public void assignPow(Complex z,
                      double x)

assignPlus

public void assignPlus(Complex a,
                       Complex b)

assignPlus

public void assignPlus(Complex c)

assignMinus

public void assignMinus(Complex c)

assignTimes

public void assignTimes(Complex c,
                        double d)

assignTimes

public void assignTimes(Complex c)

assignTimes

public void assignTimes(Complex a,
                        Complex b)

assignDivide

public void assignDivide(Complex c)

assignTimesTimes

public void assignTimesTimes(Complex a,
                             double d)

assignPlusTimes

public void assignPlusTimes(Complex a,
                            Complex b)

assignTimesPlus

public void assignTimesPlus(Complex a,
                            Complex b)

assign_PlusTimes

public void assign_PlusTimes(Complex a,
                             Complex b)

assign_PlusTimes

public void assign_PlusTimes(Complex a,
                             double d)

assignTimes_PlusTimes

public void assignTimes_PlusTimes(Complex a,
                                  Complex b,
                                  double d)

invert

public Complex invert()