|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.util.Complex
public class Complex
This is a complex number class with the essential features needed for computations. The real and imaginary parts can be accessed directly for fast operation. (See ComplexImm for an immutable version of a complex number class.) Several of the common complex number operations are provided as static methods. New instances of Complex are returned by these methods. Code from book: Lindsey, Tolliver, Lindblad, "JavaTech, an Introduction to Scientific and Technical Computing with Java" with some minor modifications.
Field Summary | |
---|---|
double |
img
|
double |
real
|
Constructor Summary | |
---|---|
Complex(double r,
double i)
Constructor that initializes the values. |
Method Summary | |
---|---|
void |
add(Complex cvalue)
Define a complex add method. |
static Complex |
add(Complex cvalue1,
Complex cvalue2)
Define a static add method that creates a a new Complex object with the sum. |
void |
divide(Complex cvalue)
Divide this complex object by the complex argument. |
static Complex |
divide(Complex cvalue1,
Complex cvalue2)
Define a static divide method that creates a a new Complex object with the result of cvalue1/cvalue2. |
boolean |
equals(java.lang.Object obj)
Check for the equality of this object with that of the argument. |
double |
getImg()
Get method for imaginary part. |
double |
getReal()
Get method for real part. |
int |
hashCode()
Returns a hash code value for the object. |
double |
modulus()
Provide the magnitude of the complex value. |
void |
multiply(Complex cvalue)
Multiply this complex object by the complex argument. |
static Complex |
multiply(Complex cvalue1,
Complex cvalue2)
Define a static multiply method that creates a a new Complex object with the product. |
void |
subtract(Complex cvalue)
Define a complex subtract method. |
static Complex |
subtract(Complex cvalue1,
Complex cvalue2)
Define a static subtract method that creates a a new Complex object equal to cvalue1 - cvalue2. |
java.lang.String |
toString()
Return a string representation of the complex value. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public double real
public double img
Constructor Detail |
---|
public Complex(double r, double i)
Method Detail |
---|
public double getReal()
public double getImg()
public void add(Complex cvalue)
public void subtract(Complex cvalue)
public static Complex add(Complex cvalue1, Complex cvalue2)
public static Complex subtract(Complex cvalue1, Complex cvalue2)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public double modulus()
public void multiply(Complex cvalue)
public static Complex multiply(Complex cvalue1, Complex cvalue2)
public void divide(Complex cvalue)
public static Complex divide(Complex cvalue1, Complex cvalue2)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |