OpenWareLaboratory
ComplexShortArray Class Reference
Inheritance diagram for ComplexShortArray:
Collaboration diagram for ComplexShortArray:

Public Member Functions

void add (ComplexShortArray operand2)
 In-place element-wise sum between complex arrays. More...
 
void add (ComplexShortArray operand2, ComplexShortArray destination)
 Element-wise sum between complex arrays. More...
 
void clear ()
 
void complexByComplexMultiplication (ComplexShortArray operand2, ComplexShortArray result)
 Complex by complex multiplication between arrays. More...
 
void complexByRealMultiplication (ShortArray operand2, ComplexShortArray result)
 Complex by real multiplication between arrays. More...
 
void complexDotProduct (ComplexShortArray operand2, ComplexShort &result)
 Complex dot product between arrays. More...
 
 ComplexShortArray ()
 
 ComplexShortArray (ComplexShort *data, size_t size)
 
void copyFrom (SimpleArray< ComplexShort > source)
 Copies the content of another array into this array. More...
 
void copyTo (SimpleArray< ComplexShort > destination)
 Copies the content of this array to another array. More...
 
bool equals (const SimpleArray< ComplexShort > &other) const
 Compares two arrays. More...
 
void getComplexConjugateValues (ComplexShortArray destination)
 The complex conjugate values of the element of the array. More...
 
ComplexShortgetData ()
 Get the data stored in the Array. More...
 
ComplexShort getElement (size_t index)
 Get a single value stored in the array. More...
 
void getImaginaryValues (ShortArray buf)
 Get the imaginary part of the elements of the array. More...
 
void getMagnitudeSquaredValues (ShortArray destination)
 The squared magnitudes of the elements of the array. More...
 
void getMagnitudeValues (ShortArray destination)
 The magnitudes of the elements of the array. More...
 
unsigned int getMaxMagnitudeIndex ()
 The index of the element with the maximum magnitude in the array. More...
 
int16_t getMaxMagnitudeValue ()
 The value of the element with the maximum magnitude in the array. More...
 
void getRealValues (ShortArray buf)
 Get the real part of the elements of the array. More...
 
size_t getSize () const
 
int16_t im (const int i)
 The imaginary part of an element of the array. More...
 
void insert (SimpleArray< ComplexShort > source, int destinationOffset, size_t len)
 Copies the content of an array into a subset of the array. More...
 
void insert (SimpleArray< ComplexShort > source, int sourceOffset, int destinationOffset, size_t len)
 Copies the content of an array into a subset of the array. More...
 
bool isEmpty () const
 
int16_t mag (const int i)
 The magnitude of an element of the array. More...
 
int16_t mag2 (const int i)
 The magnitude squared of an element of the array. More...
 
void move (int fromIndex, int toIndex, size_t len)
 Copies values within an array. More...
 
 operator ComplexShort * ()
 Casting operator to T*. More...
 
int16_t re (const int i)
 The real part of an element of the array. More...
 
void scale (int16_t factor)
 Array by scalar multiplication. More...
 
void setAll (ComplexShort value)
 Set all the elements in the array. More...
 
void setAll (int16_t value)
 Set all the elements in the array. More...
 
void setAll (int16_t valueRe, int16_t valueIm)
 Set all the elements in the array. More...
 
void setElement (size_t index, ComplexShort value)
 Set a single value in the array. More...
 
void setMagnitude (ShortArray magnitude)
 Set the magnitude of the elements of the array, leaving the phase unchanged. More...
 
void setMagnitude (ShortArray magnitude, ComplexShortArray destination)
 Set the magnitude of the elements of an array, using the phase from the current array. More...
 
void setMagnitude (ShortArray magnitude, int offset, int count)
 Set the magnitude of a range of elements of the array, leaving the phase unchanged. More...
 
void setMagnitude (ShortArray magnitude, int offset, int count, ComplexShortArray destination)
 Set the magnitude of a range of the elements of an array, using the phases from the current array. More...
 
void setPhase (ShortArray phase)
 Set the phase of the elements of the array, leaving the magnitude unchanged. More...
 
void setPhase (ShortArray phase, ComplexShortArray destination)
 Set the phase of the elements of an array, using the magnitude from the current array. More...
 
void setPhase (ShortArray phase, int offset, int count)
 Set the phase of a range of elements of the array, leaving the magnitude unchanged. More...
 
void setPhase (ShortArray phase, int offset, int count, ComplexShortArray destination)
 Set the phase of a range of the elements of an array, using the magnitude from the current array. More...
 
void setPolar (ShortArray magnitude, ShortArray phase)
 Set all the elements in the array using polar coordinates. More...
 
void setPolar (ShortArray magnitude, ShortArray phase, int offset, int count)
 Set a range of elements in the array using polar coordinates. More...
 
ComplexShortArray subArray (unsigned int offset, unsigned int length)
 A subset of the array. More...
 
void subtract (ComplexShortArray operand2)
 In-place element-wise difference between complex arrays. More...
 
void subtract (ComplexShortArray operand2, ComplexShortArray destination)
 Element-wise difference between complex arrays. More...
 

Static Public Member Functions

static void copy (ComplexShort *dst, ComplexShort *src, size_t len)
 Optimised array copy for datatype T. More...
 
static ComplexShortArray create (unsigned int size)
 Creates a new ComplexShortArray. More...
 
static void destroy (ComplexShortArray)
 Destroys a ComplexShortArray created with the create() method. More...
 

Protected Attributes

ComplexShortdata
 
size_t size
 

Detailed Description

Definition at line 70 of file ComplexShortArray.h.

Constructor & Destructor Documentation

◆ ComplexShortArray() [1/2]

ComplexShortArray::ComplexShortArray ( )
inline

Definition at line 72 of file ComplexShortArray.h.

◆ ComplexShortArray() [2/2]

ComplexShortArray::ComplexShortArray ( ComplexShort data,
size_t  size 
)
inline

Definition at line 73 of file ComplexShortArray.h.

Member Function Documentation

◆ add() [1/2]

void ComplexShortArray::add ( ComplexShortArray  operand2)

In-place element-wise sum between complex arrays.

Adds each element of operand2 to the corresponding element in the array.

Parameters
operand2second operand for the sum

◆ add() [2/2]

void ComplexShortArray::add ( ComplexShortArray  operand2,
ComplexShortArray  destination 
)

Element-wise sum between complex arrays.

Sets each element in destination to the complex sum of the corresponding element of the array and operand2

Parameters
[in]operand2second operand for the sum
[out]destinationthe destination array

Definition at line 151 of file ComplexShortArray.cpp.

References SimpleArray< T >::data, SimpleArray< ComplexShort >::data, ComplexShort::im, im(), ComplexShort::re, re(), and SimpleArray< ComplexShort >::size.

◆ clear()

void ComplexShortArray::clear ( )
inline

Definition at line 95 of file ComplexShortArray.h.

References setAll().

Referenced by create().

◆ complexByComplexMultiplication()

void ComplexShortArray::complexByComplexMultiplication ( ComplexShortArray  operand2,
ComplexShortArray  result 
)

Complex by complex multiplication between arrays.

Parameters
[in]operand2The second operand of the multiplication
[out]resultThe array where the result of the multiplication is stored
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 109 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, SimpleArray< T >::getData(), SimpleArray< ComplexShort >::getData(), Q15_MUL_Q15, and SimpleArray< ComplexShort >::size.

◆ complexByRealMultiplication()

void ComplexShortArray::complexByRealMultiplication ( ShortArray  operand2,
ComplexShortArray  result 
)

Complex by real multiplication between arrays.

Parameters
[in]operand2The second operand of the multiplication
[out]resultThe array where the result of the multiplication is stored

◆ complexDotProduct()

void ComplexShortArray::complexDotProduct ( ComplexShortArray  operand2,
ComplexShort result 
)

Complex dot product between arrays.

Parameters
[in]operand2The second operand of the dot product
[out]resultThe array where the result of the dot product is stored

◆ copy()

static void SimpleArray< ComplexShort >::copy ( ComplexShort dst,
ComplexShort src,
size_t  len 
)
inlinestaticinherited

Optimised array copy for datatype T.

Copy four at a time to minimise loop overheads and allow SIMD optimisations. This performs well on external RAM but is slower on internal memory compared to memcpy.

Definition at line 134 of file SimpleArray.h.

◆ copyFrom()

void SimpleArray< ComplexShort >::copyFrom ( SimpleArray< ComplexShort source)
inlineinherited

Copies the content of another array into this array.

This array needs to be at least as big as the other array.

Parameters
[in]sourcethe source array

Definition at line 86 of file SimpleArray.h.

◆ copyTo()

void SimpleArray< ComplexShort >::copyTo ( SimpleArray< ComplexShort destination)
inlineinherited

Copies the content of this array to another array.

The other array needs to be at least as big as this array.

Parameters
[out]destinationthe destination array

Definition at line 76 of file SimpleArray.h.

◆ create()

ComplexShortArray ComplexShortArray::create ( unsigned int  size)
static

Creates a new ComplexShortArray.

Allocates size*sizeof(int16_t) bytes of memory and returns a ComplexShortArray that points to it.

Parameters
sizeThe size of the new ComplexShortArray.
Returns
A ComplexShortArray which data point to the newly allocated memory and size is initialized to the proper value.
Remarks
A ComplexShortArray created with this method has to be destroyed invoking the ComplexShortArray::destroy() method.

Definition at line 163 of file ComplexShortArray.cpp.

References clear(), and SimpleArray< ComplexShort >::size.

Referenced by ShortFastFourierTransform::init().

◆ destroy()

void ComplexShortArray::destroy ( ComplexShortArray  array)
static

Destroys a ComplexShortArray created with the create() method.

Parameters
arrayThe ComplexShortArray to be destroyed.
Remarks
The ComplexShortArray object passed as an argument should not be used again after invoking this method.
A ComplexShortArray object that has not been created by the ComplexShortArray::create() method might cause an exception if passed as an argument to this method.

Definition at line 169 of file ComplexShortArray.cpp.

References SimpleArray< T >::data.

Referenced by ShortFastFourierTransform::~ShortFastFourierTransform().

◆ equals()

bool SimpleArray< ComplexShort >::equals ( const SimpleArray< ComplexShort > &  other) const
inlineinherited

Compares two arrays.

Performs an element-wise comparison of the values contained in the arrays.

Parameters
otherthe array to compare against.
Returns
true if the arrays have the same size and the value of each of the elements of the one match the value of the corresponding element of the other, or false otherwise.

Definition at line 61 of file SimpleArray.h.

◆ getComplexConjugateValues()

void ComplexShortArray::getComplexConjugateValues ( ComplexShortArray  destination)

The complex conjugate values of the element of the array.

Parameters
[out]destinationThe array where the complex conjugate values will be stored.

◆ getData()

ComplexShort * SimpleArray< ComplexShort >::getData ( )
inlineinherited

Get the data stored in the Array.

Returns
a T* pointer to the data stored in the Array

Definition at line 27 of file SimpleArray.h.

◆ getElement()

ComplexShort SimpleArray< ComplexShort >::getElement ( size_t  index)
inlineinherited

Get a single value stored in the array.

Returns
the value stored at index
Parameters
index

Definition at line 43 of file SimpleArray.h.

◆ getImaginaryValues()

void ComplexShortArray::getImaginaryValues ( ShortArray  buf)

Get the imaginary part of the elements of the array.

Parameters
[out]bufThe array where the imaginary part will be stored.

◆ getMagnitudeSquaredValues()

void ComplexShortArray::getMagnitudeSquaredValues ( ShortArray  destination)

The squared magnitudes of the elements of the array.

Parameters
[out]destinationThe array where the magnitude squared values will be stored.
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 74 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, SimpleArray< T >::getSize(), mag2(), and SimpleArray< ComplexShort >::size.

◆ getMagnitudeValues()

void ComplexShortArray::getMagnitudeValues ( ShortArray  destination)

The magnitudes of the elements of the array.

Parameters
[out]destinationThe array where the magnitude values will be stored.
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 45 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, mag(), ShortArray::shift(), and SimpleArray< ComplexShort >::size.

◆ getMaxMagnitudeIndex()

unsigned int ComplexShortArray::getMaxMagnitudeIndex ( )

The index of the element with the maximum magnitude in the array.

Returns
The index of the element with the maximum magnitude in the array.

◆ getMaxMagnitudeValue()

int16_t ComplexShortArray::getMaxMagnitudeValue ( )

The value of the element with the maximum magnitude in the array.

Returns
The maximum magnitude value in the array.

◆ getRealValues()

void ComplexShortArray::getRealValues ( ShortArray  buf)

Get the real part of the elements of the array.

Parameters
[out]bufThe array where the real part will be stored.

◆ getSize()

size_t SimpleArray< ComplexShort >::getSize ( ) const
inlineinherited

Definition at line 31 of file SimpleArray.h.

◆ im()

int16_t ComplexShortArray::im ( const int  i)
inline

The imaginary part of an element of the array.

Parameters
iThe index of the element
Returns
The imaginary part of the element

Definition at line 91 of file ComplexShortArray.h.

References SimpleArray< ComplexShort >::data, and ComplexShort::im.

Referenced by add(), ShortFastFourierTransform::fft(), and mag2().

◆ insert() [1/2]

void SimpleArray< ComplexShort >::insert ( SimpleArray< ComplexShort source,
int  destinationOffset,
size_t  len 
)
inlineinherited

Copies the content of an array into a subset of the array.

Copies len elements from source to destinationOffset in the current array.

Parameters
[in]sourcethe source array
[in]destinationOffsetthe offset into the destination array
[in]lenthe number of samples to copy

Definition at line 99 of file SimpleArray.h.

◆ insert() [2/2]

void SimpleArray< ComplexShort >::insert ( SimpleArray< ComplexShort source,
int  sourceOffset,
int  destinationOffset,
size_t  len 
)
inlineinherited

Copies the content of an array into a subset of the array.

Copies len elements starting from sourceOffset of source to destinationOffset in the current array.

Parameters
[in]sourcethe source array
[in]sourceOffsetthe offset into the source array
[in]destinationOffsetthe offset into the destination array
[in]lenthe number of samples to copy

Definition at line 111 of file SimpleArray.h.

◆ isEmpty()

bool SimpleArray< ComplexShort >::isEmpty ( ) const
inlineinherited

Definition at line 35 of file SimpleArray.h.

◆ mag()

int16_t ComplexShortArray::mag ( const int  i)

The magnitude of an element of the array.

Parameters
iThe index of the element
Returns
The magnitude of the element
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 34 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, FLOAT_TO_Q15, mag2(), and Q15_TO_FLOAT.

Referenced by getMagnitudeValues().

◆ mag2()

int16_t ComplexShortArray::mag2 ( const int  i)

The magnitude squared of an element of the array.

Parameters
iThe index of the element
Returns
The magnitude squared of the element
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 58 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, FLOAT_TO_Q15, im(), Q15_TO_FLOAT, and re().

Referenced by getMagnitudeSquaredValues(), and mag().

◆ move()

void SimpleArray< ComplexShort >::move ( int  fromIndex,
int  toIndex,
size_t  len 
)
inlineinherited

Copies values within an array.

Copies length values starting from index fromIndex to locations starting with index toIndex

Parameters
[in]fromIndexthe first element to copy
[in]toIndexthe destination of the first element
[in]lenthe number of elements to copy

Definition at line 124 of file SimpleArray.h.

◆ operator ComplexShort *()

SimpleArray< ComplexShort >::operator ComplexShort * ( )
inlineinherited

Casting operator to T*.

Returns
a T* pointer to the data stored in the Array

Definition at line 157 of file SimpleArray.h.

◆ re()

int16_t ComplexShortArray::re ( const int  i)
inline

The real part of an element of the array.

Parameters
iThe index of the element
Returns
The real part of the element

Definition at line 82 of file ComplexShortArray.h.

References SimpleArray< ComplexShort >::data, and ComplexShort::re.

Referenced by add(), ShortFastFourierTransform::fft(), ShortFastFourierTransform::ifft(), and mag2().

◆ scale()

void ComplexShortArray::scale ( int16_t  factor)

Array by scalar multiplication.

Parameters
factorThe value by which all the elements of the array are multiplied.

◆ setAll() [1/3]

void ComplexShortArray::setAll ( ComplexShort  value)

Set all the elements in the array.

Parameters
[in]valueAll the elements are set to this value.

Definition at line 139 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, ComplexShort::im, ComplexShort::re, and SimpleArray< ComplexShort >::size.

Referenced by clear(), and setAll().

◆ setAll() [2/3]

void ComplexShortArray::setAll ( int16_t  value)

Set all the elements in the array.

Parameters
[in]valueThe real and imaginary parts of all the elements in the array are set to this value.
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 127 of file ComplexShortArray.cpp.

References SimpleArray< ComplexShort >::data, ComplexShort::im, ComplexShort::re, setAll(), and SimpleArray< ComplexShort >::size.

◆ setAll() [3/3]

void ComplexShortArray::setAll ( int16_t  valueRe,
int16_t  valueIm 
)

Set all the elements in the array.

Parameters
[in]valueReThe real part of every element of the the array will be set to this value.
[in]valueImThe imaginary pary of rvery element of the the array will be set to this value.

Definition at line 146 of file ComplexShortArray.cpp.

References setAll().

◆ setElement()

void SimpleArray< ComplexShort >::setElement ( size_t  index,
ComplexShort  value 
)
inlineinherited

Set a single value in the array.

Definition at line 50 of file SimpleArray.h.

◆ setMagnitude() [1/4]

void ComplexShortArray::setMagnitude ( ShortArray  magnitude)

Set the magnitude of the elements of the array, leaving the phase unchanged.

Parameters
[in]magnitudeAn array containing the magnitudes.

◆ setMagnitude() [2/4]

void ComplexShortArray::setMagnitude ( ShortArray  magnitude,
ComplexShortArray  destination 
)

Set the magnitude of the elements of an array, using the phase from the current array.

Parameters
[in]magnitudeAn array containing the magnitudes.
[out]destinationThe destination array.

◆ setMagnitude() [3/4]

void ComplexShortArray::setMagnitude ( ShortArray  magnitude,
int  offset,
int  count 
)

Set the magnitude of a range of elements of the array, leaving the phase unchanged.

Parameters
[in]magnitudeAn array containing the magnitudes.
[in]offsetFirst element to set
[in]countNumber of elements to set

◆ setMagnitude() [4/4]

void ComplexShortArray::setMagnitude ( ShortArray  magnitude,
int  offset,
int  count,
ComplexShortArray  destination 
)

Set the magnitude of a range of the elements of an array, using the phases from the current array.

The offset and count specified apply to both the source and destination arrays. Elements of the destination array outside this range will not be affected.

Parameters
[in]magnitudeAn array containing the magnitudes.
[in]offsetFirst element to set
[in]countNumber of elements to set
[out]destinationThe destination array.

◆ setPhase() [1/4]

void ComplexShortArray::setPhase ( ShortArray  phase)

Set the phase of the elements of the array, leaving the magnitude unchanged.

Parameters
[in]phaseAn array containing the phases.

◆ setPhase() [2/4]

void ComplexShortArray::setPhase ( ShortArray  phase,
ComplexShortArray  destination 
)

Set the phase of the elements of an array, using the magnitude from the current array.

Parameters
[in]phaseAn array containing the phases.
[out]destinationThe destination array.

◆ setPhase() [3/4]

void ComplexShortArray::setPhase ( ShortArray  phase,
int  offset,
int  count 
)

Set the phase of a range of elements of the array, leaving the magnitude unchanged.

Parameters
[in]phaseAn array containing the phases.
[in]offsetFirst element to set
[in]countNumber of elements to set

◆ setPhase() [4/4]

void ComplexShortArray::setPhase ( ShortArray  phase,
int  offset,
int  count,
ComplexShortArray  destination 
)

Set the phase of a range of the elements of an array, using the magnitude from the current array.

The offset and count specified apply to both the source and destination arrays. Elements of the destination array outside this range will not be affected.

Parameters
[in]phaseAn array containing the phases.
[in]offsetFirst element to set
[in]countNumber of elements to set
[out]destinationThe destination array.

◆ setPolar() [1/2]

void ComplexShortArray::setPolar ( ShortArray  magnitude,
ShortArray  phase 
)

Set all the elements in the array using polar coordinates.

Parameters
[in]magnitudeAn array containing the magnitudes.
[in]phaseAn array containing the phases.

◆ setPolar() [2/2]

void ComplexShortArray::setPolar ( ShortArray  magnitude,
ShortArray  phase,
int  offset,
int  count 
)

Set a range of elements in the array using polar coordinates.

Parameters
[in]magnitudeAn array containing the magnitudes.
[in]phaseAn array containing the phases.
[in]offsetFirst element to set
[in]countNumber of elements to set

◆ subArray()

ComplexShortArray ComplexShortArray::subArray ( unsigned int  offset,
unsigned int  length 
)

A subset of the array.

Returns an array that points to subset of the memory used by the original array.

Parameters
[in]offsetthe first element of the subset.
[in]lengththe number of elments in the new ComplexShortArray.
Returns
the newly created ComplexShortArray.
Remarks
no memory is allocated by this method. The memory is still shared with the original array. The memory should not be de-allocated elsewhere (e.g.: by calling ComplexShortArray::destroy() on the original ComplexShortArray) as long as the ComplexShortArray returned by this method is still in use.
Calling ComplexShortArray::destroy() on a ComplexShortArray instance created with this method might cause an exception.

◆ subtract() [1/2]

void ComplexShortArray::subtract ( ComplexShortArray  operand2)

In-place element-wise difference between complex arrays.

Sutracts each element of operand2 from the corresponding element in the array.

Parameters
operand2second operand for the sum

◆ subtract() [2/2]

void ComplexShortArray::subtract ( ComplexShortArray  operand2,
ComplexShortArray  destination 
)

Element-wise difference between complex arrays.

Sets each element in destination to the complex difference between the corresponding element of the array and operand2

Parameters
[in]operand2second operand for the subtraction
[out]destinationthe destination array

Field Documentation

◆ data

ComplexShort * SimpleArray< ComplexShort >::data
protectedinherited

Definition at line 16 of file SimpleArray.h.

◆ size

size_t SimpleArray< ComplexShort >::size
protectedinherited

Definition at line 17 of file SimpleArray.h.


The documentation for this class was generated from the following files: