edu.mines.jtk.util
Class Cfloat

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

public class Cfloat
extends java.lang.Object

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

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

Field Summary
static Cfloat FLT_I
          The complex constant (0.0f,1.0f).
 float i
          The imaginary part.
 float r
          The real part.
 
Constructor Summary
Cfloat()
          Constructs a complex number with zero real and imaginary parts.
Cfloat(Cfloat x)
          Constructs a copy of the specified complex number.
Cfloat(float r)
          Constructs a complex number with zero imaginary part.
Cfloat(float r, float i)
          Constructs a complex number.
 
Method Summary
 float abs()
          Returns the magnitude of this complex number.
static float abs(Cfloat x)
          Returns the magnitude of a complex number.
static Cfloat add(Cfloat x, Cfloat y)
          Returns the sum x + y.
 float arg()
          Returns the argument of this complex number.
static float arg(Cfloat x)
          Returns the argument of a complex number.
 Cfloat conj()
          Returns the complex conjugate of this complex number.
static Cfloat conj(Cfloat x)
          Returns the conjugate of x.
 Cfloat conjEquals()
          Returns the conjugate z = conj(z), where z is this complex number.
 Cfloat cos()
          Returns the cosine of this complex number.
static Cfloat cos(Cfloat x)
          Returns the cosine of a complex number.
 Cfloat cosh()
          Returns the hyberbolic cosine of this complex number.
static Cfloat cosh(Cfloat x)
          Returns the hyperbolic cosine of a complex number.
static Cfloat div(Cfloat x, Cfloat y)
          Returns the quotient x * y.
 boolean equals(java.lang.Object obj)
           
 Cfloat exp()
          Returns the exponential of this complex number.
static Cfloat exp(Cfloat x)
          Returns the exponential of a complex number.
 int hashCode()
           
 Cfloat inv()
          Returns the complex inverse of this complex number.
 Cfloat inv(Cfloat x)
          Returns the inverse of x.
 Cfloat 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(Cfloat 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(Cfloat x)
          Determines whether x is real (has zero imaginary part).
 Cfloat log()
          Returns the natural logarithm of this complex number.
static Cfloat log(Cfloat x)
          Returns the natural logarithm of a complex number.
 Cfloat log10()
          Returns the logarithm base 10 of this complex number.
static Cfloat log10(Cfloat x)
          Returns the logarithm base 10 of a complex number.
 Cfloat minus(Cfloat x)
          Returns the difference z - x, where z is this complex number.
 Cfloat minus(float x)
          Returns the difference z - x, where z is this complex number.
 Cfloat minusEquals(Cfloat x)
          Returns the difference z -= x, where z is this complex number.
 Cfloat minusEquals(float x)
          Returns the difference z -= x, where z is this complex number.
static Cfloat mul(Cfloat x, Cfloat y)
          Returns the product x * y.
 Cfloat neg()
          Returns the complex negative of this complex number.
static Cfloat neg(Cfloat x)
          Returns the negative of x.
 Cfloat negEquals()
          Returns the negative z = neg(z), where z is this complex number.
 float norm()
          Returns the norm of this complex number.
static float norm(Cfloat x)
          Returns the norm of a complex number.
 Cfloat over(Cfloat x)
          Returns the quotent z / x, where z is this complex number.
 Cfloat over(float x)
          Returns the quotent z / x, where z is this complex number.
 Cfloat overEquals(Cfloat x)
          Returns the quotient z /= x, where z is this complex number.
 Cfloat overEquals(float x)
          Returns the quotient z /= x, where z is this complex number.
 Cfloat plus(Cfloat x)
          Returns the sum z + x, where z is this complex number.
 Cfloat plus(float x)
          Returns the sum z + x, where z is this complex number.
 Cfloat plusEquals(Cfloat x)
          Returns the sum z += x, where z is this complex number.
 Cfloat plusEquals(float x)
          Returns the sum z += x, where z is this complex number.
static Cfloat polar(float r, float a)
          Returns the complex number (r*cos(a),r*sin(a)).
 Cfloat pow(Cfloat y)
          Returns z to the y'th power, where z is this complex number.
static Cfloat pow(Cfloat x, Cfloat y)
          Returns x to the y'th power.
static Cfloat pow(Cfloat x, float y)
          Returns x to the y'th power.
 Cfloat pow(float y)
          Returns z to the y'th power, where z is this complex number.
static Cfloat pow(float x, Cfloat y)
          Returns x to the y'th power.
 Cfloat sin()
          Returns the sine of this complex number.
static Cfloat sin(Cfloat x)
          Returns the sine of a complex number.
 Cfloat sinh()
          Returns the hyberbolic sine of this complex number.
static Cfloat sinh(Cfloat x)
          Returns the hyperbolic sine of a complex number.
 Cfloat sqrt()
          Returns the square-root of this complex number.
static Cfloat sqrt(Cfloat x)
          Returns the square root of a complex number.
static Cfloat sub(Cfloat x, Cfloat y)
          Returns the difference x - y.
 Cfloat tan()
          Returns the tangent of this complex number.
static Cfloat tan(Cfloat x)
          Returns the tangent of a complex number.
 Cfloat tanh()
          Returns the hyberbolic tangent of this complex number.
static Cfloat tanh(Cfloat x)
          Returns the hyperbolic tangent of a complex number.
 Cfloat times(Cfloat x)
          Returns the product z * x, where z is this complex number.
 Cfloat times(float x)
          Returns the product z * x, where z is this complex number.
 Cfloat timesEquals(Cfloat x)
          Returns the product z *= x, where z is this complex number.
 Cfloat timesEquals(float 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

FLT_I

public static final Cfloat FLT_I
The complex constant (0.0f,1.0f).


r

public float r
The real part.


i

public float i
The imaginary part.

Constructor Detail

Cfloat

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


Cfloat

public Cfloat(float r)
Constructs a complex number with zero imaginary part.

Parameters:
r - the real part.

Cfloat

public Cfloat(float r,
              float i)
Constructs a complex number.

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

Cfloat

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

Parameters:
x - the complex number.
Method Detail

plus

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

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

minus

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

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

times

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

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

over

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

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

plus

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

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

minus

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

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

times

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

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

over

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

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

plusEquals

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

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

minusEquals

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

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

timesEquals

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

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

overEquals

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

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

plusEquals

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

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

minusEquals

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

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

timesEquals

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

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

overEquals

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

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

conjEquals

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

Returns:
z = conj(z).

invEquals

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

Returns:
z = inv(z).

negEquals

public Cfloat 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 Cfloat conj()
Returns the complex conjugate of this complex number.

Returns:
the complex conjugate.

inv

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

Returns:
the complex inverse.

neg

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

Returns:
the complex negative.

abs

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

Returns:
the magnitude.

arg

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

Returns:
the argument.

norm

public float 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 Cfloat sqrt()
Returns the square-root of this complex number.

Returns:
the square-root.

exp

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

Returns:
the exponential.

log

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

Returns:
the natural logarithm.

log10

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

Returns:
the logarithm base 10.

pow

public Cfloat pow(float 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 Cfloat pow(Cfloat 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 Cfloat sin()
Returns the sine of this complex number.

Returns:
the sine.

cos

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

Returns:
the cosine.

tan

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

Returns:
the tangent.

sinh

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

Returns:
the hyberbolic sine.

cosh

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

Returns:
the hyberbolic cosine.

tanh

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

Returns:
the hyberbolic tangent.

isReal

public static boolean isReal(Cfloat 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(Cfloat x)
Determines whether x is imaginary (has zero real part).

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

conj

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

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

inv

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

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

neg

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

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

polar

public static Cfloat polar(float r,
                           float 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 Cfloat add(Cfloat x,
                         Cfloat y)
Returns the sum x + y.

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

sub

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

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

mul

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

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

div

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

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

abs

public static float abs(Cfloat x)
Returns the magnitude of a complex number.

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

arg

public static float arg(Cfloat x)
Returns the argument of a complex number.

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

norm

public static float norm(Cfloat 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 Cfloat sqrt(Cfloat x)
Returns the square root of a complex number.

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

exp

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

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

log

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

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

log10

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

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

pow

public static Cfloat pow(Cfloat x,
                         float 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 Cfloat pow(float x,
                         Cfloat 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 Cfloat pow(Cfloat x,
                         Cfloat 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 Cfloat sin(Cfloat x)
Returns the sine of a complex number.

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

cos

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

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

tan

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

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

sinh

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

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

cosh

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

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

tanh

public static Cfloat tanh(Cfloat 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