Package fi.iki.jmtilli.javafastcomplex
Interface ComplexNumber
- All Known Implementing Classes:
Complex,ComplexBuffer
public interface ComplexNumber
A common interface to complex numbers.
-
Method Summary
Modifier and Type Method Description doubleabs()Returns the absolute value of the complex number.doublearg()Returns the argument of the complex number.doublegetImag()Returns the imaginary part of the complex number.doublegetReal()Returns the real part of the complex number.booleanisInfinite()Checks whether the complex number is infinite.booleanisNaN()Checks whether the complex number is NaN.java.lang.StringtoString()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:
toStringin classjava.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
-