All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class cmpsci197c.Complex
java.lang.Object
   |
   +----cmpsci197c.Complex
  -  public class Complex
  -  extends java.lang.Object
Simple complex number class.
 A complex number z = (x,y) has both a real component x and
 an imaginary component y.  Often z is written as x +iy where
 i is the solution to v^2 = -1.
  -  Author:
  
-  Brent Heeringa
   
  -   _imaginary _imaginary
-  
  
-   _real _real
-  
   
  -   Complex() Complex()
-   Default constructor creates the complex number z = (0,0)
  
-   Complex(double, double) Complex(double, double)
-   Creates the complex number z = (real, imaginary)
   
  -   clone() clone()
-   Clone procedure
 
  
-   conjugate() conjugate()
-   For any complex number z = (a,b) the conjugate 
 (usually denoted z-bar) is defined as (a,-b)
 
  
-   divide(Complex) divide(Complex)
-   Dividing two complex numbers z = (a,b) w = (c,d) is defined as
 z * w-bar / |w|^2
 The |w|^2 is equivalent to w * w.conjugate() where 
 the conjugate of w = (c,d) is defined as (c,-d)
 Note that multiplying by the conjugate produces a non-negative real
 number so that we can easily divide the real and imaginary
 components of the imaginary numbers.
  
-   equals(Complex) equals(Complex)
-   Two complex numbers are equal if and only if both their
 real and imaginary components are equal
 
  
-   equals(Object) equals(Object)
-   Two complex numbers are equal if both their
 real and imaginary components are equal
 
  
-   getImaginary() getImaginary()
-   Returns the imaginary component of the complex number
 
  
-   getReal() getReal()
-   Returns the real component of the complex number
 
  
-   main(String[]) main(String[])
-   Tests the Complex API
  
-   minus(Complex) minus(Complex)
-   Subtracting two complex numbers (a,b) (c,d) is defined as
 (a - c, b -d)
 
  
-   plus(Complex) plus(Complex)
-   Adding two complex numbers (a,b) (c,d) is defined as
 (a+c,b+d)
 
  
-   power(int) power(int)
-   Return the exponant of the complex number.
  
-   times(Complex) times(Complex)
-   Multiplying two complex numbers (a,b) (c,d) is defined as
 (a*c - b*d, a*d + b*c)
 
  
-   toString() toString()
-   Returns (r,i) where r is the real
 component and i is the imaginary component
   
 _real
_real
 private double _real
 _imaginary
_imaginary
 private double _imaginary
   
 Complex
Complex
 public Complex()
  -  Default constructor creates the complex number z = (0,0)
 
 Complex
Complex
 public Complex(double real,
                double imaginary)
  -  Creates the complex number z = (real, imaginary)
 
   
 plus
plus
 public cmpsci197c.Complex plus(cmpsci197c.Complex c)
  -  Adding two complex numbers (a,b) (c,d) is defined as
 (a+c,b+d)
   
- 
    -  Returns:
    
-  s this + c
  
 
 getReal
getReal
 public double getReal()
  -  Returns the real component of the complex number
   
- 
    -  Returns:
    
-  s the real value
  
 
 getImaginary
getImaginary
 public double getImaginary()
  -  Returns the imaginary component of the complex number
   
- 
    -  Returns:
    
-  s the imaginary value
  
 
 minus
minus
 public cmpsci197c.Complex minus(cmpsci197c.Complex c)
  -  Subtracting two complex numbers (a,b) (c,d) is defined as
 (a - c, b -d)
   
- 
    -  Returns:
    
-  s this - c
  
 
 times
times
 public cmpsci197c.Complex times(cmpsci197c.Complex c)
  -  Multiplying two complex numbers (a,b) (c,d) is defined as
 (a*c - b*d, a*d + b*c)
   
- 
    -  Returns:
    
-  s this * c
  
 
 divide
divide
 public cmpsci197c.Complex divide(cmpsci197c.Complex c) throws java.lang.ArithmeticException
  -  Dividing two complex numbers z = (a,b) w = (c,d) is defined as
 z * w-bar / |w|^2
 The |w|^2 is equivalent to w * w.conjugate() where 
 the conjugate of w = (c,d) is defined as (c,-d)
 Note that multiplying by the conjugate produces a non-negative real
 number so that we can easily divide the real and imaginary
 components of the imaginary numbers.
   
- 
    -  Returns:
    
-  s this / c
  
 
 power
power
 public cmpsci197c.Complex power(int power)
  -  Return the exponant of the complex number.
 Note that when power = 0 we return (1,0)
 and when power < 0 we return 1 / (a,b)^power
   
- 
    -  Returns:
    
-  s this^power
  
 
 conjugate
conjugate
 public cmpsci197c.Complex conjugate()
  -  For any complex number z = (a,b) the conjugate 
 (usually denoted z-bar) is defined as (a,-b)
   
- 
    -  Returns:
    
-  s The conjugate of this
  
 
 equals
equals
 public boolean equals(cmpsci197c.Complex c)
  -  Two complex numbers are equal if and only if both their
 real and imaginary components are equal
   
- 
    -  Returns:
    
-  s true if this is equivalent to c
  
 
 equals
equals
 public boolean equals(java.lang.Object o)
  -  Two complex numbers are equal if both their
 real and imaginary components are equal
   
- 
    -  Returns:
    
-  s true if this is equivalent to o
    
-  Overrides:
    
-  equals in class java.lang.Object
  
 
 toString
toString
 public java.lang.String toString()
  -  Returns (r,i) where r is the real
 component and i is the imaginary component
   
- 
    -  Returns:
    
-  s String representation of this
    
-  Overrides:
    
-  toString in class java.lang.Object
  
 
 clone
clone
 public java.lang.Object clone()
  -  Clone procedure
   
- 
    -  Returns:
    
-  s A deep copy of this
    
-  Overrides:
    
-  clone in class java.lang.Object
  
 
 main
main
 public static void main(java.lang.String args[])
  -  Tests the Complex API
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index