|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
math.complex.ComplexBusted
public class ComplexBusted
The class Complex defines a complex data type, and
implements operations with that data type. The methods in this
class fall into two categories--instance methods and
static methods. The instance methods are mostly designed to work
on Complex objects and to return references to
Complex objects, so that they can be strung together
in expressions. For example, a Complex expression such as
z3 = z1 * z2 + z3can be implemented as
z3 = z1.mul(z2).add(z3)However, these methods are always evaluated from left to right, so if the order of operations is not purely left-to-right, you will have to use parentheses or re-arrange the order of the methods to get the order of operations right. For example, a
Complex expression such as
z3 = z1 + z2 * z3requires that the multiplication occur before the addition. This can be implemented as
z3 = z1.add( z2.mul(z3) );or alternatively as
z3 = z2.mul(z3).add(z1);The instance methods in this class that can be used to build such expressions include
add,
sub, mul, div, pow,
inv, neg, abs, arg,
cong, re, and im.
This class also contains many static methods that accept Complex
arguments and return appropriate values. In general, the static methods
in this class qre similar to the static methods in class
java.lang.Math.
Examples include sin(z), cos(z), tan(z),
log(z), etc.
Class Complex is a subclass of Number, and it
overrides all of the abstract methods in that class. The overridden
methods in class Complex work with the real part of the
Complex number only.
This class also implements the java.lang.Comparable interface.
In this case, the comparisons are between the absolute values of the
two Complex numbers.
| Field Summary | |
|---|---|
static ComplexBusted |
I
Constant representing i, the square root of -1. |
double |
im
imaginary part of Complex number. |
static ComplexBusted |
J
Constant representing i, the square root of -1. |
double |
re
Real part of Complex number. |
| Constructor Summary | |
|---|---|
ComplexBusted()
Constructs a Complex object representing the number zero. |
|
ComplexBusted(ComplexBusted z)
Constructs a new Complex object from an existing Complex object. |
|
ComplexBusted(double re)
Constructs a Complex from a real number. |
|
ComplexBusted(double re,
double im)
Constructs a Complex object from real and imaginary parts. |
|
| Method Summary | |
|---|---|
double |
abs()
Returns the absolute value (magnitude) of a Complex object. |
static double |
abs(ComplexBusted z)
Returns the absolute value (magnitude) of a Complex number. |
static ComplexBusted |
acos(ComplexBusted z)
Returns the principal inverse cosine of a Complex number. |
static ComplexBusted |
acosh(ComplexBusted z)
Returns the principal inverse hyperbolic cosine of a Complex number. |
ComplexBusted |
add(ComplexBusted z)
Returns the sum of two Complex values. |
ComplexBusted |
add(double d)
Returns the sum of a Complex and a double value. |
void |
addImaginary(double _i)
|
void |
addReal(double _x)
|
double |
arg()
Returns the principal angle of a Complex number, in radians, measured counter-clockwise from the real axis. |
static double |
arg(ComplexBusted z)
Returns the principal angle of a Complex number, in radians, measured counter-clockwise from the real axis. |
static ComplexBusted |
asin(ComplexBusted z)
Returns the principal inverse sine of a Complex number. |
static ComplexBusted |
asinh(ComplexBusted z)
Returns the principal inverse hyperbolic sine of a Complex number. |
static ComplexBusted |
atan(ComplexBusted z)
Returns the principal inverse tangent of a Complex number. |
static ComplexBusted |
atanh(ComplexBusted z)
Returns the principal inverse hyperbolic tangent of a Complex number. |
byte |
byteValue()
Returns the value of the real part of the specified number as a byte. |
int |
compareTo(ComplexBusted anotherComplex)
Compares two Complex values numerically according to their
absolute values. |
int |
compareTo(java.lang.Object o)
Compares this Complex to another Object. |
static ComplexBusted |
complex(double re)
Creates a new Complex number from a double. |
static ComplexBusted |
complex(double re,
double im)
Creates a new Complex from real and imaginary parts. |
ComplexBusted |
conj()
Returns the Complex conjugate of a Complex object. |
static ComplexBusted |
conj(ComplexBusted z)
Returns the Complex conjugate of a Complex number. |
ComplexBusted |
copy()
|
static ComplexBusted |
cos(ComplexBusted z)
Returns the cosine of a Complex number. |
static ComplexBusted |
cosh(ComplexBusted z)
Returns the hyperbolic cosine of a Complex number. |
ComplexBusted |
div(ComplexBusted z)
Returns the division of two Complex values. |
ComplexBusted |
div(double d)
Returns the division of a Complex value by a double value. |
double |
doubleValue()
Returns the value of the real part of the specified number as a double. |
boolean |
equals(ComplexBusted z)
Decides if two Complex numbers are "sufficiently" alike to be considered equal. |
boolean |
equals(ComplexBusted z,
double tol)
Decides if two Complex numbers are "sufficiently" alike to be considered equal. |
static ComplexBusted |
exp(ComplexBusted z)
Returns the exponential number e (i.e., 2.718...) raised to the power of the Complex value z. |
float |
floatValue()
Returns the value of the real part of the specified number as a float. |
double |
getIm()
|
double |
getRe()
|
double |
im()
Extracts the imaginary part of a Complex object as a double. |
static double |
im(ComplexBusted z)
Returns the imaginary part of a Complex as a double. |
int |
intValue()
Returns the value of the real part of the specified number as an int. |
ComplexBusted |
inv()
Returns the reciprocal of a Complex number (1/z). |
static ComplexBusted |
inv(ComplexBusted z)
Returns the reciprocal of a Complex number (1/z). |
ComplexBusted |
inverse()
|
boolean |
isInfinite()
Returns true if either the real or imaginary component of this Complex has an infinite value. |
boolean |
isNaN()
Returns true if either the real or the imaginary component of this Complex is a Not-a-Number (NaN) value. |
static ComplexBusted |
log(ComplexBusted z)
Returns the principal natural logarithm of a Complex number. |
long |
longValue()
Returns the value of the real part of the specified number as a long. |
double |
magnitude()
|
ComplexBusted |
minus(ComplexBusted b)
|
ComplexBusted |
mul(ComplexBusted z)
Returns the product of two Complex values. |
ComplexBusted |
mul(double d)
Returns the product of a Complex and a double value. |
ComplexBusted |
neg()
Returns the negative of a Complex value. |
static double |
norm(ComplexBusted z)
Returns the L2 norm of a Complex number, which is the sum of the squares of the real and imaginary parts. |
double |
phase()
Returns the phase of a Complex object. |
static double |
phase(ComplexBusted c)
Returns the phase of a Complex value. |
ComplexBusted |
plus(ComplexBusted b)
|
static ComplexBusted |
polar(double r,
double theta)
Returns a new Complex from a magnitude and angle. |
ComplexBusted |
pow(ComplexBusted exponent)
Returns the Complex base raised to the power of the Complex exponent. |
static ComplexBusted |
pow(ComplexBusted base,
ComplexBusted exponent)
Returns the Complex base raised to the power of the Complex exponent. |
static ComplexBusted |
pow(ComplexBusted base,
double exponent)
Returns the Complex base raised to the power of the double exponent. |
ComplexBusted |
pow(double exponent)
Returns the Complex value raised to the power of the double exponent. |
static ComplexBusted |
pow(double base,
ComplexBusted exponent)
Returns the double base raised to the power of the Complex exponent. |
void |
print()
|
void |
print(java.lang.String msg)
|
double |
re()
Extracts the real part of a Complex object as a double. |
static double |
re(ComplexBusted z)
Returns the real part of a Complex as a double. |
void |
setIm(double im)
Sets a double value into the imaginary part of a Complex object. |
void |
setRe(double re)
Sets a double value into the real part of a Complex object. |
void |
setZ(double re,
double im)
Sets two double values into the real and imaginary parts of a Complex object. |
short |
shortValue()
Returns the value of the real part of the specified number as a short. |
static ComplexBusted |
sin(ComplexBusted z)
Returns the sine of a Complex number. |
static ComplexBusted |
sinh(ComplexBusted z)
Returns the hyperbolic sine of a Complex number. |
static ComplexBusted |
sqrt(ComplexBusted z)
Returns the square root of a Complex value. |
double |
square()
|
ComplexBusted |
sub(ComplexBusted z)
Returns the difference of two Complex values. |
ComplexBusted |
sub(double d)
Returns the difference between a Complex and a double value. |
static ComplexBusted |
tan(ComplexBusted z)
Returns the tangent of a Complex number. |
static ComplexBusted |
tanh(ComplexBusted z)
Returns the hyperbolic tangent of a Complex number. |
ComplexBusted |
times(ComplexBusted b)
|
java.lang.String |
toString()
Converts a Complex value into a String of the form (re + iim). |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final ComplexBusted I
public static final ComplexBusted J
public double re
public double im
| Constructor Detail |
|---|
public ComplexBusted()
public ComplexBusted(double re)
re - The real number
complex(double)public ComplexBusted(ComplexBusted z)
z - A Complex value
public ComplexBusted(double re,
double im)
re - Real partim - Imaginary part
complex(double, double)| Method Detail |
|---|
public byte byteValue()
byte. This may involve rounding.
byteValue in class java.lang.Numberbyte.public double doubleValue()
double.
doubleValue in class java.lang.Numberdouble.public float floatValue()
float.
This may involve rounding.
floatValue in class java.lang.Numberfloat.public int intValue()
int.
This may involve rounding.
intValue in class java.lang.Numberint.public long longValue()
long.
This may involve rounding.
longValue in class java.lang.Numberlong.public short shortValue()
short.
This may involve rounding.
shortValue in class java.lang.Numbershort.public java.lang.String toString()
toString in class java.lang.Objectpublic static double abs(ComplexBusted z)
z - a Complex number
abs()public static double arg(ComplexBusted z)
z - Complex number
arg()public static ComplexBusted acos(ComplexBusted z)
acos(z) = -i * log( z + i * sqrt(1 - z*z) )
z - a Complex number
cos(ComplexBusted)public static ComplexBusted acosh(ComplexBusted z)
acosh(z) = log(z + sqrt(z*z - 1))
z - a Complex number
cosh(ComplexBusted)public static ComplexBusted asin(ComplexBusted z)
asin(z) = -i * log(i*z + sqrt(1 - z*z))
z - a Complex number
sin(ComplexBusted)public static ComplexBusted asinh(ComplexBusted z)
asinh(z) = log(z + sqrt(z*z + 1))
z - a Complex number
sinh(ComplexBusted)public static ComplexBusted atan(ComplexBusted z)
atan(z) = -i/2 * log( (i-z)/(i+z) )
z - a Complex number
tan(ComplexBusted)public static ComplexBusted atanh(ComplexBusted z)
atanh(z) = 1/2 * log( (1+z)/(1-z) )
z - a Complex number
tanh(ComplexBusted)public static ComplexBusted complex(double re)
re - real part
complex(double, double)
public static ComplexBusted complex(double re,
double im)
re - Real partim - Imaginary part
complex(double)public static ComplexBusted conj(ComplexBusted z)
z - Complex input parameter
public static ComplexBusted cos(ComplexBusted z)
cos(z) = ( exp(i*z) + exp(-i*z) ) / (2*i)
z - an Complex angle
acos(ComplexBusted)public static ComplexBusted cosh(ComplexBusted z)
cosh(z) = ( exp(z) + exp(-z) ) / 2
z - a Complex value
acosh(ComplexBusted)public static ComplexBusted exp(ComplexBusted z)
Complex value z.
z - a double value.
log(ComplexBusted)public static double im(ComplexBusted z)
z - Complex number
im()public static ComplexBusted inv(ComplexBusted z)
z - Complex number
public static ComplexBusted log(ComplexBusted z)
z - a Complex number.
z, the natural logarithm of
z.exp(ComplexBusted)public static double norm(ComplexBusted z)
z - a Complex number
public static double phase(ComplexBusted c)
public static ComplexBusted polar(double r,
double theta)
r - Magnitudetheta - Angle (in radians)
public static ComplexBusted pow(ComplexBusted base,
double exponent)
base - The Complex base valueexponent - The double exponent
pow(double, ComplexBusted),
pow(ComplexBusted , ComplexBusted)
public static ComplexBusted pow(double base,
ComplexBusted exponent)
base - The double base valueexponent - The Complex exponent
pow(ComplexBusted , double),
pow(ComplexBusted , ComplexBusted)
public static ComplexBusted pow(ComplexBusted base,
ComplexBusted exponent)
base - The Complex base valueexponent - The Complex exponent
pow(double, ComplexBusted),
pow(ComplexBusted , double)public static double re(ComplexBusted z)
z - Complex number
re()public static ComplexBusted sin(ComplexBusted z)
sin(z) = ( exp(i*z) - exp(-i*z) ) / (2*i)
z - an angle, in radians.
asin(ComplexBusted)public static ComplexBusted sinh(ComplexBusted z)
sinh(z) = ( exp(z) - exp(-z) ) / 2
z - a Complex value
asinh(ComplexBusted)public static ComplexBusted sqrt(ComplexBusted z)
Complex value.
z - a Complex value.
z.public static ComplexBusted tan(ComplexBusted z)
tan(z) = sin(z) / cos(z)
z - a Complex angle
atan(ComplexBusted)public static ComplexBusted tanh(ComplexBusted z)
tanh(z) = sinh(z) / cosh(z)
z - a Complex value
atanh(ComplexBusted)public double re()
re(ComplexBusted)public double im()
im(ComplexBusted)public void setIm(double im)
im(),
setRe(double),
setZ(double,double)public void setRe(double re)
re(),
setIm(double),
setZ(double,double)
public void setZ(double re,
double im)
re(),
setRe(double),
setIm(double)public double abs()
abs(ComplexBusted),
arg(),
arg(ComplexBusted)public double arg()
arg(ComplexBusted)public ComplexBusted conj()
conj(ComplexBusted)public ComplexBusted add(ComplexBusted z)
z1 + z2 + z3 == z1.add(z2).add(z3)
z - A Complex number
add(double),
sub(ComplexBusted),
sub(double),
mul(ComplexBusted),
mul(double),
div(ComplexBusted),
div(double)public ComplexBusted add(double d)
d - A double value
add(ComplexBusted),
sub(ComplexBusted),
sub(double),
mul(ComplexBusted),
mul(double),
div(ComplexBusted),
div(double)public ComplexBusted sub(ComplexBusted z)
z1 - z2 + z3 == z1.sub(z2).add(z3)
z - A Complex number
add(ComplexBusted),
add(double),
sub(double),
mul(ComplexBusted),
mul(double),
div(ComplexBusted),
div(double)public ComplexBusted sub(double d)
d - A double value
add(ComplexBusted),
add(double),
sub(ComplexBusted),
mul(ComplexBusted),
mul(double),
div(ComplexBusted),
div(double)public ComplexBusted mul(ComplexBusted z)
z1 * z2 / z3 == z1.mul(z2).div(z3)
z - A Complex number
add(ComplexBusted),
add(double),
sub(ComplexBusted),
sub(double),
mul(double),
div(ComplexBusted),
div(double)public ComplexBusted mul(double d)
d - A double value
add(ComplexBusted),
add(double),
sub(ComplexBusted),
sub(double),
mul(ComplexBusted),
div(ComplexBusted),
div(double)public ComplexBusted div(ComplexBusted z)
z1 * z2 / z3 == z1.mul(z2).div(z3)
z - A Complex number
add(ComplexBusted),
add(double),
sub(ComplexBusted),
sub(double),
mul(ComplexBusted),
mul(double),
div(double)public ComplexBusted div(double d)
d - A double number
add(ComplexBusted),
add(double),
sub(ComplexBusted),
sub(double),
mul(ComplexBusted),
mul(double),
div(ComplexBusted)public ComplexBusted inv()
public ComplexBusted neg()
public double phase()
public ComplexBusted pow(double exponent)
exponent - The double exponent
pow(ComplexBusted),
pow(ComplexBusted , double),
pow(double, ComplexBusted),
pow(ComplexBusted , ComplexBusted)public ComplexBusted pow(ComplexBusted exponent)
exponent - The Complex exponent
pow(double),
pow(ComplexBusted , double),
pow(double, ComplexBusted),
pow(ComplexBusted , ComplexBusted)public boolean isInfinite()
public boolean isNaN()
public boolean equals(ComplexBusted z)
z - A Complex number
equals(ComplexBusted ,double)
public boolean equals(ComplexBusted z,
double tol)
z - A Complex numbertol - The tolerance with which to comapare the two numbers
equals(ComplexBusted)public int compareTo(ComplexBusted anotherComplex)
Complex values numerically according to their
absolute values.
anotherComplex - the Complex to be compared.
0 if the absolute value of the argument
anotherComplex is equal to the absolute value of
this Complex; a value less than 0 if
the absolute value of this Complex is
numerically less than the Complex argument; and a
the absolute value of this Complex is
numerically greater than the Complex argument.
(signed comparison).Comparablepublic int compareTo(java.lang.Object o)
Complex to another Object. If the Object is a
Complex,
this function behaves like compareTo(Complex). Otherwise,
it throws a ClassCastException (as Complex values
are comparable only to other Complex values).
compareTo in interface java.lang.Comparableo - the Object to be compared.
0 if the absolute value of the argument
Object is equal to the absolute value of
this Complex; a value less than 0 if
the absolute value of this Complex is
numerically less than the Object argument; and a
the absolute value of this Complex is
numerically greater than the Object argument.
(signed comparison).
ClassCastException - if the argument is not a
Complex.Comparablepublic void addReal(double _x)
public void addImaginary(double _i)
public double getRe()
public double getIm()
public ComplexBusted plus(ComplexBusted b)
public ComplexBusted minus(ComplexBusted b)
public ComplexBusted times(ComplexBusted b)
public ComplexBusted inverse()
public double square()
public double magnitude()
public ComplexBusted copy()
public void print()
public void print(java.lang.String msg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||