Class Cmplx

Class Cmplx

Object
   |
   +----Cmplx

public class Cmplx
extends Object
Implementation of an ADT for ordinary algebraic complex numbers

Version:
Oct. 1, 1999
Author:
Bary W Pollack
See Also:
Cmplx

Variable Index

 o i
the square root of -1
 o im
the "imaginary" portion of an imaginary number
 o re
the "real" portion of an imaginary number

Constructor Index

 o Cmplx()
default constructor; creats 0+0i
 o Cmplx(double, double)
creates the complex number c+di

Method Index

 o add(Cmplx, Cmplx)
adds two complex numbers
 o conj(Cmplx)
conjugates a complex number
 o div(Cmplx, Cmplx)
divides two complex numbers
 o div(Cmplx, double)
divides a complex number by a scalar
 o mag(Cmplx)
calculates the magnitude of a complex number
 o mpy(Cmplx, Cmplx)
multiplies two complex numbers
 o mpy(double, Cmplx)
multiplies a scalar times a complex number
 o sub(Cmplx, Cmplx)
subtracts one complex number from another
 o toString()
converts a complex number into its String representation

Variables

 o i
public static final Cmplx i
the square root of -1

See Also:
Cmplx
 o im
private double im
the "imaginary" portion of an imaginary number

See Also:
Cmplx
 o re
private double re
the "real" portion of an imaginary number

See Also:
Cmplx

Constructors

 o Cmplx
 Cmplx()
default constructor; creats 0+0i

See Also:
Cmplx
 o Cmplx
 Cmplx(double re,
       double im)
creates the complex number c+di

Parameters:
re - the real portion of the complex number to be created
im - the imaginary portion of the complex number to be created

Methods

 o add
public static Cmplx add(Cmplx c,
                        Cmplx d)
adds two complex numbers

Parameters:
c - a complex number
d - another complex number
Returns:
the sum of two complex numbers
See Also:
sub
 o conj
public static Cmplx conj(Cmplx c)
conjugates a complex number

Parameters:
c - a complex number
Returns:
the complex conjugate of the complex number provided
 o div
public static Cmplx div(Cmplx c,
                        Cmplx d)
divides two complex numbers

Parameters:
c - the numerator complex number
d - the denominator complex number
Returns:
a complex number that is the quotient of the two inputs
See Also:
mpy
 o div
public static Cmplx div(Cmplx c,
                        double d)
divides a complex number by a scalar

Parameters:
c - numerator complex number
d - double denominator
Returns:
the quotient a complex numbers when divided by a scalar
See Also:
mpy
 o mag
public static double mag(Cmplx c)
calculates the magnitude of a complex number

Parameters:
c - the complex number
Returns:
the magnitude (a double) of the complex number provided as input
See Also:
Cmplx
 o mpy
public static Cmplx mpy(Cmplx c,
                        Cmplx d)
multiplies two complex numbers

Parameters:
c - one complex number
d - another complex number
Returns:
product of two complex numbers
See Also:
div
 o mpy
public static Cmplx mpy(double d,
                        Cmplx c)
multiplies a scalar times a complex number

Parameters:
d - a scalar double multiplier
c - a complex number
Returns:
product of a scalar and a complex number
See Also:
div
 o sub
public static Cmplx sub(Cmplx c,
                        Cmplx d)
subtracts one complex number from another

Parameters:
c - the complex number from which the second is to be subtracted
d - the complex number to be subtracted
Returns:
difference of two complex numbers
See Also:
add
 o toString
public java.lang.String toString()
converts a complex number into its String representation

Returns:
a String representation of the complex number in the form: ( a b )
Overrides:
toString in class Object
See Also:
Cmplx