All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class crw.math.Complex

java.lang.Object
   |
   +----crw.math.Complex

public class Complex
extends Object
implements Cloneable
Class to represent complex numbers. This Java class is similar to a C++ class but without (overloaded) operators, and contains all the C functions found in the Numerical Recipes in C, pp 710-712. This class defines the standard mathematical functions such as log() trigonometric functions, abs(), pow(), etc. as well as the standard operations incl. addition, subtraction, division, multiplication, etc.

Version:
1.0, 1997/6/14
Author:
C. R. Wie

Constructor Index

 o Complex()
Creates a Complex object with zero as the real and imaginary values.
 o Complex(Complex)
Creates a Complex object, initializing the real and imag parts equal to the supplied complex number.
 o Complex(double)
Creates a Complex object with the real part initialized to the argument and the imaginary part to zero.
 o Complex(double, double)
Creates a Complex object, initializing the real part and the imaginary part by the supplied arguments.

Method Index

 o abs()
Returns the absolute value of this Complex number.
 o abs(Complex)
Returns the absolute value of the argument.
 o acos(Complex)
Returns arccos() value of a complex number.
 o acosh(double)
Returns a double value y where cosh(y)=x and x=the argument.
 o add(Complex)
Adds a complex number (the supplied arg) to this complex number.
 o add(Complex, Complex)
Returns the addition of two complex numbers.
 o add(Complex, double)
Returns addition of a double to the real part of a Complex number.
 o add(double)
Adds a double to the real part of this object.
 o add(double, Complex)
Returns addition of a double to the real part of a Complex number.
 o arg(Complex)
Returns the argument (or phase) of a complex number.
 o asin(Complex)
Returns arcsin() value of a complex number.
 o asinh(Complex)
Returns the arcsinh() value of a complex number.
 o asinh(double)
Returns a double value y where sinh(y)=x and x is the argument.
 o atan(Complex)
Returns arctan() value of a complex number.
 o atanh(Complex)
Returns the arctanh() value of a complex number.
 o atanh(double)
Returns a double value y where tanh(y)=x and x=the argument.
 o conj()
Converts this complex number into its complex conjugate.
 o conj(Complex)
Returns a complex conjugate of a complex number.
 o cos(Complex)
Returns the complex cosine value of a complex number.
 o cosh(Complex)
Returns the complex cosh() value of a complex number.
 o cosh(double)
Returns the double cosh() value of a double.
 o div(Complex)
Divides this complex number by another complex number.
 o div(Complex, Complex)
Returns the complex quotient of the first (complex) argument divided by the second (complex) argument.
 o div(Complex, double)
Returns the complex quotient of the first (complex) argument divided by the second (double) argument.
 o div(double)
Divides this Complex number by a double.
 o div(double, Complex)
Returns the complex quotient of the first (double) argument divided by the second (complex) argument.
 o equals(Complex)
Compares this complex number with another one.
 o equals(double)
Compares this complex number with a double value.
 o exp(Complex)
Returns the complex exp() value of a complex
 o imag()
Returns the imaginary part of this complex number.
 o imag(Complex)
Returns the imaginary part of a complex number.
 o invert()
Converts this complex number into its inverse.
 o invert(Complex)
Returns the inverted value of a complex number (the argument).
 o log(Complex)
Returns the complex natural-log() value of a complex
 o log10(Complex)
Returns the complex log() of base 10 value of a complex.
 o modulus(Complex)
Returns the absolute value of a complex number.
 o mul(Complex)
Multiplies a complex number with this object and this object is replaced by the product.
 o mul(Complex, Complex)
Returns the result of multiplying a complex number to another.
 o mul(Complex, double)
Returns the result of multiplying a complex number with a double.
 o mul(double)
Multiplies a double to this complex object and this object is replaced by the product.
 o mul(double, Complex)
Returns the result of multiplying a complex number with a double.
 o neg(Complex)
Returns the negative of a complex number.
 o norm(Complex)
Returns the norm of a complex number.
 o polar(double, double)
Returns a complex quantity from a polar coordinate.
 o pow(Complex, Complex)
Returns the result of a complex base to the power of a complex exponent.
 o pow(Complex, double)
Returns the result of a complex base to the power of a double exponent.
 o pow(Complex, int)
Returns the result of a complex base to the power of an integer exponent.
 o pow(double, Complex)
Returns a complex result of a double base to the power of a complex exponent.
 o print()
 o real()
Returns the real part of this complex number.
 o real(Complex)
Returns the real part of a complex number.
 o sin(Complex)
Returns the complex sin() value of a complex
 o sinh(Complex)
Returns the complex sinh() value of a complex
 o sinh(double)
Returns a double sinh() value of a double
 o sqrt(Complex)
Returns the square root of a complex number.
 o sqrt2(Complex)
Returns the square root of a complex number.
 o sub(Complex)
Subtracts a complex number from this one.
 o sub(Complex, Complex)
Returns the result of subtracting the second arg from the first.
 o sub(Complex, double)
Returns the result of subtracting a double from the real part of a complex number.
 o sub(double)
Subtracts a double value from the real part of this Complex object.
 o sub(double, Complex)
Returns the result of a double minus a complex.
 o tan(Complex)
Returns a complex tangent value of a complex
 o tanh(Complex)
Returns a complex tanh() value of a complex
 o tanh(double)
Returns the double tanh() value of a double.

Constructors

 o Complex
 public Complex(double re,
                double im)
Creates a Complex object, initializing the real part and the imaginary part by the supplied arguments.

Parameters:
re - the real part
im - the imaginary part
 o Complex
 public Complex(double re)
Creates a Complex object with the real part initialized to the argument and the imaginary part to zero.

Parameters:
re - the new value of real part
 o Complex
 public Complex()
Creates a Complex object with zero as the real and imaginary values.

 o Complex
 public Complex(Complex z)
Creates a Complex object, initializing the real and imag parts equal to the supplied complex number.

Parameters:
z - a complex number

Methods

 o atanh
 public static Complex atanh(Complex z)
Returns the arctanh() value of a complex number.

Parameters:
z - a complex number
Returns:
the arctanh(z)
 o asinh
 public static Complex asinh(Complex z)
Returns the arcsinh() value of a complex number.

Parameters:
z - a complex number
Returns:
the arcsinh(z)
 o asinh
 public static double asinh(double x)
Returns a double value y where sinh(y)=x and x is the argument.

Parameters:
x - a double value
Returns:
the arcsinh() value of the argument x
 o acosh
 public static double acosh(double x)
Returns a double value y where cosh(y)=x and x=the argument.

Parameters:
x - a double value
Returns:
the arccosh() value of the argument x.
 o atanh
 public static double atanh(double x)
Returns a double value y where tanh(y)=x and x=the argument.

Parameters:
x - a double value
Returns:
the arctanh() value of the argument x.
 o asin
 public static Complex asin(Complex z)
Returns arcsin() value of a complex number.

Parameters:
z - a complex number
Returns:
arcsin() value of the argument z.
 o acos
 public static Complex acos(Complex z)
Returns arccos() value of a complex number.

Parameters:
z - a complex number.
Returns:
arccos() value of the argument z.
 o atan
 public static Complex atan(Complex z)
Returns arctan() value of a complex number.

Parameters:
z - a complex number.
Returns:
arctan() value of the argument z.
 o cos
 public static Complex cos(Complex z)
Returns the complex cosine value of a complex number.

Parameters:
z - the complex argument
Returns:
cos(z)
 o cosh
 public static Complex cosh(Complex z)
Returns the complex cosh() value of a complex number.

Parameters:
z - the complex argument return cosh(z)
 o cosh
 public static double cosh(double x)
Returns the double cosh() value of a double.

Parameters:
x - a double argument
Returns:
cosh(x)
 o sin
 public static Complex sin(Complex z)
Returns the complex sin() value of a complex

Parameters:
z - the complex argument
Returns:
a complex sin(z)
 o sinh
 public static Complex sinh(Complex z)
Returns the complex sinh() value of a complex

Parameters:
z - the complex argument
Returns:
a complex sinh(z)
 o sinh
 public static double sinh(double x)
Returns a double sinh() value of a double

Parameters:
x - a double argument
Returns:
a double sinh(x)
 o tan
 public static Complex tan(Complex z)
Returns a complex tangent value of a complex

Parameters:
z - the complex argument
Returns:
a complex tan(z)
 o tanh
 public static Complex tanh(Complex z)
Returns a complex tanh() value of a complex

Parameters:
z - the complex argument
Returns:
a complex tanh(z)
 o tanh
 public static double tanh(double x)
Returns the double tanh() value of a double.

Parameters:
x - the double argument
Returns:
a double tanh(x)
 o exp
 public static Complex exp(Complex z)
Returns the complex exp() value of a complex

Parameters:
z - the complex argument
Returns:
a complex exp(z)
 o log
 public static Complex log(Complex z)
Returns the complex natural-log() value of a complex

Parameters:
z - the complex argument
Returns:
a complex log(z)
 o log10
 public static Complex log10(Complex z)
Returns the complex log() of base 10 value of a complex.

Parameters:
z - the complex argument
Returns:
the complex log-base-10 value log10(z)
 o polar
 public static Complex polar(double r,
                             double theta)
Returns a complex quantity from a polar coordinate.

Parameters:
r - the radius
theta - the angle in radians
Returns:
the complex value corresponding to (r, theta)
 o sqrt
 public static Complex sqrt(Complex z)
Returns the square root of a complex number. The phase ranges from -pi to pi.

Parameters:
z - the complex number to take sqrt.
Returns:
the sqrt of z
 o sqrt2
 public static Complex sqrt2(Complex z)
Returns the square root of a complex number. The phase ranges from 0 to 2*pi.

Parameters:
z - the complex number to take the sqrt.
Returns:
the sqrt of the argument
 o pow
 public static Complex pow(Complex lhs,
                           Complex rhs)
Returns the result of a complex base to the power of a complex exponent. This function needs to be tested for its correctness.

Parameters:
lhs - the complex base
rhs - the complex exponent
 o pow
 public static Complex pow(Complex lhs,
                           int rhs)
Returns the result of a complex base to the power of an integer exponent.

Parameters:
lhs - the complex base.
rhs - the integer exponent
Returns:
lhs^rhs.
 o pow
 public static Complex pow(Complex lhs,
                           double rhs)
Returns the result of a complex base to the power of a double exponent.

Parameters:
lhs - the complex base
rhs - the double exponent
Returns:
lhs^rhs
 o pow
 public static Complex pow(double lhs,
                           Complex rhs)
Returns a complex result of a double base to the power of a complex exponent.

Parameters:
lhs - the double base
rhs - the complex exponent
Returns:
lhs^rhs.
 o abs
 public double abs()
Returns the absolute value of this Complex number.

Returns:
magnitude of this Complex object.
 o abs
 public static double abs(Complex z)
Returns the absolute value of the argument.

Parameters:
z - the complex number to find the magnitude.
Returns:
the magnitude of z.
 o arg
 public static double arg(Complex z)
Returns the argument (or phase) of a complex number.

Parameters:
z - a complex number
Returns:
the phase angle of the argument.
 o equals
 public boolean equals(Complex z)
Compares this complex number with another one.

Parameters:
z - the complex number to compare to.
Returns:
true if both re and im are equal.
 o equals
 public boolean equals(double r)
Compares this complex number with a double value.

Parameters:
r - the double value to compare this complex number to.
Returns:
true if both re and im are equal, false otherwise.
 o norm
 public static double norm(Complex z)
Returns the norm of a complex number.

Parameters:
z - a complex number
Returns:
the norm of the argument
 o modulus
 public static double modulus(Complex z)
Returns the absolute value of a complex number.

Parameters:
z - a complex number.
Returns:
abs(z)
 o conj
 public void conj()
Converts this complex number into its complex conjugate. Operation changes this object.

 o conj
 public static Complex conj(Complex z)
Returns a complex conjugate of a complex number.

Parameters:
z - a complex number
Returns:
z*
 o neg
 public static Complex neg(Complex z)
Returns the negative of a complex number.

Parameters:
z - the complex number to negate.
Returns:
-z
 o real
 public double real()
Returns the real part of this complex number.

Returns:
the real part
 o imag
 public double imag()
Returns the imaginary part of this complex number.

Returns:
the imaginary part.
 o real
 public static double real(Complex z)
Returns the real part of a complex number.

Parameters:
z - the complex number.
Returns:
the real part of z
 o imag
 public static double imag(Complex z)
Returns the imaginary part of a complex number.

Parameters:
z - the complex number.
Returns:
the imaginary part of z
 o add
 public void add(Complex z)
Adds a complex number (the supplied arg) to this complex number. This object changes as a result.

Parameters:
z - the Complex number to be added to this object.
 o add
 public void add(double r)
Adds a double to the real part of this object.

Parameters:
r - the double to be added to the real part.
 o add
 public static Complex add(Complex a,
                           Complex b)
Returns the addition of two complex numbers.

Parameters:
a - a complex number.
b - the other complex number.
Returns:
a+b
 o add
 public static Complex add(Complex z,
                           double r)
Returns addition of a double to the real part of a Complex number.

Parameters:
z - Complex number
r - a double to add to the real part.
Returns:
z+r
 o add
 public static Complex add(double r,
                           Complex z)
Returns addition of a double to the real part of a Complex number.

Parameters:
z - Complex number
r - a double to add to the real part.
Returns:
r+z
 o sub
 public void sub(Complex z)
Subtracts a complex number from this one. This method changes this Complex object.

Parameters:
z - the complex value to subtract.
 o sub
 public void sub(double r)
Subtracts a double value from the real part of this Complex object. Operation changes this object.

Parameters:
r - the double value to subtract.
 o sub
 public static Complex sub(Complex a,
                           Complex b)
Returns the result of subtracting the second arg from the first.

Parameters:
a - the Complex number to subract from.
b - the number to subtract.
Returns:
a - b
 o sub
 public static Complex sub(Complex z,
                           double r)
Returns the result of subtracting a double from the real part of a complex number.

Parameters:
z - the complex object to subtract from.
r - the double to subtract.
Returns:
z - r
 o sub
 public static Complex sub(double r,
                           Complex z)
Returns the result of a double minus a complex.

Parameters:
r - a double value
z - a Complex value
Returns:
r - z
 o mul
 public void mul(Complex z)
Multiplies a complex number with this object and this object is replaced by the product. This operation changes this object.

Parameters:
z - the complex number to multiply with.
 o mul
 public void mul(double r)
Multiplies a double to this complex object and this object is replaced by the product. Operation changes this object.

Parameters:
r - the double number to multiply with.
 o mul
 public static Complex mul(Complex a,
                           Complex b)
Returns the result of multiplying a complex number to another.

Parameters:
a - a complex number
b - another complex number.
Returns:
a * b
 o mul
 public static Complex mul(Complex z,
                           double r)
Returns the result of multiplying a complex number with a double.

Parameters:
z - a complex number
r - a double number.
Returns:
z * r
 o mul
 public static Complex mul(double r,
                           Complex z)
Returns the result of multiplying a complex number with a double.

Parameters:
z - a complex number
r - a double number.
Returns:
z * r
 o div
 public void div(Complex z)
Divides this complex number by another complex number. Operation changes this object.

Parameters:
z - the denominator
 o div
 public void div(double r)
Divides this Complex number by a double. Operation changes this object.

Parameters:
r - the denominator
 o div
 public static Complex div(Complex a,
                           Complex b)
Returns the complex quotient of the first (complex) argument divided by the second (complex) argument.

Parameters:
a - numerator
b - denominator returns a / b
 o div
 public static Complex div(double r,
                           Complex z)
Returns the complex quotient of the first (double) argument divided by the second (complex) argument.

Parameters:
r - (double) numerator
z - (complex) denominator returns r / z
 o div
 public static Complex div(Complex z,
                           double r)
Returns the complex quotient of the first (complex) argument divided by the second (double) argument.

Parameters:
z - (complex) numerator
r - (double) denominator returns z / r
 o invert
 public void invert()
Converts this complex number into its inverse. Operation changes this object.

 o invert
 public static Complex invert(Complex z)
Returns the inverted value of a complex number (the argument).

Parameters:
z - the complex number to invert.
Returns:
the inverted value of the argument
 o print
 protected void print()

All Packages  Class Hierarchy  This Package  Previous  Next  Index