An index iterator can be obtained from an MArray
by calling indexBegin()
:
MArray<T,N> A( ... ); MArray<T,N>::IndexIterator i = A.indexBegin();
IndexIterator ltl::MArray<T,N>::indexBegin ();
IndexIterator
for the current ltl::MArray
.
An index iterator always iterates over the index ranges of the array it was created from. They are used in the same way as normal iterators, except that they have some additional methods and no operator*
:
FixedVector I = i(); // get index int x = i(1); // get index in first dimension int y = i(2); // get index in second dimension
Mostly you will prefer to use the 'automatic' version of the index iterators directly in expressions rather than creating an index iterator by hand and writing out the loop, Array Expressions. These look like an ordinary function in the expression. The "function" simply evaluates to the index of the current element during elementwise evaluation of the expression, e.g.
While indexPos()
evaluates to an int, there are also spcialized versions that return float
and double
values, indexPosFlt()
and indexPosDbl()
, respectively. These are provided for convenience to avoid having to use cast expressions frequently.
ExprNode<IndexIterDimExpr<T1,float,N>, N> ltl::indexPosFlt | ( | const MArray< T1, N > & | a, | |
const int | dim | |||
) | [inline] |
indexPosFlt() return the index value as a float. This is neccessary because of the lack of arbitrary type applicative templates, only X(T a, T b) ...
ExprNode<IndexIterDimExpr<T1,double,N>, N> ltl::indexPosDbl | ( | const MArray< T1, N > & | a, | |
const int | dim | |||
) | [inline] |
indexPosDbl() returns the index value as a double. This is neccessary because of the lack of arbitrary type applicative templates, only X(T a, T b) ...