net.grelf
Class Complex

java.lang.Object
  extended by net.grelf.Complex
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Complex
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Complex numbers and operations upon them.

See Also:
Serialized Form

Field Summary
 double im
          Imaginary part.
 double re
          Real part.
 
Constructor Summary
Complex(double re, double im)
           
 
Method Summary
 Complex add(Complex z)
          Adds z to this and also returns this, to be chainable.
 Complex add(double x)
          Adds real x to this and also returns this, to be chainable.
 Angle arg()
          Returns polar angle.
 Complex assign(Complex z)
          Sets this from z and also returns this, to be chainable.
 Complex clone()
          Returns a new Complex object with the same fields.
 Complex conjugate()
          Conjugates this and also returns this, to be chainable.
 Complex divide(Complex z)
          Divides this by z and returns this, to be chainable.
 Complex divide(double x)
          Divides this by real x and also returns this, to be chainable.
 boolean equals(java.lang.Object other)
           
static Complex expi(Angle theta)
          Get exp (i.theta) = cos (theta) + i.sin (theta).
static Complex expi(double theta)
          Get exp (i.theta) = cos (theta) + i.sin (theta).
 int hashCode()
           
 double mod()
          Returns |z| = root sum of squares of real and imaginary parts.
 Complex multiply(Complex z)
          Multiplies this by z and also returns this, to be chainable.
 Complex multiply(double x)
          Multiplies this by real x and also returns this, to be chainable.
 Complex subtract(Complex z)
          Subtracts z from this and also returns this, to be chainable.
 Complex subtract(double x)
          Subtracts real x from this and also returns this, to be chainable.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

re

public double re
Real part.


im

public double im
Imaginary part.

Constructor Detail

Complex

public Complex(double re,
               double im)
Method Detail

clone

public Complex clone()
Returns a new Complex object with the same fields.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

mod

public double mod()
Returns |z| = root sum of squares of real and imaginary parts.


arg

public Angle arg()
Returns polar angle.


conjugate

public Complex conjugate()
Conjugates this and also returns this, to be chainable.


assign

public Complex assign(Complex z)
Sets this from z and also returns this, to be chainable.


add

public Complex add(Complex z)
Adds z to this and also returns this, to be chainable.


add

public Complex add(double x)
Adds real x to this and also returns this, to be chainable.


subtract

public Complex subtract(Complex z)
Subtracts z from this and also returns this, to be chainable.


subtract

public Complex subtract(double x)
Subtracts real x from this and also returns this, to be chainable.


multiply

public Complex multiply(Complex z)
Multiplies this by z and also returns this, to be chainable.


multiply

public Complex multiply(double x)
Multiplies this by real x and also returns this, to be chainable.


divide

public Complex divide(Complex z)
Divides this by z and returns this, to be chainable.


divide

public Complex divide(double x)
Divides this by real x and also returns this, to be chainable.


expi

public static Complex expi(double theta)
Get exp (i.theta) = cos (theta) + i.sin (theta).


expi

public static Complex expi(Angle theta)
Get exp (i.theta) = cos (theta) + i.sin (theta).