EasyLink
EasyLink is a C++ software development kit for developing blocks for SIMULINK (S-functions)
Public Member Functions | Protected Attributes | List of all members
Array< _Scalar > Class Template Reference

#include <Array.h>

Public Member Functions

 Array (std::string name="untitled array")
 
 Array (int nrows, int ncols=1, std::string name="untitled array", bool moveable=false)
 
 Array (const mxArray *mxarray, std::string name="untitled mxArray", bool moveable=false, bool dataCopy=false)
 
 Array (const _Scalar *data, int nrows, int ncols=1, std::string name="untitled data", bool moveable=false, bool releaseData=false)
 
 Array (Array< _Scalar > &array)
 
 ~Array ()
 
void empty ()
 
Array< _Scalar > & operator= (Array< _Scalar > &array)
 
_Scalar * getData ()
 
mxArray * getmxArray ()
 
bool isShared ()
 
int getWidth ()
 
int getNCols ()
 
int getNRows ()
 
std::string getName ()
 
_Scalar & operator[] (int i)
 
_Scalar & operator() (int row, int col)
 
void init (_Scalar x=0)
 
void reshape (int nrows, int ncols)
 
void print ()
 
void operator+= (_Scalar x)
 
void operator-= (_Scalar x)
 
void operator *= (_Scalar x)
 
void operator/= (_Scalar x)
 
Array< _Scalar > operator+ (_Scalar x)
 
Array< _Scalar > operator- (_Scalar x)
 
Array< _Scalar > operator * (_Scalar x)
 
Array< _Scalar > operator/ (_Scalar x)
 
void operator+= (const Array< _Scalar > &operand)
 
void operator-= (const Array< _Scalar > &operand)
 
void operator *= (const Array< _Scalar > &operand)
 
void operator/= (const Array< _Scalar > &operand)
 
bool operator== (const Array< _Scalar > &operand)
 
_Scalar getMax ()
 
_Scalar getMin ()
 
Array< _Scalar > operator- ()
 

Protected Attributes

int ncols
 

Detailed Description

template<typename _Scalar>
class Array< _Scalar >

Array is a template array class allowing element-wise operations.

Array is used to access input, output and parameter ports as well as MATLAB mxArray.

Definition at line 25 of file Array.h.

Constructor & Destructor Documentation

◆ Array() [1/5]

template<typename _Scalar>
Array< _Scalar >::Array ( std::string  name = "untitled array")
inline

Default constructor.

Definition at line 29 of file Array.h.

◆ Array() [2/5]

template<typename _Scalar>
Array< _Scalar >::Array ( int  nrows,
int  ncols = 1,
std::string  name = "untitled array",
bool  moveable = false 
)
inline

Construct an Array and allocate memory for data.

Set moveable to true if the Array is used as a return value (and to avoid data copy in this case).

Definition at line 46 of file Array.h.

◆ Array() [3/5]

template<typename _Scalar>
Array< _Scalar >::Array ( const mxArray< _Scalar > *  mxarray,
std::string  name = "untitled mxArray< _Scalar >",
bool  moveable = false,
bool  dataCopy = false 
)
inline

Construct an Array using an existing mxArray. The constructor do NOT allocate and NOT copy the data if dataCopy is false.

Set moveable to true if the Array is used as a return value (and to avoid data copy in this case).

Definition at line 66 of file Array.h.

◆ Array() [4/5]

template<typename _Scalar>
Array< _Scalar >::Array ( const _Scalar *  data,
int  nrows,
int  ncols = 1,
std::string  name = "untitled data",
bool  moveable = false,
bool  releaseData = false 
)
inline

Construct an Array with already allocated data without using mxArray. The constructor do NOT allocate and NOT copy the data.

Set moveable to true if the Array is used as a return value (and to avoid data copy in this case).

Set releaseData to true if the Array must free the memory during deletion.

Definition at line 99 of file Array.h.

◆ Array() [5/5]

template<typename _Scalar>
Array< _Scalar >::Array ( Array< _Scalar > &  array)
inline

Copy constructor. The method generally does a copy of the data. If the argument is moveable, the data are stolen to this argument before its deletion (no data copy).

Definition at line 115 of file Array.h.

◆ ~Array()

template<typename _Scalar>
Array< _Scalar >::~Array ( )
inline

Move constructor. C++ 2011 only. Destructor. Free the memory if not shared.

Definition at line 141 of file Array.h.

Member Function Documentation

◆ empty()

template<typename _Scalar>
void Array< _Scalar >::empty ( )
inline

Empty the array and free the memory if owned.

Definition at line 146 of file Array.h.

◆ getData()

template<typename _Scalar>
_Scalar* Array< _Scalar >::getData ( )
inline

Move assignment. C++ 2011 only. Returns the address of the data.

Definition at line 244 of file Array.h.

◆ getMax()

template<typename _Scalar>
_Scalar Array< _Scalar >::getMax ( )
inline

Returns the maximal value of the array

Definition at line 491 of file Array.h.

◆ getMin()

template<typename _Scalar>
_Scalar Array< _Scalar >::getMin ( )
inline

Returns the minimal value of the array

Definition at line 504 of file Array.h.

◆ getmxArray()

template<typename _Scalar>
mxArray* Array< _Scalar >::getmxArray ( )
inline

Returns themxarray mapped by the array (no data copy).

The obtained mxArray must not be released using mxDestroyArray.

Definition at line 251 of file Array.h.

◆ getName()

template<typename _Scalar>
std::string Array< _Scalar >::getName ( )
inline

Returns the name of the array.

Definition at line 278 of file Array.h.

◆ getNCols()

template<typename _Scalar>
int Array< _Scalar >::getNCols ( )
inline

Returns the number of columns of the array.

Definition at line 268 of file Array.h.

◆ getNRows()

template<typename _Scalar>
int Array< _Scalar >::getNRows ( )
inline

Returns the number of rows of the array.

Definition at line 273 of file Array.h.

◆ getWidth()

template<typename _Scalar>
int Array< _Scalar >::getWidth ( )
inline

Returns the number of elements of the array. For 1-D array with w elements, this method returns w. For M-by-N array, this method returns m*n.

Definition at line 263 of file Array.h.

◆ init()

template<typename _Scalar>
void Array< _Scalar >::init ( _Scalar  x = 0)
inline

Initialization of all elements at the same value.

Definition at line 300 of file Array.h.

◆ isShared()

template<typename _Scalar>
bool Array< _Scalar >::isShared ( )
inline

Returns true is the array does not own the data.

Definition at line 256 of file Array.h.

◆ operator *()

template<typename _Scalar>
Array<_Scalar> Array< _Scalar >::operator * ( _Scalar  x)
inline

Array-_Scalar multiplication.

Definition at line 388 of file Array.h.

◆ operator *=() [1/2]

template<typename _Scalar>
void Array< _Scalar >::operator *= ( _Scalar  x)
inline

In-place element-by-element multiplication.

Definition at line 354 of file Array.h.

◆ operator *=() [2/2]

template<typename _Scalar>
void Array< _Scalar >::operator *= ( const Array< _Scalar > &  operand)
inline

In-place element-by-element multiplication. Arrays must have the same dimensions.

Definition at line 433 of file Array.h.

◆ operator()()

template<typename _Scalar>
_Scalar& Array< _Scalar >::operator() ( int  row,
int  col 
)
inline

Read/write access to the element (row,col) of the array. Range errors throw an exception.

Definition at line 293 of file Array.h.

◆ operator+()

template<typename _Scalar>
Array<_Scalar> Array< _Scalar >::operator+ ( _Scalar  x)
inline

Array-_Scalar addition.

Definition at line 370 of file Array.h.

◆ operator+=() [1/2]

template<typename _Scalar>
void Array< _Scalar >::operator+= ( _Scalar  x)
inline

In-place element-by-element addition.

Definition at line 338 of file Array.h.

◆ operator+=() [2/2]

template<typename _Scalar>
void Array< _Scalar >::operator+= ( const Array< _Scalar > &  operand)
inline

In-place element-by-element addition. Arrays must have the same dimensions.

Definition at line 407 of file Array.h.

◆ operator-() [1/2]

template<typename _Scalar>
Array<_Scalar> Array< _Scalar >::operator- ( _Scalar  x)
inline

Array-_Scalar substraction.

Definition at line 379 of file Array.h.

◆ operator-() [2/2]

template<typename _Scalar>
Array<_Scalar> Array< _Scalar >::operator- ( )
inline

Returns the additive inverse of the array.

Definition at line 517 of file Array.h.

◆ operator-=() [1/2]

template<typename _Scalar>
void Array< _Scalar >::operator-= ( _Scalar  x)
inline

In-place element-by-element substraction.

Definition at line 346 of file Array.h.

◆ operator-=() [2/2]

template<typename _Scalar>
void Array< _Scalar >::operator-= ( const Array< _Scalar > &  operand)
inline

In-place element-by-element substraction. Arrays must have the same dimensions.

Definition at line 420 of file Array.h.

◆ operator/()

template<typename _Scalar>
Array<_Scalar> Array< _Scalar >::operator/ ( _Scalar  x)
inline

Array-_Scalar division.

Definition at line 397 of file Array.h.

◆ operator/=() [1/2]

template<typename _Scalar>
void Array< _Scalar >::operator/= ( _Scalar  x)
inline

In-place element-by-element division.

Definition at line 362 of file Array.h.

◆ operator/=() [2/2]

template<typename _Scalar>
void Array< _Scalar >::operator/= ( const Array< _Scalar > &  operand)
inline

In-place element-by-element division. Arrays must have the same dimensions.

Definition at line 446 of file Array.h.

◆ operator=()

template<typename _Scalar>
Array<_Scalar>& Array< _Scalar >::operator= ( Array< _Scalar > &  array)
inline

Array assignment. The method generally does a copy of the data. If the argument is moveable, the data are stolen to this argument before its deletion (no data copy).

Throws an exception if the data is shared and sizes don't match.

Definition at line 167 of file Array.h.

◆ operator==()

template<typename _Scalar>
bool Array< _Scalar >::operator== ( const Array< _Scalar > &  operand)
inline

Array-array element-by-element addition. Array-array element-by-element substraction. Array-array element-by-element multiplication (matrix product). Element-by-element comparison. Returns true if the array contains the same values. Use areEqual to compare element values.

Definition at line 475 of file Array.h.

◆ operator[]()

template<typename _Scalar>
_Scalar& Array< _Scalar >::operator[] ( int  i)
inline

Read/write access to the element i of the array. i can go from 0 to nrows*ncols-1. Range errors throw an exception.

Definition at line 285 of file Array.h.

◆ print()

template<typename _Scalar>
void Array< _Scalar >::print ( )
inline

Print the array in the console.

Definition at line 318 of file Array.h.

◆ reshape()

template<typename _Scalar>
void Array< _Scalar >::reshape ( int  nrows,
int  ncols 
)
inline

Reshaped to a new size with the same elements nrows*ncols must equal the number of elements of the array.

Definition at line 309 of file Array.h.

Member Data Documentation

◆ ncols

template<typename _Scalar>
int Array< _Scalar >::ncols
protected

Returns the inverse of the array. Return the identity matrix.

Definition at line 546 of file Array.h.


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

Copyright (c) 2014 FEMTO-ST / ENSMM / UFC / UTBM, Besançon, France. Generated by Doxygen.