Class Complex

java.lang.Object
  extended by Complex

public class Complex
extends java.lang.Object

Immutable, complex numbers. A Complex consists of a real and imaginary part, called Cartesian coordinates. The Complex class provides methods for arithmetic such as: add, subtract, multiply, divide, negate and invert. Also provided are complex functions sin, cos, tan, asin, acos, atan, sqrt, log, exp, pow, sinh, cosh, tanh, atanh. Source code Complex.java


Constructor Summary
Complex()
          cartesian coordinates real and imaginary are NaN
Complex(Complex z)
          construct a copy of a Complex object
Complex(double x)
          real value, imaginary=0.0
Complex(double x, double y)
          cartesian coordinates real and imaginary
 
Method Summary
 double abs()
          compute the absolute value of a complex number
 Complex acos()
          compute the arccosine of a complex number
 Complex add(Complex z)
          add complex numbers
 Complex add(double d)
          add a double to a complex number
 double argument()
          extract the argument of the complex number
 Complex asin()
          compute the arcsine of a complex number
 Complex atan()
          compute the arctangent of a complex number
 Complex atanh()
          compute the inverse hyperbolic tangent of a complex number
 Complex cartesian()
          convert polar to cartesian
 Complex conjugate()
          conjugate the complex number
 Complex cos()
          compute the cosine of the complex number
 Complex cosh()
          compute the hyperbolic cosine of the complex number
 Complex divide(Complex z)
          divide the complex number by z
 Complex divide(double d)
          divide the complex number by the double d
 boolean equals(Complex z)
          compare complex numbers for equality
 Complex exp()
          compute e to the power of the complex number
 double imaginary()
          extract the imaginary part of the complex number
 Complex invert()
          invert the complex number
 Complex log()
          compute the natural logarithm of the complex number
 double magnitude()
          extract the magnitude of the complex number
 Complex multiply(Complex z)
          multiply complex numbers
 Complex multiply(double d)
          multiply a complex number by a double
 Complex negate()
          negate the complex number
static Complex parseComplex(java.lang.String s)
          convert text representation to a Complex.
 Complex polar()
          convert cartesian to polar
 Complex pow(Complex z)
          compute the complex number raised to the power z
 Complex pow(double d)
          compute the complex number raised to the power double d
 double real()
          extract the real part of the complex number
 Complex sin()
          compute the sin of the complex number
 Complex sinh()
          compute the hyperbolic sin of the complex number
 Complex sqrt()
          compute the square root of the complex number
 Complex subtract(Complex z)
          subtract z from the complex number
 Complex subtract(double d)
          subtract the double d from the complex number
 Complex tan()
          compute the tangent of the complex number
 Complex tanh()
          compute the hyperbolic tangent of the complex number
 java.lang.String toString()
          convert a complex number to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex()
cartesian coordinates real and imaginary are NaN


Complex

public Complex(Complex z)
construct a copy of a Complex object


Complex

public Complex(double x)
real value, imaginary=0.0


Complex

public Complex(double x,
               double y)
cartesian coordinates real and imaginary

Method Detail

polar

public Complex polar()
convert cartesian to polar


cartesian

public Complex cartesian()
convert polar to cartesian


real

public double real()
extract the real part of the complex number


imaginary

public double imaginary()
extract the imaginary part of the complex number


magnitude

public double magnitude()
extract the magnitude of the complex number


argument

public double argument()
extract the argument of the complex number


add

public Complex add(Complex z)
add complex numbers


add

public Complex add(double d)
add a double to a complex number


subtract

public Complex subtract(Complex z)
subtract z from the complex number


subtract

public Complex subtract(double d)
subtract the double d from the complex number


negate

public Complex negate()
negate the complex number


multiply

public Complex multiply(Complex z)
multiply complex numbers


multiply

public Complex multiply(double d)
multiply a complex number by a double


divide

public Complex divide(Complex z)
divide the complex number by z


divide

public Complex divide(double d)
divide the complex number by the double d


invert

public Complex invert()
invert the complex number


conjugate

public Complex conjugate()
conjugate the complex number


abs

public double abs()
compute the absolute value of a complex number


equals

public boolean equals(Complex z)
compare complex numbers for equality


toString

public java.lang.String toString()
convert a complex number to a String. Complex z = new Complex(1.0,2.0); System.out.println("z="+z);

Overrides:
toString in class java.lang.Object

parseComplex

public static Complex parseComplex(java.lang.String s)
convert text representation to a Complex. input format (real_double,imaginary_double)


exp

public Complex exp()
compute e to the power of the complex number


log

public Complex log()
compute the natural logarithm of the complex number


sqrt

public Complex sqrt()
compute the square root of the complex number


pow

public Complex pow(Complex z)
compute the complex number raised to the power z


pow

public Complex pow(double d)
compute the complex number raised to the power double d


sin

public Complex sin()
compute the sin of the complex number


cos

public Complex cos()
compute the cosine of the complex number


tan

public Complex tan()
compute the tangent of the complex number


asin

public Complex asin()
compute the arcsine of a complex number


acos

public Complex acos()
compute the arccosine of a complex number


atan

public Complex atan()
compute the arctangent of a complex number


sinh

public Complex sinh()
compute the hyperbolic sin of the complex number


cosh

public Complex cosh()
compute the hyperbolic cosine of the complex number


tanh

public Complex tanh()
compute the hyperbolic tangent of the complex number


atanh

public Complex atanh()
compute the inverse hyperbolic tangent of a complex number