JML

org.jmlspecs.samples.dbc
Interface Complex

All Known Implementing Classes:
ComplexOps

public interface Complex

Complex numbers. Note that these are immutable. Abstractly, one can think of a complex number as realPart+(imaginaryPart*i). Alternatively, one can think of it as distance from the origin along a given angle (measured in radians counterclockwise from the positive x axis), hence a pair of (magnitude, angle). This class supports both of these views. The specifications in this class are intentionally of the lightweight variety.

Author:
Gary T. Leavens with help from Abelson and Sussman's Structure and Interpretation of Computer Programs

Method Summary
 Complex add(Complex b)
          Return this + b (the sum of this and b).
 double angle()
          Return the angle of this complex number.
 Complex div(Complex b)
          Return this/b (the quotient of this by b).
 boolean equals(Object o)
          Return true if these are the same complex number.
 int hashCode()
          Return a hashCode for this number.
 double imaginaryPart()
          Return the imaginary part of this complex number.
 double magnitude()
          Return the magnitude of this complex number.
 Complex mul(Complex b)
          Tell whether the given angles are the same, taking into account that angles measured in radians wrap around after 2*StrictMath.PI times.
 double realPart()
          Return the real part of this complex number.
 Complex sub(Complex b)
          Return this - b (the difference between this and b).
 

Method Detail

realPart

public double realPart()
Return the real part of this complex number.


imaginaryPart

public double imaginaryPart()
Return the imaginary part of this complex number.


magnitude

public double magnitude()
Return the magnitude of this complex number.


angle

public double angle()
Return the angle of this complex number.


add

public Complex add(Complex b)
Return this + b (the sum of this and b).


sub

public Complex sub(Complex b)
Return this - b (the difference between this and b).


mul

public Complex mul(Complex b)
Tell whether the given angles are the same, taking into account that angles measured in radians wrap around after 2*StrictMath.PI times. Return the positive remainder of n divided by d. Return this * b (the product of this and b).


div

public Complex div(Complex b)
Return this/b (the quotient of this by b).


equals

public boolean equals(Object o)
Return true if these are the same complex number.


hashCode

public int hashCode()
Return a hashCode for this number.


JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.