org.opensourcephysics.sip.ch02
Class Complex

java.lang.Object
  extended by org.opensourcephysics.sip.ch02.Complex

public class Complex
extends java.lang.Object

Complex defines a new data type that models a complex number.


Constructor Summary
Complex()
          Constructs a complex number.
Complex(double real, double imag)
          Constructs a complex number with given real and imaginary parts.
 
Method Summary
 Complex add(Complex c)
          Adds a complex number to this complex number and returns the new complex number.
 void conjugate()
          Conjugates this complex number.
 Complex multiply(Complex c)
          Multiples this complex number by another complex number and returns the new complex number.
 java.lang.String toString()
          Represents this complex number as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex()
Constructs a complex number.


Complex

public Complex(double real,
               double imag)
Constructs a complex number with given real and imaginary parts.

Parameters:
real - double
imag - double
Method Detail

conjugate

public void conjugate()
Conjugates this complex number. The current complex number is changed.


add

public Complex add(Complex c)
Adds a complex number to this complex number and returns the new complex number. The current complex number is not changed.

Parameters:
c - Complex
Returns:
Complex

multiply

public Complex multiply(Complex c)
Multiples this complex number by another complex number and returns the new complex number. The current complex number is not changed.

Parameters:
c - Complex
Returns:
Complex

toString

public java.lang.String toString()
Represents this complex number as a string.

Overrides:
toString in class java.lang.Object
Returns:
String