DRCL J-Sim API

drcl.util.scalar
Class Complex

java.lang.Object
  extended bydrcl.util.scalar.Complex

public class Complex
extends java.lang.Object

This class implements complex numbers. It provides basic operations such as addition, subtraction, multiplication, division and absolute values.

Version:
1.0 02/04/2004
Author:
Honghai Zhang

Constructor Summary
Complex()
          Constructs a Complex 0.
Complex(Complex z)
          Constructs a Comlex equal to z.
Complex(double re, double im)
          Constructs a Complex re + i * im.
 
Method Summary
static double abs(Complex z)
          Returns the absolute value (modulus) of a Complex, |z|.
static Complex add(Complex y, Complex z)
          Returns the sum of Complex y and Complex z.
static Complex add(Complex y, double x)
          Returns the sum of Complex y and double x.
static Complex add(double x, Complex y)
          Returns the sum of double x and Complex y.
 Complex conjugate()
          Returns the conjugate of this current Complex.
static Complex divide(Complex y, Complex z)
          Returns a Complex y/z for Complex y and Complex z.
 double imag()
          Returns the imaginary part of the Complex.
static Complex multiply(Complex y, Complex z)
          Returns the product of two complex number
static Complex multiply(Complex z, double x)
          Returns the product of a complex z with a real number x.
static Complex multiply(double x, Complex z)
          Returns the product of a real number x with a complex z.
 double real()
          Returns the real part of the Complex.
 void setImag(double im)
          Sets the Imaginary part of the Complex number.
 void setReal(double re)
          Sets the real part of the Complex number.
static Complex sqrt(Complex z)
          Returns the square root of a Complex number z.
static Complex subtract(Complex y, Complex z)
          Returns y -z for Complex y and Complex z.
static Complex subtract(Complex y, double x)
          Returns y - x for Complex y and double x.
static Complex subtract(double x, Complex z)
          Returns x - z for double x and Complex z.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Complex

public Complex()
Constructs a Complex 0.


Complex

public Complex(double re,
               double im)
Constructs a Complex re + i * im.


Complex

public Complex(Complex z)
Constructs a Comlex equal to z.

Method Detail

setReal

public void setReal(double re)
Sets the real part of the Complex number.


setImag

public void setImag(double im)
Sets the Imaginary part of the Complex number.


abs

public static double abs(Complex z)
Returns the absolute value (modulus) of a Complex, |z|.


conjugate

public Complex conjugate()
Returns the conjugate of this current Complex.


real

public double real()
Returns the real part of the Complex.


imag

public double imag()
Returns the imaginary part of the Complex.


multiply

public static Complex multiply(Complex y,
                               Complex z)
Returns the product of two complex number


multiply

public static Complex multiply(Complex z,
                               double x)
Returns the product of a complex z with a real number x.


multiply

public static Complex multiply(double x,
                               Complex z)
Returns the product of a real number x with a complex z.


sqrt

public static Complex sqrt(Complex z)
Returns the square root of a Complex number z. Its real part is always nonegative and imaginary part is nonnegative if it can be chosen.


divide

public static Complex divide(Complex y,
                             Complex z)
Returns a Complex y/z for Complex y and Complex z.


add

public static Complex add(Complex y,
                          Complex z)
Returns the sum of Complex y and Complex z.


add

public static Complex add(Complex y,
                          double x)
Returns the sum of Complex y and double x.


add

public static Complex add(double x,
                          Complex y)
Returns the sum of double x and Complex y.


subtract

public static Complex subtract(Complex y,
                               Complex z)
Returns y -z for Complex y and Complex z.


subtract

public static Complex subtract(Complex y,
                               double x)
Returns y - x for Complex y and double x.


subtract

public static Complex subtract(double x,
                               Complex z)
Returns x - z for double x and Complex z.


DRCL J-Sim API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~