OpenWareLaboratory
ComplexShortArray Class Reference

Public Member Functions

void add (ComplexShortArray operand2, ComplexShortArray destination)
 Element-wise sum between complex arrays. More...
 
void add (ComplexShortArray operand2)
 In-place 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 ()
 Constructor. More...
 
 ComplexShortArray (ComplexShort *array, unsigned int size)
 Constructor. More...
 
void copyFrom (ShortArray source)
 Copies the content of an array into another array. More...
 
void copyFrom (ComplexShortArray source)
 Copies the content of a ShortArray into the ComplexShortArray. More...
 
void copyFrom (ComplexShort *source, unsigned int length)
 Copies an array of ComplexShort into the array. More...
 
void copyTo (ShortArray destination)
 Copies the content of the ComplexShortArray into a ShortArray. More...
 
void copyTo (ComplexShortArray destination)
 Copies the content of the array to another array. More...
 
void copyTo (ComplexShort *destination, int length)
 Copies an array of ComplexShort into the array. More...
 
bool equals (const ComplexShortArray 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 ComplexShortArray. 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...
 
unsigned int getSize () const
 
int16_t im (const int i)
 The imaginary part of an element of the array. More...
 
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...
 
 operator ComplexShort * ()
 
ComplexShortoperator[] (const int index)
 Allows to index the array using array-style brackets. More...
 
ComplexShortoperator[] (const int i) const
 Allows to index the array using array-style brackets. 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 setMagnitude (ShortArray magnitude)
 Set the magnitude of the elements of the array, leaving the phase unchanged. 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, 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, 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, int offset, int count)
 Set the phase of a range of 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, 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, ComplexShortArray destination)
 Element-wise difference between complex arrays. More...
 
void subtract (ComplexShortArray operand2)
 In-place element-wise difference between complex arrays. More...
 

Static Public Member Functions

static ComplexShortArray create (unsigned int size)
 Creates a new ComplexShortArray. More...
 
static void destroy (ComplexShortArray)
 Destroys a ComplexShortArray created with the create() method. More...
 

Detailed Description

Definition at line 83 of file ComplexShortArray.h.

Constructor & Destructor Documentation

ComplexShortArray::ComplexShortArray ( )
inline

Constructor.

Initializes size to 0.

Definition at line 92 of file ComplexShortArray.h.

Referenced by create().

ComplexShortArray::ComplexShortArray ( ComplexShort array,
unsigned int  size 
)
inline

Constructor.

Parameters
arrayA pointer to an array of ComplexShort
sizeThe length of the rray

Definition at line 101 of file ComplexShortArray.h.

Member Function Documentation

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
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
void ComplexShortArray::clear ( )
inline

Definition at line 123 of file ComplexShortArray.h.

References setAll().

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 82 of file ComplexShortArray.cpp.

References getData().

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
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
void ComplexShortArray::copyFrom ( ShortArray  source)

Copies the content of an array into another array.

Parameters
[in]sourceThe source array
void ComplexShortArray::copyFrom ( ComplexShortArray  source)

Copies the content of a ShortArray into the ComplexShortArray.

Parameters
[in]sourceThe source array
Remarks
The size of the ShortArray must be twice the size of the ComplexShortArray.
void ComplexShortArray::copyFrom ( ComplexShort source,
unsigned int  length 
)

Copies an array of ComplexShort into the array.

Parameters
[in]sourceA pointer to the beginning of the portion of memory to read from.
[in]lengthNumber of samples to copy.
void ComplexShortArray::copyTo ( ShortArray  destination)

Copies the content of the ComplexShortArray into a ShortArray.

Parameters
[out]destinationThe destination array
Remarks
The size of the ShortArray must be twice the size of the ComplexShortArray.
void ComplexShortArray::copyTo ( ComplexShortArray  destination)

Copies the content of the array to another array.

Parameters
[out]destinationThe destination array
void ComplexShortArray::copyTo ( ComplexShort destination,
int  length 
)

Copies an array of ComplexShort into the array.

Parameters
[in]destinationA pointer to the beginning of the portion of memory to write to.
[in]lengthNumber of samples to copy.
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 99 of file ComplexShortArray.cpp.

References ComplexShortArray().

Referenced by ShortFastFourierTransform::init().

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 103 of file ComplexShortArray.cpp.

Referenced by ShortFastFourierTransform::~ShortFastFourierTransform().

bool ComplexShortArray::equals ( const ComplexShortArray  other) const
inline

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 304 of file ComplexShortArray.h.

References getSize(), im(), and re().

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.
ComplexShort* ComplexShortArray::getData ( )
inline

Get the data stored in the ComplexShortArray.

Returns
a ComplexShort* pointer to the data stored in the ComplexShortArray

Definition at line 293 of file ComplexShortArray.h.

Referenced by complexByComplexMultiplication(), ComplexIntArray::copyFrom(), ComplexIntArray::copyTo(), ShortFastFourierTransform::fft(), and ShortFastFourierTransform::ifft().

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.
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 47 of file ComplexShortArray.cpp.

References ShortArray::getSize(), and mag2().

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 17 of file ComplexShortArray.cpp.

References mag(), and ShortArray::shift().

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.
int16_t ComplexShortArray::getMaxMagnitudeValue ( )

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

Returns
The maximum magnitude value in the array.
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.
unsigned int ComplexShortArray::getSize ( ) const
inline
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 119 of file ComplexShortArray.h.

References ComplexShort::im.

Referenced by ComplexIntArray::copyFrom(), equals(), ShortFastFourierTransform::fft(), and mag2().

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 5 of file ComplexShortArray.cpp.

References mag2().

Referenced by getMagnitudeValues().

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 30 of file ComplexShortArray.cpp.

References ComplexShort::im, im(), ComplexShort::re, and re().

Referenced by getMagnitudeSquaredValues(), and mag().

ComplexShortArray::operator ComplexShort * ( )
inline

Definition at line 286 of file ComplexShortArray.h.

ComplexShort& ComplexShortArray::operator[] ( const int  index)
inline

Allows to index the array using array-style brackets.

Parameters
indexThe index of the element
Returns
the Value of the index element of the array Example usage:
int size=1000;
int16_t content[size];
ComplexShortArray complexShortArray(content, size);
for(int n=0; n<size; n+=2){//now the ComplexShortArray can be indexed as if it was an array
content[n]==complexShortArray[n/2].re;
content[n+1]==complexShortArray[n/2].im;
}

Definition at line 269 of file ComplexShortArray.h.

ComplexShort& ComplexShortArray::operator[] ( const int  i) const
inline

Allows to index the array using array-style brackets.

const version of operator[]

Definition at line 278 of file ComplexShortArray.h.

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 110 of file ComplexShortArray.h.

References ComplexShort::re.

Referenced by ComplexIntArray::copyFrom(), equals(), ShortFastFourierTransform::fft(), ShortFastFourierTransform::ifft(), and mag2().

void ComplexShortArray::scale ( int16_t  factor)

Array by scalar multiplication.

Parameters
factorThe value by which all the elements of the array are multiplied.
void ComplexShortArray::setAll ( ComplexShort  value)

Set all the elements in the array.

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

Referenced by clear(), and setAll().

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 107 of file ComplexShortArray.cpp.

References ComplexFloat::im, ComplexFloat::re, and setAll().

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.
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.
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
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.
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.
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.
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
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.
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.
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.
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
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.
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
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

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