edu.mines.jtk.util
Class Cdouble

java.lang.Object
  extended by edu.mines.jtk.util.Cdouble

public class Cdouble
extends java.lang.Object

A complex number, with double-precision real and imaginary parts.

Version:
2005.05.06
Author:
Dave Hale, Colorado School of Mines

Field Summary
static Cdouble DBL_I
          The complex constant (0.0,1.0).
 double i
          The imaginary part.
 double r
          The real part.
 
Constructor Summary
Cdouble()
          Constructs a complex number with zero real and imaginary parts.
Cdouble(Cdouble x)
          Constructs a copy of the specified complex number.
Cdouble(double r)
          Constructs a complex number with zero imaginary part.
Cdouble(double r, double i)
          Constructs a complex number.
 
Method Summary
 double abs()
          Returns the magnitude of this complex number.
static double abs(Cdouble x)
          Returns the magnitude of a complex number.
static Cdouble add(Cdouble x, Cdouble y)
          Returns the sum x + y.
 double arg()
          Returns the argument of this complex number.
static double arg(Cdouble x)
          Returns the argument of a complex number.
 Cdouble conj()
          Returns the complex conjugate of this complex number.
static Cdouble conj(Cdouble x)
          Returns the conjugate of x.
 Cdouble conjEquals()
          Returns the conjugate z = conj(z), where z is this complex number.
 Cdouble cos()
          Returns the cosine of this complex number.
static Cdouble cos(Cdouble x)
          Returns the cosine of a complex number.
 Cdouble cosh()
          Returns the hyberbolic cosine of this complex number.
static Cdouble cosh(Cdouble x)
          Returns the hyperbolic cosine of a complex number.
static Cdouble div(Cdouble x, Cdouble y)
          Returns the quotient x * y.
 boolean equals(java.lang.Object obj)
           
 Cdouble exp()
          Returns the exponential of this complex number.
static Cdouble exp(Cdouble x)
          Returns the exponential of a complex number.
 int hashCode()
           
 Cdouble inv()
          Returns the complex inverse of this complex number.
 Cdouble inv(Cdouble x)
          Returns the inverse of x.
 Cdouble invEquals()
          Returns the inverse z = inv(z), where z is this complex number.
 boolean isImag()
          Determines whether this complex number is imaginary (has zero real part).
static boolean isImag(Cdouble x)
          Determines whether x is imaginary (has zero real part).
 boolean isReal()
          Determines whether this complex number is real (has zero imaginary part).
static boolean isReal(Cdouble x)
          Determines whether x is real (has zero imaginary part).
 Cdouble log()
          Returns the natural logarithm of this complex number.
static Cdouble log(Cdouble x)
          Returns the natural logarithm of a complex number.
 Cdouble log10()
          Returns the logarithm base 10 of this complex number.
static Cdouble log10(Cdouble x)
          Returns the logarithm base 10 of a complex number.
 Cdouble minus(Cdouble x)
          Returns the difference z - x, where z is this complex number.
 Cdouble minus(double x)
          Returns the difference z - x, where z is this complex number.
 Cdouble minusEquals(Cdouble x)
          Returns the difference z -= x, where z is this complex number.
 Cdouble minusEquals(double x)
          Returns the difference z -= x, where z is this complex number.
static Cdouble mul(Cdouble x, Cdouble y)
          Returns the product x * y.
 Cdouble neg()
          Returns the complex negative of this complex number.
static Cdouble neg(Cdouble x)
          Returns the negative of x.
 Cdouble negEquals()
          Returns the negative z = neg(z), where z is this complex number.
 double norm()
          Returns the norm of this complex number.
static double norm(Cdouble x)
          Returns the norm of a complex number.
 Cdouble over(Cdouble x)
          Returns the quotent z / x, where z is this complex number.
 Cdouble over(double x)
          Returns the quotent z / x, where z is this complex number.
 Cdouble overEquals(Cdouble x)
          Returns the quotient z /= x, where z is this complex number.
 Cdouble overEquals(double x)
          Returns the quotient z /= x, where z is this complex number.
 Cdouble plus(Cdouble x)
          Returns the sum z + x, where z is this complex number.
 Cdouble plus(double x)
          Returns the sum z + x, where z is this complex number.
 Cdouble plusEquals(Cdouble x)
          Returns the sum z += x, where z is this complex number.
 Cdouble plusEquals(double x)
          Returns the sum z += x, where z is this complex number.
static Cdouble polar(double r, double a)
          Returns the complex number (r*cos(a),r*sin(a)).
 Cdouble pow(Cdouble y)
          Returns z to the y'th power, where z is this complex number.
static Cdouble pow(Cdouble x, Cdouble y)
          Returns x to the y'th power.
static Cdouble pow(Cdouble x, double y)
          Returns x to the y'th power.
 Cdouble pow(double y)
          Returns z to the y'th power, where z is this complex number.
static Cdouble pow(double x, Cdouble y)
          Returns x to the y'th power.
 Cdouble sin()
          Returns the sine of this complex number.
static Cdouble sin(Cdouble x)
          Returns the sine of a complex number.
 Cdouble sinh()
          Returns the hyberbolic sine of this complex number.
static Cdouble sinh(Cdouble x)
          Returns the hyperbolic sine of a complex number.
 Cdouble sqrt()
          Returns the square-root of this complex number.
static Cdouble sqrt(Cdouble x)
          Returns the square root of a complex number.
static Cdouble sub(Cdouble x, Cdouble y)
          Returns the difference x - y.
 Cdouble tan()
          Returns the tangent of this complex number.
static Cdouble tan(Cdouble x)
          Returns the tangent of a complex number.
 Cdouble tanh()
          Returns the hyberbolic tangent of this complex number.
static Cdouble tanh(Cdouble x)
          Returns the hyperbolic tangent of a complex number.
 Cdouble times(Cdouble x)
          Returns the product z * x, where z is this complex number.
 Cdouble times(double x)
          Returns the product z * x, where z is this complex number.
 Cdouble timesEquals(Cdouble x)
          Returns the product z *= x, where z is this complex number.
 Cdouble timesEquals(double x)
          Returns the product z *= x, where z is this complex number.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DBL_I

public static final Cdouble DBL_I
The complex constant (0.0,1.0).


r

public double r
The real part.


i

public double i
The imaginary part.

Constructor Detail

Cdouble

public Cdouble()
Constructs a complex number with zero real and imaginary parts.


Cdouble

public Cdouble(double r)
Constructs a complex number with zero imaginary part.

Parameters:
r - the real part.

Cdouble

public Cdouble(double r,
               double i)
Constructs a complex number.

Parameters:
r - the real part.
i - the imaginary part.

Cdouble

public Cdouble(Cdouble x)
Constructs a copy of the specified complex number.

Parameters:
x - the complex number.
Method Detail

plus

public Cdouble plus(Cdouble x)
Returns the sum z + x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z + x.

minus

public Cdouble minus(Cdouble x)
Returns the difference z - x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z - x.

times

public Cdouble times(Cdouble x)
Returns the product z * x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z * x.

over

public Cdouble over(Cdouble x)
Returns the quotent z / x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z / x.

plus

public Cdouble plus(double x)
Returns the sum z + x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z + x.

minus

public Cdouble minus(double x)
Returns the difference z - x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z - x.

times

public Cdouble times(double x)
Returns the product z * x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z * x.

over

public Cdouble over(double x)
Returns the quotent z / x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z / x.

plusEquals

public Cdouble plusEquals(Cdouble x)
Returns the sum z += x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z += x.

minusEquals

public Cdouble minusEquals(Cdouble x)
Returns the difference z -= x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z -= x.

timesEquals

public Cdouble timesEquals(Cdouble x)
Returns the product z *= x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z *= x.

overEquals

public Cdouble overEquals(Cdouble x)
Returns the quotient z /= x, where z is this complex number.

Parameters:
x - a complex number.
Returns:
z /= x.

plusEquals

public Cdouble plusEquals(double x)
Returns the sum z += x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z += x.

minusEquals

public Cdouble minusEquals(double x)
Returns the difference z -= x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z -= x.

timesEquals

public Cdouble timesEquals(double x)
Returns the product z *= x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z *= x.

overEquals

public Cdouble overEquals(double x)
Returns the quotient z /= x, where z is this complex number.

Parameters:
x - a real number.
Returns:
z /= x.

conjEquals

public Cdouble conjEquals()
Returns the conjugate z = conj(z), where z is this complex number.

Returns:
z = conj(z).

invEquals

public Cdouble invEquals()
Returns the inverse z = inv(z), where z is this complex number.

Returns:
z = inv(z).

negEquals

public Cdouble negEquals()
Returns the negative z = neg(z), where z is this complex number.

Returns:
z = neg(z).

isReal

public boolean isReal()
Determines whether this complex number is real (has zero imaginary part).

Returns:
true, if real; false, otherwise.

isImag

public boolean isImag()
Determines whether this complex number is imaginary (has zero real part).

Returns:
true, if imaginary; false, otherwise.

conj

public Cdouble conj()
Returns the complex conjugate of this complex number.

Returns:
the complex conjugate.

inv

public Cdouble inv()
Returns the complex inverse of this complex number.

Returns:
the complex inverse.

neg

public Cdouble neg()
Returns the complex negative of this complex number.

Returns:
the complex negative.

abs

public double abs()
Returns the magnitude of this complex number.

Returns:
the magnitude.

arg

public double arg()
Returns the argument of this complex number.

Returns:
the argument.

norm

public double norm()
Returns the norm of this complex number. The norm is the sum of the squares of the real and imaginary parts.

Returns:
the norm.

sqrt

public Cdouble sqrt()
Returns the square-root of this complex number.

Returns:
the square-root.

exp

public Cdouble exp()
Returns the exponential of this complex number.

Returns:
the exponential.

log

public Cdouble log()
Returns the natural logarithm of this complex number.

Returns:
the natural logarithm.

log10

public Cdouble log10()
Returns the logarithm base 10 of this complex number.

Returns:
the logarithm base 10.

pow

public Cdouble pow(double y)
Returns z to the y'th power, where z is this complex number.

Parameters:
y - a real number.
Returns:
z to the y'th power.

pow

public Cdouble pow(Cdouble y)
Returns z to the y'th power, where z is this complex number.

Parameters:
y - a complex number.
Returns:
z to the y'th power.

sin

public Cdouble sin()
Returns the sine of this complex number.

Returns:
the sine.

cos

public Cdouble cos()
Returns the cosine of this complex number.

Returns:
the cosine.

tan

public Cdouble tan()
Returns the tangent of this complex number.

Returns:
the tangent.

sinh

public Cdouble sinh()
Returns the hyberbolic sine of this complex number.

Returns:
the hyberbolic sine.

cosh

public Cdouble cosh()
Returns the hyberbolic cosine of this complex number.

Returns:
the hyberbolic cosine.

tanh

public Cdouble tanh()
Returns the hyberbolic tangent of this complex number.

Returns:
the hyberbolic tangent.

isReal

public static boolean isReal(Cdouble x)
Determines whether x is real (has zero imaginary part).

Parameters:
x - a complex number.
Returns:
true, if real; false, otherwise.

isImag

public static boolean isImag(Cdouble x)
Determines whether x is imaginary (has zero real part).

Parameters:
x - a complex number.
Returns:
true, if imaginary; false, otherwise.

conj

public static Cdouble conj(Cdouble x)
Returns the conjugate of x.

Parameters:
x - a complex number.
Returns:
the conjugate.

inv

public Cdouble inv(Cdouble x)
Returns the inverse of x.

Parameters:
x - a complex number.
Returns:
the complex inverse.

neg

public static Cdouble neg(Cdouble x)
Returns the negative of x.

Parameters:
x - a complex number.
Returns:
the negative.

polar

public static Cdouble polar(double r,
                            double a)
Returns the complex number (r*cos(a),r*sin(a)).

Parameters:
r - the polar radius.
a - the polar angle.
Returns:
the complex number.

add

public static Cdouble add(Cdouble x,
                          Cdouble y)
Returns the sum x + y.

Parameters:
x - a complex number.
y - a complex number.
Returns:
the sum.

sub

public static Cdouble sub(Cdouble x,
                          Cdouble y)
Returns the difference x - y.

Parameters:
x - a complex number.
y - a complex number.
Returns:
the difference.

mul

public static Cdouble mul(Cdouble x,
                          Cdouble y)
Returns the product x * y.

Parameters:
x - a complex number.
y - a complex number.
Returns:
the product.

div

public static Cdouble div(Cdouble x,
                          Cdouble y)
Returns the quotient x * y.

Parameters:
x - a complex number.
y - a complex number.
Returns:
the quotient.

abs

public static double abs(Cdouble x)
Returns the magnitude of a complex number.

Parameters:
x - a complex number.
Returns:
the magnitude.

arg

public static double arg(Cdouble x)
Returns the argument of a complex number.

Parameters:
x - a complex number.
Returns:
the argument.

norm

public static double norm(Cdouble x)
Returns the norm of a complex number. The norm is the sum of the squares of the real and imaginary parts.

Parameters:
x - a complex number.
Returns:
the norm.

sqrt

public static Cdouble sqrt(Cdouble x)
Returns the square root of a complex number.

Parameters:
x - a complex number.
Returns:
the square root.

exp

public static Cdouble exp(Cdouble x)
Returns the exponential of a complex number.

Parameters:
x - a complex number.
Returns:
the exponential.

log

public static Cdouble log(Cdouble x)
Returns the natural logarithm of a complex number.

Parameters:
x - a complex number.
Returns:
the natural logarithm.

log10

public static Cdouble log10(Cdouble x)
Returns the logarithm base 10 of a complex number.

Parameters:
x - a complex number.
Returns:
the logarithm base 10.

pow

public static Cdouble pow(Cdouble x,
                          double y)
Returns x to the y'th power.

Parameters:
x - a complex number.
y - a real number.
Returns:
x to the y'th power.

pow

public static Cdouble pow(double x,
                          Cdouble y)
Returns x to the y'th power.

Parameters:
x - a real number.
y - a complex number.
Returns:
x to the y'th power.

pow

public static Cdouble pow(Cdouble x,
                          Cdouble y)
Returns x to the y'th power.

Parameters:
x - a complex number.
y - a complex number.
Returns:
x to the y'th power.

sin

public static Cdouble sin(Cdouble x)
Returns the sine of a complex number.

Parameters:
x - a complex number.
Returns:
the sine.

cos

public static Cdouble cos(Cdouble x)
Returns the cosine of a complex number.

Parameters:
x - a complex number.
Returns:
the cosine.

tan

public static Cdouble tan(Cdouble x)
Returns the tangent of a complex number.

Parameters:
x - a complex number.
Returns:
the tangent.

sinh

public static Cdouble sinh(Cdouble x)
Returns the hyperbolic sine of a complex number.

Parameters:
x - a complex number.
Returns:
the hyperbolic sine.

cosh

public static Cdouble cosh(Cdouble x)
Returns the hyperbolic cosine of a complex number.

Parameters:
x - a complex number.
Returns:
the hyperbolic cosine.

tanh

public static Cdouble tanh(Cdouble x)
Returns the hyperbolic tangent of a complex number.

Parameters:
x - a complex number.
Returns:
the hyperbolic tangent.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object