SM_ADC  1.0
Приём данных АЦП через разделяемую память
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Array Class Reference

#include <array.h>

Public Member Functions

 Array (string name="untitled array")
 
 Array (int nrows, int ncols=1, string name="untitled array", bool moveable=false)
 
 Array (const mxArray *mxarray, string name="untitled mxArray", bool moveable=false, bool dataCopy=false)
 
 Array (const double *data, int nrows, int ncols=1, string name="untitled data", bool moveable=false, bool releaseData=false)
 
 Array (const Array &array)
 
 ~Array ()
 
void empty ()
 
void operator= (const Array &array)
 
double * getData ()
 
mxArray * getmxArrayCopy () const
 
bool isShared ()
 
int getWidth ()
 
int getNCols ()
 
int getNRows ()
 
string getName ()
 
double & operator[] (int i)
 
double & operator() (int row, int col)
 
void init (double x=0)
 
void reshape (int nrows, int ncols)
 
void print ()
 
Array callMatlab (string cmd)
 
Array callMatlab (string cmd, const Array &operand2)
 
Array callMatlab (string cmd, double operand2)
 
void operator+= (double x)
 
void operator-= (double x)
 
void operator*= (double x)
 
void operator/= (double x)
 
Array operator+ (double x)
 
Array operator- (double x)
 
Array operator* (double x)
 
Array operator/ (double x)
 
void operator+= (const Array &operand)
 
void operator-= (const Array &operand)
 
void operator*= (const Array &operand)
 
void operator/= (const Array &operand)
 
Array operator+ (const Array &operand)
 
Array operator- (const Array &operand)
 
Array operator* (const Array &operand)
 
bool operator== (const Array &operand)
 
double getMax ()
 
double getMin ()
 
Array opposite ()
 
Array inverse ()
 

Static Public Member Functions

static Array eye (int nrows, int ncols, string name="eye array")
 

Protected Member Functions

void stealData (const Array &array)
 
void copyOf (const Array &array)
 
string getFullName ()
 

Protected Attributes

int ncols
 
int nrows
 
mxArray * mxarray
 
double * data
 
string name
 
bool moveable
 
bool releaseData
 

Detailed Description

Array is the fundamental class underlying easyLink data manipulation.

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

Array provides intuitive functions and operators to perform various operations using a MATLAB like interface.

Definition at line 29 of file array.h.

Constructor & Destructor Documentation

◆ Array() [1/5]

Array::Array ( string  name = "untitled array")
inline

Default constructor.

Definition at line 34 of file array.h.

◆ Array() [2/5]

Array::Array ( int  nrows,
int  ncols = 1,
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 52 of file array.h.

◆ Array() [3/5]

Array::Array ( const mxArray *  mxarray,
string  name = "untitled mxArray",
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 73 of file array.h.

◆ Array() [4/5]

Array::Array ( const double *  data,
int  nrows,
int  ncols = 1,
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 110 of file array.h.

◆ Array() [5/5]

Array::Array ( const Array 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 127 of file array.h.

References moveable, and name.

◆ ~Array()

Array::~Array ( )
inline

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

Definition at line 149 of file array.h.

Member Function Documentation

◆ callMatlab() [1/3]

Array Array::callMatlab ( string  cmd)
inline

Call internal MATLAB numeric functions, MATLAB operators, or user-defined functions and applied it to the array.

Definition at line 367 of file array.h.

◆ callMatlab() [2/3]

Array Array::callMatlab ( string  cmd,
const Array operand2 
)
inline

Call internal MATLAB numeric functions, MATLAB operators, or user-defined functions and applied it to the array and to a second operand.

Definition at line 390 of file array.h.

References getmxArrayCopy(), mxarray, and name.

◆ callMatlab() [3/3]

Array Array::callMatlab ( string  cmd,
double  operand2 
)
inline

Call internal MATLAB numeric functions, MATLAB operators, or user-defined functions and applied it to the array and to a second scalar operand.

Definition at line 421 of file array.h.

References toString().

◆ copyOf()

void Array::copyOf ( const Array array)
inlineprotected

Definition at line 693 of file array.h.

References data, name, ncols, and nrows.

◆ empty()

void Array::empty ( )
inline

Empty the array and free the memory if owned.

Definition at line 158 of file array.h.

◆ eye()

static Array Array::eye ( int  nrows,
int  ncols,
string  name = "eye array" 
)
inlinestatic

Return the identity matrix.

Definition at line 662 of file array.h.

◆ getData()

double* Array::getData ( )
inline

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

Definition at line 256 of file array.h.

Referenced by BaseBlock::setDerivativeStateArray(), BaseBlock::setDiscreteStateArray(), BaseFunction::setOutputArray(), and BaseBlock::setOutputArray().

◆ getFullName()

string Array::getFullName ( )
inlineprotected

Definition at line 708 of file array.h.

References toString().

◆ getMax()

double Array::getMax ( )
inline

Returns the maximal value of the array

Definition at line 615 of file array.h.

◆ getMin()

double Array::getMin ( )
inline

Returns the minimal value of the array

Definition at line 629 of file array.h.

◆ getmxArrayCopy()

mxArray* Array::getmxArrayCopy ( ) const
inline

Returns a copy of the array within a mxArray (data copy).

The obtained mxArray must be released using mxDestroyArray.

Definition at line 264 of file array.h.

Referenced by callMatlab().

◆ getName()

string Array::getName ( )
inline

◆ getNCols()

int Array::getNCols ( )
inline

Returns the number of columns of the array.

Definition at line 287 of file array.h.

Referenced by BaseBlock::setDerivativeStateArray(), BaseBlock::setDiscreteStateArray(), BaseFunction::setOutputArray(), and BaseBlock::setOutputArray().

◆ getNRows()

int Array::getNRows ( )
inline

Returns the number of rows of the array.

Definition at line 293 of file array.h.

Referenced by BaseBlock::setDerivativeStateArray(), BaseBlock::setDiscreteStateArray(), BaseFunction::setOutputArray(), and BaseBlock::setOutputArray().

◆ getWidth()

int Array::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 281 of file array.h.

Referenced by BaseBlock::setDerivativeStateArray(), BaseBlock::setDiscreteStateArray(), BaseFunction::setOutputArray(), and BaseBlock::setOutputArray().

◆ init()

void Array::init ( double  x = 0)
inline

Initialization of all elements at the same value.

Definition at line 324 of file array.h.

◆ inverse()

Array Array::inverse ( )
inline

Returns the inverse of the array.

Definition at line 656 of file array.h.

◆ isShared()

bool Array::isShared ( )
inline

Returns true is the array does not own the data.

Definition at line 273 of file array.h.

◆ operator()()

double& Array::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 316 of file array.h.

References toString().

◆ operator*() [1/2]

Array Array::operator* ( double  x)
inline

Array-double multiplication.

Definition at line 501 of file array.h.

References moveable, name, and toString().

◆ operator*() [2/2]

Array Array::operator* ( const Array operand)
inline

Array-array multiplication (matrix product).

Definition at line 589 of file array.h.

◆ operator*=() [1/2]

void Array::operator*= ( double  x)
inline

In-place element-by-element multiplication.

Definition at line 463 of file array.h.

◆ operator*=() [2/2]

void Array::operator*= ( const Array operand)
inline

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

Definition at line 550 of file array.h.

References data, name, ncols, and nrows.

◆ operator+() [1/2]

Array Array::operator+ ( double  x)
inline

Array-double addition.

Definition at line 481 of file array.h.

References moveable, name, and toString().

◆ operator+() [2/2]

Array Array::operator+ ( const Array operand)
inline

Array-array addition.

Definition at line 577 of file array.h.

◆ operator+=() [1/2]

void Array::operator+= ( double  x)
inline

In-place element-by-element addition.

Definition at line 445 of file array.h.

◆ operator+=() [2/2]

void Array::operator+= ( const Array operand)
inline

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

Definition at line 522 of file array.h.

References data, name, ncols, and nrows.

◆ operator-() [1/2]

Array Array::operator- ( double  x)
inline

Array-double substraction.

Definition at line 491 of file array.h.

References moveable, name, and toString().

◆ operator-() [2/2]

Array Array::operator- ( const Array operand)
inline

Array-array substraction.

Definition at line 583 of file array.h.

◆ operator-=() [1/2]

void Array::operator-= ( double  x)
inline

In-place element-by-element substraction.

Definition at line 454 of file array.h.

◆ operator-=() [2/2]

void Array::operator-= ( const Array operand)
inline

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

Definition at line 536 of file array.h.

References data, name, ncols, and nrows.

◆ operator/()

Array Array::operator/ ( double  x)
inline

Array-double division.

Definition at line 511 of file array.h.

References moveable, name, and toString().

◆ operator/=() [1/2]

void Array::operator/= ( double  x)
inline

In-place element-by-element division.

Definition at line 472 of file array.h.

◆ operator/=() [2/2]

void Array::operator/= ( const Array operand)
inline

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

Definition at line 564 of file array.h.

References data, name, ncols, and nrows.

◆ operator=()

void Array::operator= ( const Array 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 180 of file array.h.

References data, moveable, name, ncols, and nrows.

◆ operator==()

bool Array::operator== ( const Array operand)
inline

Element-by-element comparison. Returns true if the array contains the same values. Use areEqual to compare double values.

Definition at line 597 of file array.h.

References areEqual(), data, ncols, and nrows.

◆ operator[]()

double& Array::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 307 of file array.h.

References toString().

◆ opposite()

Array Array::opposite ( )
inline

Returns the additive inverse of the array.

Definition at line 643 of file array.h.

References data, moveable, and name.

Referenced by operator-().

◆ print()

void Array::print ( )
inline

Print the array in the console.

Definition at line 344 of file array.h.

◆ reshape()

void Array::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 334 of file array.h.

◆ stealData()

void Array::stealData ( const Array array)
inlineprotected

Definition at line 681 of file array.h.

References data, mxarray, name, ncols, nrows, and releaseData.

Member Data Documentation

◆ data

double* Array::data
protected

◆ moveable

bool Array::moveable
protected

Definition at line 679 of file array.h.

Referenced by Array(), operator*(), operator+(), operator-(), operator/(), operator=(), and opposite().

◆ mxarray

mxArray* Array::mxarray
protected

Definition at line 676 of file array.h.

Referenced by callMatlab(), and stealData().

◆ name

string Array::name
protected

◆ ncols

int Array::ncols
protected

◆ nrows

int Array::nrows
protected

◆ releaseData

bool Array::releaseData
protected

Definition at line 679 of file array.h.

Referenced by stealData().


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