infpp.fractal
Class Complex

java.lang.Object
  extended by infpp.fractal.Complex

public class Complex
extends java.lang.Object

The Complex class models a complex number. It provides the operations addition to a Complex, multiplication by a Complex factor, the square of a Complex and the square of the absolute value of a Complex.

Author:
both

Field Summary
 double im
          The Complex's imaginary part.
 double re
          The Complex's real part.
 
Constructor Summary
Complex(Complex c)
          Constructs a new Complex from a given Complex.
Complex(double re, double im)
          Constructs a new Complex from two doubles.
 
Method Summary
 void addTo(Complex increment)
          Increments this complex number.
 double getAbsSquare()
          Calculates the square of this complex number's absolute value.
 void multiplyBy(Complex factor)
          Multiplies this complex number by another.
 void square()
          Squares this complex number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

re

public double re
The Complex's real part.


im

public double im
The Complex's imaginary part.

Constructor Detail

Complex

public Complex(double re,
               double im)
Constructs a new Complex from two doubles.

Parameters:
re - the real part of the Complex
im - the imaginary part of the Complex

Complex

public Complex(Complex c)
Constructs a new Complex from a given Complex.

Parameters:
c - the given Complex
Method Detail

addTo

public void addTo(Complex increment)
Increments this complex number.

Parameters:
increment - the increment to add to this

multiplyBy

public void multiplyBy(Complex factor)
Multiplies this complex number by another.

Parameters:
factor - the factor to multiply this complex number by

square

public void square()
Squares this complex number.


getAbsSquare

public double getAbsSquare()
Calculates the square of this complex number's absolute value. This method is provided to avoid costly sqrt calulations.

Returns:
the square of this complex number's absolute value