Interface ComplexNumber

All Known Implementing Classes:
Complex, ComplexBuffer

public interface ComplexNumber
A common interface to complex numbers.
  • Method Summary

    Modifier and Type Method Description
    double abs()
    Returns the absolute value of the complex number.
    double arg()
    Returns the argument of the complex number.
    double getImag()
    Returns the imaginary part of the complex number.
    double getReal()
    Returns the real part of the complex number.
    boolean isInfinite()
    Checks whether the complex number is infinite.
    boolean isNaN()
    Checks whether the complex number is NaN.
    java.lang.String toString()
    Returns a String representation of the complex number.
  • Method Details

    • getReal

      double getReal()
      Returns the real part of the complex number.
      Returns:
      The real part
    • getImag

      double getImag()
      Returns the imaginary part of the complex number.
      Returns:
      The imaginary part
    • abs

      double abs()
      Returns the absolute value of the complex number.
      Returns:
      Double.NaN if isNaN()
      Double.POSITIVE_INFINITY if isInfinite()
      x≥0 absolute value otherwise
    • arg

      double arg()
      Returns the argument of the complex number.
      Returns:
      Double.NaN if isNaN()
      -pi≤x≤pi argument otherwise
    • isNaN

      boolean isNaN()
      Checks whether the complex number is NaN.
      Returns:
      true if either the real or imaginary part is NaN
      false otherwise
    • isInfinite

      boolean isInfinite()
      Checks whether the complex number is infinite.
      Returns:
      true if the real or imaginary part is infinite and !isNaN()
      false otherwise
    • toString

      java.lang.String toString()
      Returns a String representation of the complex number.
      Overrides:
      toString in class java.lang.Object
      Returns:
      "NaN" if NaN
      re if purely real
      im + "i" if purely imaginary
      re " + " + im + "i" if imaginary part positive
      re " - " + (-im) + "i" if imaginary part negative