Using the C++ Math Library | ![]() ![]() |
Array Indexing
Array indexing is implemented through the interaction of three classes: mwArray
, mwSubArray
, and mwIndex
. When applied to an mwArray
, operator()
returns an mwSubArray
. The mwSubArray
``remembers'' the indexing operation and defers evaluation until the result is either assigned or referred to.
You can pass an integer, double, mwArray
, the contents of a cell or structure field, or an indexing expression as an argument to operator()
.
The mwArray
class interface contains a series of operator()
member functions that support n-dimensional indexing. Several of the functions are listed here.
This pair of operator()
member functions supports one-dimensional indexing and indexing into arrays with more than 32 dimensions. The second non-const
signature supports calls that are targets of the assignment operator and modify the contents of an array.
mwArray operator()(const mwVarargin &a) const;
mwSubArray operator()(const mwVarargin &a);
This pair of operator()
member functions supports two-dimensional indexing The second non-const
signature supports calls that are valid targets for the assignment operator.
mwArray operator()(const mwArray &a1, const mwArray &a2) const;
mwSubArray operator()(const mwArray &a1,
const mwArray &a2);
This pair of operator()
member functions supports the maximum number of arguments. To index into more than 32 dimensions, you must construct an mwVarargin
object.
mwArray operator()(const mwArray &a1,
const mwArray &a2, const mwArray &a3, . . . const mwArray &a32) const;mwSubArray operator()(const mwArray &a1,
const mwArray &a2, const mwArray &a3, . . . const mwArray &a32);
![]() | Indexing and Subscripts | Cell Content Indexing | ![]() |