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
-
Complex()
- Creates a Complex object with zero as the real and imaginary
values.
-
Complex(Complex)
- Creates a Complex object, initializing the real and imag parts
equal to the supplied complex number.
-
Complex(double)
- Creates a Complex object with the real part initialized to the argument
and the imaginary part to zero.
-
Complex(double, double)
- Creates a Complex object, initializing the real part and the
imaginary part by the supplied arguments.
-
abs()
- Returns the absolute value of this Complex number.
-
abs(Complex)
- Returns the absolute value of the argument.
-
acos(Complex)
- Returns arccos() value of a complex number.
-
acosh(double)
- Returns a double value y where cosh(y)=x and x=the argument.
-
add(Complex)
- Adds a complex number (the supplied arg) to this complex number.
-
add(Complex, Complex)
- Returns the addition of two complex numbers.
-
add(Complex, double)
- Returns addition of a double to the real part of a Complex number.
-
add(double)
- Adds a double to the real part of this object.
-
add(double, Complex)
- Returns addition of a double to the real part of a Complex number.
-
arg(Complex)
- Returns the argument (or phase) of a complex number.
-
asin(Complex)
- Returns arcsin() value of a complex number.
-
asinh(Complex)
- Returns the arcsinh() value of a complex number.
-
asinh(double)
- Returns a double value y where sinh(y)=x and x is the argument.
-
atan(Complex)
- Returns arctan() value of a complex number.
-
atanh(Complex)
- Returns the arctanh() value of a complex number.
-
atanh(double)
- Returns a double value y where tanh(y)=x and x=the argument.
-
conj()
- Converts this complex number into its complex conjugate.
-
conj(Complex)
- Returns a complex conjugate of a complex number.
-
cos(Complex)
- Returns the complex cosine value of a complex number.
-
cosh(Complex)
- Returns the complex cosh() value of a complex number.
-
cosh(double)
- Returns the double cosh() value of a double.
-
div(Complex)
- Divides this complex number by another complex number.
-
div(Complex, Complex)
- Returns the complex quotient of the first (complex) argument divided
by the second (complex) argument.
-
div(Complex, double)
- Returns the complex quotient of the first (complex) argument divided
by the second (double) argument.
-
div(double)
- Divides this Complex number by a double.
-
div(double, Complex)
- Returns the complex quotient of the first (double) argument divided
by the second (complex) argument.
-
equals(Complex)
- Compares this complex number with another one.
-
equals(double)
- Compares this complex number with a double value.
-
exp(Complex)
- Returns the complex exp() value of a complex
-
imag()
- Returns the imaginary part of this complex number.
-
imag(Complex)
- Returns the imaginary part of a complex number.
-
invert()
- Converts this complex number into its inverse.
-
invert(Complex)
- Returns the inverted value of a complex number (the argument).
-
log(Complex)
- Returns the complex natural-log() value of a complex
-
log10(Complex)
- Returns the complex log() of base 10 value of a complex.
-
modulus(Complex)
- Returns the absolute value of a complex number.
-
mul(Complex)
- Multiplies a complex number with this object and this object is
replaced by the product.
-
mul(Complex, Complex)
- Returns the result of multiplying a complex number to another.
-
mul(Complex, double)
- Returns the result of multiplying a complex number with a double.
-
mul(double)
- Multiplies a double to this complex object and this object is
replaced by the product.
-
mul(double, Complex)
- Returns the result of multiplying a complex number with a double.
-
neg(Complex)
- Returns the negative of a complex number.
-
norm(Complex)
- Returns the norm of a complex number.
-
polar(double, double)
- Returns a complex quantity from a polar coordinate.
-
pow(Complex, Complex)
- Returns the result of a complex base to the power of a complex
exponent.
-
pow(Complex, double)
- Returns the result of a complex base to the power of a double
exponent.
-
pow(Complex, int)
- Returns the result of a complex base to the power of an integer
exponent.
-
pow(double, Complex)
- Returns a complex result of a double base to the power of a
complex exponent.
-
print()
-
-
real()
- Returns the real part of this complex number.
-
real(Complex)
- Returns the real part of a complex number.
-
sin(Complex)
- Returns the complex sin() value of a complex
-
sinh(Complex)
- Returns the complex sinh() value of a complex
-
sinh(double)
- Returns a double sinh() value of a double
-
sqrt(Complex)
- Returns the square root of a complex number.
-
sqrt2(Complex)
- Returns the square root of a complex number.
-
sub(Complex)
- Subtracts a complex number from this one.
-
sub(Complex, Complex)
- Returns the result of subtracting the second arg
from the first.
-
sub(Complex, double)
- Returns the result of subtracting a double from the real part
of a complex number.
-
sub(double)
- Subtracts a double value from the real part of this Complex object.
-
sub(double, Complex)
- Returns the result of a double minus a complex.
-
tan(Complex)
- Returns a complex tangent value of a complex
-
tanh(Complex)
- Returns a complex tanh() value of a complex
-
tanh(double)
- Returns the double tanh() value of a double.
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
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
Complex
public Complex()
- Creates a Complex object with zero as the real and imaginary
values.
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
atanh
public static Complex atanh(Complex z)
- Returns the arctanh() value of a complex number.
- Parameters:
- z - a complex number
- Returns:
- the arctanh(z)
asinh
public static Complex asinh(Complex z)
- Returns the arcsinh() value of a complex number.
- Parameters:
- z - a complex number
- Returns:
- the arcsinh(z)
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
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.
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.
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.
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.
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.
cos
public static Complex cos(Complex z)
- Returns the complex cosine value of a complex number.
- Parameters:
- z - the complex argument
- Returns:
- cos(z)
cosh
public static Complex cosh(Complex z)
- Returns the complex cosh() value of a complex number.
- Parameters:
- z - the complex argument
return cosh(z)
cosh
public static double cosh(double x)
- Returns the double cosh() value of a double.
- Parameters:
- x - a double argument
- Returns:
- cosh(x)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
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
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
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.
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
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.
abs
public double abs()
- Returns the absolute value of this Complex number.
- Returns:
- magnitude of this Complex object.
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.
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.
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.
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.
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
modulus
public static double modulus(Complex z)
- Returns the absolute value of a complex number.
- Parameters:
- z - a complex number.
- Returns:
- abs(z)
conj
public void conj()
- Converts this complex number into its complex conjugate.
Operation changes this object.
conj
public static Complex conj(Complex z)
- Returns a complex conjugate of a complex number.
- Parameters:
- z - a complex number
- Returns:
- z*
neg
public static Complex neg(Complex z)
- Returns the negative of a complex number.
- Parameters:
- z - the complex number to negate.
- Returns:
- -z
real
public double real()
- Returns the real part of this complex number.
- Returns:
- the real part
imag
public double imag()
- Returns the imaginary part of this complex number.
- Returns:
- the imaginary part.
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
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
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.
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.
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
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
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
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.
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.
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
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
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
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.
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.
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
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
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
div
public void div(Complex z)
- Divides this complex number by another complex number. Operation
changes this object.
- Parameters:
- z - the denominator
div
public void div(double r)
- Divides this Complex number by a double. Operation changes
this object.
- Parameters:
- r - the denominator
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
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
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
invert
public void invert()
- Converts this complex number into its inverse. Operation changes
this object.
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
print
protected void print()
All Packages Class Hierarchy This Package Previous Next Index