1 #ifndef __ComplexFloatArray_h__
2 #define __ComplexFloatArray_h__
79 re = magnitude*cosf(phase);
80 im = magnitude*sinf(phase);
114 return re == other.
re &&
im == other.
im;
118 return re != other.
re ||
im != other.
im;
216 float re(
const int i){
225 float im(
const int i){
238 float mag(
const int i);
251 float mag2(
const int i);
354 void scale(
float factor);
403 void setAll(
float valueRe,
float valueIm);
void getPhaseValues(FloatArray destination)
The phases of the elements of the array.
float im(const int i)
Get the imaginary part of an element of the array.
void getImaginaryValues(FloatArray buf)
Get the imaginary part of the elements of the array.
void getComplexConjugateValues(ComplexFloatArray destination)
The complex conjugate values of the element of the array.
void setPolar(FloatArray magnitude, FloatArray phase)
Set all the elements in the array using polar coordinates.
void setPhase(FloatArray phase)
Set the phase of the elements of the array, leaving the magnitude unchanged.
void getMagnitudeSquaredValues(FloatArray destination)
The squared magnitudes of the elements of the array.
void getRealValues(FloatArray buf)
Get the real part of the elements of the array.
void add(ComplexFloatArray operand2, ComplexFloatArray destination)
Element-wise sum between complex arrays.
static void destroy(ComplexFloatArray)
Destroys a ComplexFloatArray created with the create() method.
void setMagnitude(FloatArray magnitude)
Set the magnitude of the elements of the array, leaving the phase unchanged.
void complexDotProduct(ComplexFloatArray operand2, ComplexFloat &result)
Complex dot product between arrays.
ComplexFloatArray subArray(int offset, size_t length)
A subset of the array.
ComplexFloatArray(ComplexFloat *data, size_t size)
void copyTo(FloatArray real, FloatArray imag)
Split complex data into two channels of audio containing real and imaginary axis data.
void complexByComplexMultiplication(ComplexFloatArray operand2, ComplexFloatArray result)
Complex by complex multiplication between arrays.
void getPolar(FloatArray magnitude, FloatArray phase)
Get polar coordinates for all the elements in the array.
void getMagnitudeValues(FloatArray destination)
The magnitudes of the elements of the array.
void setAll(ComplexFloat value)
Set all the elements in the array.
float mag2(const int i)
The magnitude squared of an element of the array.
void scale(float factor)
Array by scalar multiplication.
static ComplexFloatArray create(size_t size)
Creates a new ComplexFloatArray.
int getMaxMagnitudeIndex()
The index of the element with the maximum magnitude in the array.
void copyFrom(FloatArray real, FloatArray imag)
Merge two channels of audio containing real and imaginary axis data into this array.
float re(const int i)
Get the real part of an element of the array.
float getMaxMagnitudeValue()
The value of the element with the maximum magnitude in the array.
void subtract(ComplexFloatArray operand2, ComplexFloatArray destination)
Element-wise difference between complex arrays.
float mag(const int i)
Get the magnitude of an element of the array.
void toFloat(FloatArray destination)
Copies real and imaginary values of the ComplexFloatArray into a FloatArray.
void complexByRealMultiplication(FloatArray operand2, ComplexFloatArray result)
Complex by real multiplication between arrays.
void fromFloat(FloatArray source)
Copies real values from a FloatArray, sets imaginary values to 0.
This class contains useful methods for manipulating arrays of floats.
SimpleArray holds a pointer to an array and the array size, and is designed to be passed by value.
A structure defining a floating point complex number as two members of type float.
float im
The imaginary part of the complex number.
friend const ComplexFloat operator+(const ComplexFloat &lhs, const ComplexFloat &rhs)
friend const ComplexFloat operator+(const ComplexFloat &lhs, float rhs)
ComplexFloat & operator*=(const ComplexFloat &other)
constexpr ComplexFloat(float x)
bool operator>=(const ComplexFloat &other) const
friend const ComplexFloat operator-(const ComplexFloat &lhs, float rhs)
friend const ComplexFloat operator/(const ComplexFloat &lhs, float rhs)
void setMagnitude(float magnitude)
Set the magnitude of the complex number.
ComplexFloat & operator*=(float other)
float re
The real part of the complex number.
float getMagnitude() const
Get the magnitude of the complex number.
ComplexFloat & operator+=(const ComplexFloat &other)
float getPhase() const
Get the phase of the complex number.
ComplexFloat getDotProduct(ComplexFloat other) const
Returns dot product with another complex float value.
ComplexFloat getComplexConjugate() const
Returns complex conjugate - a copy of current number with imaginary part inverted.
void setPhase(float phase)
Set the phase of the complex number.
friend const ComplexFloat operator*(const ComplexFloat &lhs, float rhs)
void setPolar(float magnitude, float phase)
Set magnitude and phase of the complex number.
bool operator!=(const ComplexFloat &other) const
ComplexFloat & operator+=(float other)
friend const ComplexFloat operator*(const ComplexFloat &lhs, const ComplexFloat &rhs)
float getMagnitudeSquared() const
Get the squared magnitude of the complex number.
ComplexFloat & operator-=(float other)
bool operator<=(const ComplexFloat &other) const
bool operator>(const ComplexFloat &other) const
ComplexFloat & operator-=(const ComplexFloat &other)
bool operator==(const ComplexFloat &other) const
bool operator<(const ComplexFloat &other) const
constexpr ComplexFloat(float re, float im)
friend const ComplexFloat operator-(const ComplexFloat &lhs, const ComplexFloat &rhs)
ComplexFloat & operator/=(float other)