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
-
i
- the square root of -1
-
im
- the "imaginary" portion of an imaginary number
-
re
- the "real" portion of an imaginary number
-
Cmplx()
- default constructor; creats 0+0i
-
Cmplx(double, double)
- creates the complex number c+di
-
add(Cmplx, Cmplx)
- adds two complex numbers
-
conj(Cmplx)
- conjugates a complex number
-
div(Cmplx, Cmplx)
- divides two complex numbers
-
div(Cmplx, double)
- divides a complex number by a scalar
-
mag(Cmplx)
- calculates the magnitude of a complex number
-
mpy(Cmplx, Cmplx)
- multiplies two complex numbers
-
mpy(double, Cmplx)
- multiplies a scalar times a complex number
-
sub(Cmplx, Cmplx)
- subtracts one complex number from another
-
toString()
- converts a complex number into its String representation
i
public static final Cmplx i
- the square root of -1
- See Also:
- Cmplx
im
private double im
- the "imaginary" portion of an imaginary number
- See Also:
- Cmplx
re
private double re
- the "real" portion of an imaginary number
- See Also:
- Cmplx
Cmplx
Cmplx()
- default constructor; creats 0+0i
- See Also:
- Cmplx
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
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
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
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
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
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
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
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
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
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