// (C) Copyright Jack Culpepper 1997
// This code may not be distributed without permission.
package mandel;

import java.io.*;

public class Complex implements Serializable {
  public double real;
  public double imag;

  public Complex( double real, double imag ) {
    this.real = real;
    this.imag = imag;
  }

  public Complex mul( Complex c ) {
    return new Complex( ( real * c.real ) - ( imag * c.imag ), 
                        ( real * c.imag ) + ( imag * c.real ) );
  }

  public Complex add( Complex c ) {
    return new Complex( real + c.real, imag + c.imag );
  }

  public Complex sub( Complex c ) {
    return new Complex( real - c.real, imag - c.imag );
  }

  public double abs() {
    return Math.sqrt( ( real * real ) - ( imag * imag ) );
  }
}

