Package org.jamdev.jpamutils.spectrogram
Class Complex
java.lang.Object
org.jamdev.jpamutils.spectrogram.Complex
- All Implemented Interfaces:
Serializable,Cloneable
public class Complex extends Object implements Cloneable, Serializable
Class definition for a Complex number type.
- Author:
- Paul Redmond / Doug Gillespie
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description doubleimagdoublerealstatic longserialVersionUID -
Constructor Summary
-
Method Summary
Modifier and Type Method Description static Complex[]allocateComplexArray(int n)Allocate a new complex array in which each element has been created and it's contents set to 0 +i0;static Complex[][]allocateComplexArray(int n, int m)doubleang()Gets the angle of a complex numbervoidassign(double real, double imag)Assign new real and imaginary values to an existing Complex numbervoidassign(Complex b)Assign new real and imaginary values to an existing Complex numberComplexclone()Complexconj()static voidconj(Complex x)Converts a number to it's own complex conjugatestatic Complex[]createComplexArray(double[] doubleArray)Create a complex array from a double arrayComplexexp()A new Complex object whose value is the complex exponential of thisstatic longgetConstructorCalls()voidinternalTimes(double b)Multiply a complex numbers real and imaginary parts by a real numbervoidinternalTimes(Complex b)Multiply a complex numbers real and imaginary parts by a complex numberbooleanisInfinite()Returns true if either the real or imaginary part is infinite, false otherwisebooleanisNaN()Returns true if either the real or imaginary part is a Not-a-Number (NaN) value, false otherwisedoublemag()Gets the magnitude of a complex numberdoublemagsq()Gets the squared magnitude of a complex numberComplexminus(double b)Subtract a real number from a complex numberComplexminus(Complex b)Subtract a real number from a complex numberdoublenorm()Deprecated.Complexplus(double b)Add a real number to a complex numberComplexplus(Complex b)Adds a complex numberComplexpow(double f)Raises a complex number to a scalar power.Complexsqrt()Gets the square root of a Complex numberComplextimes(double b)Multiply a complex number by a realComplextimes(Complex b)Multiply a complex number by another complex numberStringtoString()StringtoString(int decimalPlaces)StringtoString(String format)static voidzeroComplexArray(Complex[] array)Sets all the elements of a complex array to zero
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
- Constant Field Values
-
real
public double real -
imag
public double imag
-
-
Constructor Details
-
Method Details
-
clone
-
ang
public double ang()Gets the angle of a complex number- Returns:
- angle in radians
-
magsq
public double magsq()Gets the squared magnitude of a complex number- Returns:
- squared magnitude
-
norm
Deprecated.Gets the squared magnitude of a complex number- Returns:
- squared magnitude
-
mag
public double mag()Gets the magnitude of a complex number- Returns:
- magnitude
-
sqrt
Gets the square root of a Complex number- Returns:
- square root of the Complex number
-
pow
Raises a complex number to a scalar power.- Parameters:
f- power to raise number to- Returns:
- new Complex number
-
exp
A new Complex object whose value is the complex exponential of this- Returns:
-
plus
Adds a complex number- Parameters:
b- Complex number to add- Returns:
- new Complex number
-
assign
Assign new real and imaginary values to an existing Complex number- Parameters:
b- Complex number to take values from
-
assign
public void assign(double real, double imag)Assign new real and imaginary values to an existing Complex number- Parameters:
real- new real partimag- new imaginary part
-
plus
Add a real number to a complex number- Parameters:
b- real number- Returns:
- new Complex number
-
minus
Subtract a real number from a complex number- Parameters:
b- real number- Returns:
- new Complex number
-
minus
Subtract a real number from a complex number- Parameters:
b- real number- Returns:
- new Complex number
-
times
Multiply a complex number by a real- Parameters:
b- real number- Returns:
- new Complex number
-
times
Multiply a complex number by another complex number- Parameters:
b- complex number- Returns:
- new complex number
-
internalTimes
public void internalTimes(double b)Multiply a complex numbers real and imaginary parts by a real number- Parameters:
b- real number
-
internalTimes
Multiply a complex numbers real and imaginary parts by a complex number- Parameters:
b- complex number
-
conj
-
conj
Converts a number to it's own complex conjugate- Parameters:
x-
-
isNaN
public boolean isNaN()Returns true if either the real or imaginary part is a Not-a-Number (NaN) value, false otherwise- Returns:
- true if either part of the number is NaN
-
isInfinite
public boolean isInfinite()Returns true if either the real or imaginary part is infinite, false otherwise- Returns:
- true if either part of the number is infinite
-
createComplexArray
Create a complex array from a double array- Parameters:
doubleArray- doubel array- Returns:
- complex array
-
allocateComplexArray
Allocate a new complex array in which each element has been created and it's contents set to 0 +i0;- Parameters:
n- length of array- Returns:
- Complex array of length n
-
allocateComplexArray
-
zeroComplexArray
Sets all the elements of a complex array to zero- Parameters:
array- Complex Array
-
toString
-
toString
- Parameters:
format- such as %2.2f- Returns:
-
toString
-
getConstructorCalls
public static long getConstructorCalls()
-