org.metasyntactic.math
Class Complex
java.lang.Object
|
+--org.metasyntactic.math.Complex
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class Complex
- extends java.lang.Object
- implements java.lang.Cloneable, java.io.Serializable
The lack of built-in complex arithmetic in Java is a nuisance for numerical
work. Even in languages like FORTRAN that have complex data types, it is
disconcertingly common to encounter complex operations that produce overflows
or underflows when both the complex operands and the complex result are
perfectly representable. This occurs, I think, because software companies
assign inexperienced programmers to what they believe to be the perfectly
trivial task of implementing complex arithmetic.
The routines contianed in this class are the best known ones for effeciently
and correctly determining values for complex functions, while at the same
time avoiding over and underflow problems
All instances of Complex Number are immutable (just like java primitives).
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
I
public static final Complex I
ZERO
public static final Complex ZERO
Complex
public Complex(double real,
double imaginary)
- Parameters:
real
- The real component of this Complex numberimaginary
- The imaginary component of this Compex number
Complex
public Complex(Complex complex)
- Copy constructor
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in class java.lang.Object
equals
public boolean equals(Complex c)
add
public Complex add(Complex b)
subtract
public Complex subtract(Complex b)
multiply
public Complex multiply(Complex b)
modulus
public double modulus()
divide
public Complex divide(Complex b)
squareRoot
public Complex squareRoot()
- Returns:
- The square root of this Complex number
conjugate
public Complex conjugate()
getReal
public double getReal()
- Returns:
- The real component of this Complex number
getImaginary
public double getImaginary()
- Returns:
- The imaginary component of this Compex number
main
public static void main(java.lang.String[] args)