|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmae.tut.num.Number
mae.tut.num.Complex
Represents a complex number, implemented as x+iy.
Where x is the real part, y is the imaginary part.
Complex numbers can be compared for equality, but order is not defined.
| Constructor Summary | |
Complex(float r,
float i)
Use factory method Factory.newComplex(float,float),
rather than this constructor |
|
| Method Summary | |
Number |
add(Number n)
Adds this Number to another Number n and returns the result. |
float |
angle()
Theta angle of polar coordinates, in the range of -90 through 270 degrees |
boolean |
equals(java.lang.Object x)
Compares this Number to another Object for equality. |
static Complex |
fromNumber(Number n)
Converts Number n into Complex, if not already Complex |
static Number |
fromPolar(float r,
float a)
Makes a (Complex) Number from polar coordinates |
Number |
inverse()
Returns the multiplicative inverse of this Number. |
Number |
mult(Number n)
Multiplies this Number by another Number n and returns the result. |
java.lang.String |
toPolar()
String representation of this Number in polar coordinates |
java.lang.String |
toString()
String representation of this Number in cartesian coordinates |
float |
value()
Distance to origin (rho) |
| Methods inherited from class mae.tut.num.Number |
hashCode |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Complex(float r,
float i)
Factory.newComplex(float,float),
rather than this constructor
| Method Detail |
public Number add(Number n)
Number
If this Number and n are of the same type, returned result
must be of that type.
If this and n are of different types, returned result
must be as narrow as possible.
But in all cases add(n)
and n.add(this) must return the same Number.
add in class Numberpublic Number mult(Number n)
Number
If this Number and n are of the same type, returned result
must be of that type.
If this and n are of different types, returned result
must be as narrow as possible.
But in all cases mult(n)
and n.mult(this) must return the same Number.
mult in class Numberpublic Number inverse()
Number
For any Number n, if inverse() is defined,
n.inverse().inverse() must be equal to n.
Also n.inverse().mult(n).value() must be 1.0
inverse in class Numberpublic float value()
value in class Numberpublic float angle()
public java.lang.String toPolar()
public java.lang.String toString()
public boolean equals(java.lang.Object x)
The result is true if and only if the argument (not null)
is a Complex with the same field values
OR this Number
happens to be real with the same value as x.
public static Number fromPolar(float r,
float a)
public static Complex fromNumber(Number n)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||