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

Public Member Functions

void add (IntArray operand2)
 Element-wise sum between arrays. More...
 
void add (IntArray operand2, IntArray destination)
 Element-wise sum between arrays. More...
 
void clear ()
 Clear the array. More...
 
void copyFrom (SimpleArray< int32_t > source)
 Copies the content of another array into this array. More...
 
void copyTo (SimpleArray< int32_t > destination)
 Copies the content of this array to another array. More...
 
bool equals (const SimpleArray< int32_t > &other) const
 Compares two arrays. More...
 
void fromFloat (FloatArray source)
 Copies the content of a FloatArray into a IntArray, converting the float elements to fixed-point 1.31. More...
 
int32_t * getData ()
 Get the data stored in the Array. More...
 
int32_t getElement (size_t index)
 Get a single value stored in the array. More...
 
float getFloatValue (uint32_t n)
 Returns an element of the array converted to float. More...
 
size_t getSize () const
 
void insert (SimpleArray< int32_t > source, int destinationOffset, size_t len)
 Copies the content of an array into a subset of the array. More...
 
void insert (SimpleArray< int32_t > source, int sourceOffset, int destinationOffset, size_t len)
 Copies the content of an array into a subset of the array. More...
 
 IntArray ()
 
 IntArray (int32_t *data, size_t size)
 
bool isEmpty () const
 
void move (int fromIndex, int toIndex, size_t len)
 Copies values within an array. More...
 
 operator int32_t * ()
 Casting operator to T*. More...
 
void setAll (int32_t value)
 
void setElement (size_t index, int32_t value)
 Set a single value in the array. More...
 
void setFloatValue (uint32_t n, float value)
 Converts a float to int16 and stores it. More...
 
void shift (int shiftValue)
 Bitshift the array values, saturating. More...
 
IntArray subArray (int offset, size_t length)
 A subset of the array. More...
 
void toFloat (FloatArray destination)
 Copies the content of the array to a FloatArray, interpreting the content of the IntArray as 1.31. More...
 

Static Public Member Functions

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

Protected Attributes

int32_t * data
 
size_t size
 

Detailed Description

Definition at line 9 of file IntArray.h.

Constructor & Destructor Documentation

◆ IntArray() [1/2]

IntArray::IntArray ( )
inline

Definition at line 11 of file IntArray.h.

Referenced by subArray().

◆ IntArray() [2/2]

IntArray::IntArray ( int32_t *  data,
size_t  size 
)
inline

Definition at line 12 of file IntArray.h.

Member Function Documentation

◆ add() [1/2]

void IntArray::add ( IntArray  operand2)
inline

Element-wise sum between arrays.

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

Parameters
operand2second operand for the sum
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 57 of file IntArray.h.

References add().

◆ add() [2/2]

void IntArray::add ( IntArray  operand2,
IntArray  destination 
)
inline

Element-wise sum between arrays.

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

Parameters
[in]operand2second operand for the sum
[out]destinationthe destination array
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 40 of file IntArray.h.

References SimpleArray< T >::data, SimpleArray< int32_t >::data, and SimpleArray< int32_t >::size.

Referenced by add().

◆ clear()

void IntArray::clear ( )
inline

Clear the array.

Set all the values in the array to 0.

Definition at line 30 of file IntArray.h.

References setAll().

Referenced by create().

◆ copy()

static void SimpleArray< int32_t >::copy ( int32_t *  dst,
int32_t *  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< int32_t >::copyFrom ( SimpleArray< int32_t >  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< int32_t >::copyTo ( SimpleArray< int32_t >  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()

static IntArray IntArray::create ( int  size)
inlinestatic

Creates a new IntArray.

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

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

Definition at line 159 of file IntArray.h.

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

◆ destroy()

static void IntArray::destroy ( IntArray  array)
inlinestatic

Destroys a IntArray created with the create() method.

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

Definition at line 171 of file IntArray.h.

References SimpleArray< T >::data.

◆ equals()

bool SimpleArray< int32_t >::equals ( const SimpleArray< int32_t > &  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.

◆ fromFloat()

void IntArray::fromFloat ( FloatArray  source)
inline

Copies the content of a FloatArray into a IntArray, converting the float elements to fixed-point 1.31.

Parameters
[in]sourcethe source array

Definition at line 120 of file IntArray.h.

References ASSERT, SimpleArray< int32_t >::data, SimpleArray< T >::getData(), SimpleArray< T >::getSize(), setFloatValue(), and SimpleArray< int32_t >::size.

◆ getData()

int32_t * SimpleArray< int32_t >::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()

int32_t SimpleArray< int32_t >::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.

◆ getFloatValue()

float IntArray::getFloatValue ( uint32_t  n)
inline

Returns an element of the array converted to float.

Parameters
nthe array element to read.
Returns
the floating point representation of the element.

Definition at line 148 of file IntArray.h.

References SimpleArray< int32_t >::data.

Referenced by toFloat().

◆ getSize()

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

Definition at line 31 of file SimpleArray.h.

◆ insert() [1/2]

void SimpleArray< int32_t >::insert ( SimpleArray< int32_t >  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< int32_t >::insert ( SimpleArray< int32_t >  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< int32_t >::isEmpty ( ) const
inlineinherited

Definition at line 35 of file SimpleArray.h.

◆ move()

void SimpleArray< int32_t >::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 int32_t *()

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

Casting operator to T*.

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

Definition at line 157 of file SimpleArray.h.

◆ setAll()

void IntArray::setAll ( int32_t  value)
inline
Note
When built for ARM Cortex-M processor series, this method uses the optimized CMSIS library

Definition at line 15 of file IntArray.h.

References SimpleArray< int32_t >::data, and SimpleArray< int32_t >::size.

Referenced by clear().

◆ setElement()

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

Set a single value in the array.

Definition at line 50 of file SimpleArray.h.

◆ setFloatValue()

void IntArray::setFloatValue ( uint32_t  n,
float  value 
)
inline

Converts a float to int16 and stores it.

Parameters
nthe array element to write to. @value the value to write

Definition at line 138 of file IntArray.h.

References SimpleArray< int32_t >::data.

Referenced by fromFloat().

◆ shift()

void IntArray::shift ( int  shiftValue)
inline

Bitshift the array values, saturating.

Parameters
shiftValuenumber of positions to shift. A positive value will shift left, a negative value will shift right.

Definition at line 67 of file IntArray.h.

References SimpleArray< int32_t >::data, and SimpleArray< int32_t >::size.

◆ subArray()

IntArray IntArray::subArray ( int  offset,
size_t  length 
)
inline

A subset of the array.

Returns a 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 IntArray.
Returns
the newly created IntArray.
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 IntArray::destroy() on the original IntArray) as long as the IntArray returned by this method is still in use.
Calling IntArray::destroy() on a IntArray instance created with this method might cause an exception.

Definition at line 93 of file IntArray.h.

References ASSERT, SimpleArray< int32_t >::data, IntArray(), and SimpleArray< int32_t >::size.

◆ toFloat()

void IntArray::toFloat ( FloatArray  destination)
inline

Copies the content of the array to a FloatArray, interpreting the content of the IntArray as 1.31.

Parameters
[out]destinationthe destination array

Definition at line 104 of file IntArray.h.

References ASSERT, SimpleArray< int32_t >::data, SimpleArray< T >::getData(), getFloatValue(), SimpleArray< T >::getSize(), and SimpleArray< int32_t >::size.

Field Documentation

◆ data

int32_t * SimpleArray< int32_t >::data
protectedinherited

Definition at line 16 of file SimpleArray.h.

◆ size

size_t SimpleArray< int32_t >::size
protectedinherited

Definition at line 17 of file SimpleArray.h.


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