drasys.or
Class Complex

java.lang.Object
  |
  +--drasys.or.Complex

public class Complex
extends java.lang.Object
implements ComplexI

An implementation of a complex value.


Field Summary
 double imag
           
 double real
           
 
Constructor Summary
Complex()
           
Complex(ComplexI c)
           
Complex(double r)
           
Complex(double r, double i)
           
 
Method Summary
 Complex add(ComplexI a)
          Compute: this = this + a;
static Complex add(ComplexI a, ComplexI b)
          Compute: result = a + b;
static Complex add(ComplexI a, ComplexI b, Complex results)
          Compute: result = a + b;
 Complex add(double r)
          Compute: this = this + (r,0);
 Complex add(double r, double i)
          Compute: this = this + (r,i);
static Complex add(double r1, double i1, double r2, double i2, Complex results)
          Compute: result = (r1,i1) + (r2,i2);
 Complex conjugate()
          Compute: this = conjugate(this).
 Complex divide(ComplexI a)
          Compute: this = this / a;
static Complex divide(ComplexI a, ComplexI b)
          Compute: result = a / b;
static Complex divide(ComplexI a, ComplexI b, Complex results)
          Compute: result = a / b;
 Complex divide(double r)
          Compute: this = this / (r,0);
 Complex divide(double r, double i)
          Compute: this = this / (r,i);
static Complex divide(double r1, double i1, double r2, double i2, Complex results)
          Compute: result = (r1,i1) / (r2,i2);
 boolean equals(ComplexI a)
          returns 'true' if this is equal to 'a'.
static boolean equals(ComplexI a, ComplexI b, double epsilon)
          returns 'true' if a is equal to b to within 'epsilon'.
 boolean equals(ComplexI a, double epsilon)
          returns 'true' if this is equal to 'a' to within 'epsilon'.
 boolean equals(double r, double i)
          returns 'true' if this is equal to (r,i).
 boolean equals(double r, double i, double epsilon)
          returns 'true' if this is equal to (r,i) to within 'epsilon'.
static boolean equals(double r1, double i1, double r2, double i2, double epsilon)
          returns 'true' if (r1,i1) is equal to (r2,i2) to within 'epsilon'.
 boolean equals(java.lang.Object o)
          returns 'true' this is equal to 'o'.
 double getImag()
          Return the imaginary part;
 double getReal()
          Return the real part.
 Complex invert()
          Compute: this = (1,0)/this.
static Complex invert(ComplexI a)
          Compute: new = (1,0)/a.
static Complex invert(ComplexI a, Complex results)
          Compute: results = (1,0)/a.
static Complex invert(double real, double imag, Complex results)
          Compute: results = (1,0)/(real,imag).
 double modulus()
          Computes sqrt(this.real^2 + this.imag^2).
static double modulus(ComplexI a)
          Computes sqrt(real^2 + imag^2).
static double modulus(double real, double imag)
          Computes sqrt(real^2 + imag^2).
 Complex multiply(ComplexI a)
          Compute: this = this * a;
static Complex multiply(ComplexI a, ComplexI b)
          Compute: result = a * b;
static Complex multiply(ComplexI a, ComplexI b, Complex results)
          Compute: result = a * b;
 Complex multiply(double r)
          Compute: this = this * (r,0);
 Complex multiply(double r, double i)
          Compute: this = this * (r,i);
static Complex multiply(double r1, double i1, double r2, double i2, Complex results)
          Compute: result = (r1,i1) * (r2,i2);
 Complex set(ComplexI a)
          Sets this equal to a;
 Complex set(double r, double i)
          Sets this equal to a;
 Complex sqrt()
          Compute: this = this^0.5.
static Complex sqrt(ComplexI a)
          Compute: new = a^0.5.
static Complex sqrt(ComplexI a, Complex results)
          Compute: results = a^0.5.
static Complex sqrt(double real, double imag, Complex results)
          Compute: results = (real,imag)^0.5.
 Complex subtract(ComplexI a)
          Compute: this = this - a;
static Complex subtract(ComplexI a, ComplexI b)
          Compute: result = a - b;
static Complex subtract(ComplexI a, ComplexI b, Complex results)
          Compute: result = a - b;
 Complex subtract(double r)
          Compute: this = this - (r,0);
 Complex subtract(double r, double i)
          Compute: this = this - (r,i);
static Complex subtract(double r1, double i1, double r2, double i2, Complex results)
          Compute: result = (r1,i1) - (r2,i2);
 java.lang.String toString()
          Returns a string representation of this complex number.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

real

public double real

imag

public double imag
Constructor Detail

Complex

public Complex()

Complex

public Complex(double r)

Complex

public Complex(double r,
               double i)

Complex

public Complex(ComplexI c)
Method Detail

modulus

public static double modulus(double real,
                             double imag)
Computes sqrt(real^2 + imag^2).

modulus

public static double modulus(ComplexI a)
Computes sqrt(real^2 + imag^2).

modulus

public double modulus()
Computes sqrt(this.real^2 + this.imag^2).

invert

public static Complex invert(double real,
                             double imag,
                             Complex results)
Compute: results = (1,0)/(real,imag).
Returns:
'results' if its not null, a new 'Complex' otherwise.

invert

public static Complex invert(ComplexI a)
Compute: new = (1,0)/a.
Returns:
A new 'Complex'.

invert

public static Complex invert(ComplexI a,
                             Complex results)
Compute: results = (1,0)/a.
Returns:
'results' if its not null, a new 'Complex' otherwise.

invert

public Complex invert()
Compute: this = (1,0)/this.
Returns:
this.

sqrt

public static Complex sqrt(double real,
                           double imag,
                           Complex results)
Compute: results = (real,imag)^0.5.
Returns:
'results' if its not null, a new 'Complex' otherwise.

sqrt

public static Complex sqrt(ComplexI a)
Compute: new = a^0.5.
Returns:
A new 'Complex'.

sqrt

public static Complex sqrt(ComplexI a,
                           Complex results)
Compute: results = a^0.5.
Returns:
'results' if its not null, a new 'Complex' otherwise.

sqrt

public Complex sqrt()
Compute: this = this^0.5.
Returns:
this.

conjugate

public Complex conjugate()
Compute: this = conjugate(this).
Returns:
this

add

public static Complex add(double r1,
                          double i1,
                          double r2,
                          double i2,
                          Complex results)
Compute: result = (r1,i1) + (r2,i2);
Returns:
'results' if its not null, a new 'Complex' otherwise.

add

public static Complex add(ComplexI a,
                          ComplexI b,
                          Complex results)
Compute: result = a + b;
Returns:
'results' if its not null, a new 'Complex' otherwise.

add

public static Complex add(ComplexI a,
                          ComplexI b)
Compute: result = a + b;
Returns:
A new 'Complex'.

add

public Complex add(double r,
                   double i)
Compute: this = this + (r,i);
Returns:
this

add

public Complex add(double r)
Compute: this = this + (r,0);
Returns:
this

add

public Complex add(ComplexI a)
Compute: this = this + a;
Returns:
this

subtract

public static Complex subtract(double r1,
                               double i1,
                               double r2,
                               double i2,
                               Complex results)
Compute: result = (r1,i1) - (r2,i2);
Returns:
'results' if its not null, a new 'Complex' otherwise.

subtract

public static Complex subtract(ComplexI a,
                               ComplexI b,
                               Complex results)
Compute: result = a - b;
Returns:
'results' if its not null, a new 'Complex' otherwise.

subtract

public static Complex subtract(ComplexI a,
                               ComplexI b)
Compute: result = a - b;
Returns:
A new 'Complex'.

subtract

public Complex subtract(double r,
                        double i)
Compute: this = this - (r,i);
Returns:
this

subtract

public Complex subtract(double r)
Compute: this = this - (r,0);
Returns:
this

subtract

public Complex subtract(ComplexI a)
Compute: this = this - a;
Returns:
this

multiply

public static Complex multiply(double r1,
                               double i1,
                               double r2,
                               double i2,
                               Complex results)
Compute: result = (r1,i1) * (r2,i2);
Returns:
'results' if its not null, a new 'Complex' otherwise.

multiply

public static Complex multiply(ComplexI a,
                               ComplexI b,
                               Complex results)
Compute: result = a * b;
Returns:
'results' if its not null, a new 'Complex' otherwise.

multiply

public static Complex multiply(ComplexI a,
                               ComplexI b)
Compute: result = a * b;
Returns:
A new 'Complex'.

multiply

public Complex multiply(double r,
                        double i)
Compute: this = this * (r,i);
Returns:
this

multiply

public Complex multiply(double r)
Compute: this = this * (r,0);
Returns:
this

multiply

public Complex multiply(ComplexI a)
Compute: this = this * a;
Returns:
this

divide

public static Complex divide(double r1,
                             double i1,
                             double r2,
                             double i2,
                             Complex results)
Compute: result = (r1,i1) / (r2,i2);
Returns:
'results' if its not null, a new 'Complex' otherwise.

divide

public static Complex divide(ComplexI a,
                             ComplexI b,
                             Complex results)
Compute: result = a / b;
Returns:
'results' if its not null, a new 'Complex' otherwise.

divide

public static Complex divide(ComplexI a,
                             ComplexI b)
Compute: result = a / b;
Returns:
A new 'Complex'.

divide

public Complex divide(double r,
                      double i)
Compute: this = this / (r,i);
Returns:
this

divide

public Complex divide(double r)
Compute: this = this / (r,0);
Returns:
this

divide

public Complex divide(ComplexI a)
Compute: this = this / a;
Returns:
this

set

public Complex set(double r,
                   double i)
Sets this equal to a;
Returns:
this

set

public Complex set(ComplexI a)
Sets this equal to a;
Returns:
this

getReal

public double getReal()
Return the real part.
Specified by:
getReal in interface ComplexI

getImag

public double getImag()
Return the imaginary part;
Specified by:
getImag in interface ComplexI

equals

public static boolean equals(double r1,
                             double i1,
                             double r2,
                             double i2,
                             double epsilon)
returns 'true' if (r1,i1) is equal to (r2,i2) to within 'epsilon'.

equals

public static boolean equals(ComplexI a,
                             ComplexI b,
                             double epsilon)
returns 'true' if a is equal to b to within 'epsilon'.

equals

public boolean equals(double r,
                      double i)
returns 'true' if this is equal to (r,i).

equals

public boolean equals(ComplexI a)
returns 'true' if this is equal to 'a'.

equals

public boolean equals(double r,
                      double i,
                      double epsilon)
returns 'true' if this is equal to (r,i) to within 'epsilon'.

equals

public boolean equals(ComplexI a,
                      double epsilon)
returns 'true' if this is equal to 'a' to within 'epsilon'.

equals

public boolean equals(java.lang.Object o)
returns 'true' this is equal to 'o'.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this complex number.
Overrides:
toString in class java.lang.Object


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com