qcnn
Class complex
java.lang.Object
qcnn.complex
public class complex
- extends java.lang.Object
Compilation: javac complex.java
Execution: java complex
Data type for complex numbers.
The data type is "immutable" so once you create and initialize
a complex object, you cannot change it. The "final" keyword
when declaring re and im enforces this rule, making it a
compile-time error to change the .re or .im fields after
they've been initialized.
% java complex
a = a = 5.0 + 6.0i
b = -3.0 + 4.0i
c = -39.0 + 2.0i
d = -39.0 + -2.0i
e = 5.0
Constructor Summary |
complex(double real,
double imag)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
complex
public complex(double real,
double imag)
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
abs
public double abs()
plus
public complex plus(complex b)
minus
public complex minus(complex b)
times
public complex times(complex b)
times
public complex times(double alpha)
conjugate
public complex conjugate()
plus
public static complex plus(complex a,
complex b)
modulus
public double modulus()
- Returns:
- The modulus of this complex number
modulusSquared
public double modulusSquared()
- Returns:
- The square of the modulus of this complex number
main
public static void main(java.lang.String[] args)