JIGL
v1.6

jigl.math
Class Complex

java.lang.Object
  |
  +--java.lang.Number
        |
        +--jigl.math.Complex
All Implemented Interfaces:
Serializable

public class Complex
extends Number

Complex Number Operations. For desciptions of these operations, see Complex Functions.

See Also:
Serialized Form

Field Summary
protected  float x
          the real part of the Complex number
protected  float y
          imaginary part of the Complex number
 
Fields inherited from class java.lang.Number
 
Constructor Summary
Complex()
          Sets the real and imaginary part of the complex number to zero
Complex(Complex z)
          Initilizes the complex number to z
Complex(double a, double b)
          Initilizes the real and imaginary part to a and b repectively
 
Method Summary
 Complex add(Complex z)
          Adds this complex number to another complex number.
static Complex add(Complex z1, Complex z2)
          Adds two complex numbers
 Complex add(double a)
          Adds a constant to the real part of this complex number.
 double arg()
          Returns the phase of the complex number.Converts rectangular coordinates (x, y) to polar (r, theta).
 Complex conj()
          Performs the conjuction function on the complex number
 Complex cos()
          Returns the cosine of this complex number.
 Complex cosh()
          Returns the hyperbolic cosine of this complex number.
 Complex div(Complex z)
          Divides this complex number by z (z shouldn't be 0).
static Complex div(Complex z1, Complex z2)
          Divides two complex numbers
 Complex div(double a)
          Divides this complex number by a constant a(a shouldn't be 0).
 double doubleValue()
          Returns the double value of this complex number
 boolean equals(Complex z)
          Compares this complex number to another Complex number
 Complex exp()
          Returns the result of e^(x+y*i) = e^x * e^(i*y) = e^x*(cos(y) + sin(y)).
 float floatValue()
          Returns the float value of this complex number
 double imag()
          Return the imaginary part of the imaginary number
 double imag(double a)
          Sets the imaginary part of the complex number and returns old value
 int intValue()
          Returns the integer value of this complex number
(package private)  Complex j1mult()
          Returns a complex number with the negative of this complex number's real part
(package private)  Complex j2mult()
          Returns a complex number with the negative of this complex number's real and imaginary part
(package private)  Complex j3mult()
          Returns a complex number with the negative of this complex number's imaginary part
 Complex log()
          Returns the result of ln(x+y*i) = ln(r*e^(i*theta)) = ln(r) + i*theta.
 long longValue()
          Returns the long value of this complex number
 double magnitude()
          Returns the magnitude of the complex number
 Complex mult(Complex z)
          Multiplies this complex number by another complex number.
static Complex mult(Complex z1, Complex z2)
          Multiplies two complex numbers
 Complex mult(double a)
          Multiplies this complex number by a constant.
 void polar(double r, double t)
          Converts polarrectangular coordinates (r,t) to rectangular (x, y).
 Complex pow(double a)
          Returns this complex number raised to the power a complex number.
 double real()
          Returns the real part of the complex number
 double real(double a)
          Set the real part of the complex number and returns old value
 Complex sin()
          Returns the sine of this complex number sin(x+y*i) = sin(x)*cosh(y), i*(cos(x)*sinh(y))
 Complex sinh()
          Returns the hyperbolic sine of this complex number.
 Complex sqrt()
          Returns the square root of this complex number
 Complex sub(Complex z)
          Subtracts another complex number from this complex number.
static Complex sub(Complex z1, Complex z2)
          Subtracts two complex numbers
 Complex sub(double a)
          Subtracts a constant from the real part of this complex number.
 String toString()
          Return the string representation of this complex number
 Complex unit()
          Normalizes the complex number
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected float x
the real part of the Complex number


y

protected float y
imaginary part of the Complex number

Constructor Detail

Complex

public Complex()
Sets the real and imaginary part of the complex number to zero


Complex

public Complex(double a,
               double b)
Initilizes the real and imaginary part to a and b repectively

Parameters:
a - Real part of the complex number
b - the imaginary part of the complex number

Complex

public Complex(Complex z)
Initilizes the complex number to z

Method Detail

real

public double real()
Returns the real part of the complex number


real

public double real(double a)
Set the real part of the complex number and returns old value


imag

public double imag()
Return the imaginary part of the imaginary number


imag

public double imag(double a)
Sets the imaginary part of the complex number and returns old value


magnitude

public double magnitude()
Returns the magnitude of the complex number


arg

public double arg()
Returns the phase of the complex number.Converts rectangular coordinates (x, y) to polar (r, theta).


unit

public Complex unit()
Normalizes the complex number


conj

public Complex conj()
Performs the conjuction function on the complex number


polar

public void polar(double r,
                  double t)
Converts polarrectangular coordinates (r,t) to rectangular (x, y).


equals

public boolean equals(Complex z)
Compares this complex number to another Complex number


toString

public String toString()
Return the string representation of this complex number

Overrides:
toString in class Object

add

public Complex add(Complex z)
Adds this complex number to another complex number. this is modified.

Parameters:
z - Complex number to add

sub

public Complex sub(Complex z)
Subtracts another complex number from this complex number. this is modified.

Parameters:
z - Complex number to subtract

mult

public Complex mult(Complex z)
Multiplies this complex number by another complex number. this is modified.

Parameters:
z - Complex number to multiply

div

public Complex div(Complex z)
Divides this complex number by z (z shouldn't be 0). this is modified.

Parameters:
z - Complex number to divide

add

public Complex add(double a)
Adds a constant to the real part of this complex number. this is modified.

Parameters:
a - constant to add

sub

public Complex sub(double a)
Subtracts a constant from the real part of this complex number. this is modified.

Parameters:
a - constant to subtract

mult

public Complex mult(double a)
Multiplies this complex number by a constant. this is modified.

Parameters:
a - constant to multiply

div

public Complex div(double a)
Divides this complex number by a constant a(a shouldn't be 0). this is modified.

Parameters:
a - constant to divide by

sqrt

public Complex sqrt()
Returns the square root of this complex number


exp

public Complex exp()
Returns the result of e^(x+y*i) = e^x * e^(i*y) = e^x*(cos(y) + sin(y)).


log

public Complex log()
Returns the result of ln(x+y*i) = ln(r*e^(i*theta)) = ln(r) + i*theta.


pow

public Complex pow(double a)
Returns this complex number raised to the power a complex number. That is, calculates (x+y*i)^a


cosh

public Complex cosh()
Returns the hyperbolic cosine of this complex number. cosh(k) = 1/2 * (e^k + e^k).


sinh

public Complex sinh()
Returns the hyperbolic sine of this complex number. sinh(k) = 1/2 * (e^k - e^k).


j1mult

Complex j1mult()
Returns a complex number with the negative of this complex number's real part


j2mult

Complex j2mult()
Returns a complex number with the negative of this complex number's real and imaginary part


j3mult

Complex j3mult()
Returns a complex number with the negative of this complex number's imaginary part


cos

public Complex cos()
Returns the cosine of this complex number. cos(x+y*i) = cos(x)*cosh(y) - i*(sin(x)*sinh(y)).


sin

public Complex sin()
Returns the sine of this complex number sin(x+y*i) = sin(x)*cosh(y), i*(cos(x)*sinh(y))


doubleValue

public double doubleValue()
Returns the double value of this complex number

Specified by:
doubleValue in class Number

floatValue

public float floatValue()
Returns the float value of this complex number

Specified by:
floatValue in class Number

intValue

public int intValue()
Returns the integer value of this complex number

Specified by:
intValue in class Number

longValue

public long longValue()
Returns the long value of this complex number

Specified by:
longValue in class Number

add

public static Complex add(Complex z1,
                          Complex z2)
Adds two complex numbers

Parameters:
z1 - first complex number
z2 - second complex number

sub

public static Complex sub(Complex z1,
                          Complex z2)
Subtracts two complex numbers

Parameters:
z1 - first complex number
z2 - second complex number (subtracted from the first)

mult

public static Complex mult(Complex z1,
                           Complex z2)
Multiplies two complex numbers

Parameters:
z1 - first complex number
z2 - second complex number

div

public static Complex div(Complex z1,
                          Complex z2)
Divides two complex numbers

Parameters:
z1 - first complex number
z2 - second complex number

JIGL
v1.6

Submit a bug or feature
Revised in May 2002 by Weiming Liu