LTL  2.0.x
Classes | Functions
Index Iterator Expressions

Classes

class  ltl::IndexIter< T, N >
 

Functions

template<typename T1 , int N>
ExprNode< IndexIterDimExpr< T1,
int, N >, N > 
ltl::indexPosInt (const MArray< T1, N > &a, const int dim)
 
template<typename T1 , int N>
ExprNode< IndexIterDimExpr< T1,
float, N >, N > 
ltl::indexPosFlt (const MArray< T1, N > &a, const int dim)
 
template<typename T1 , int N>
ExprNode< IndexIterDimExpr< T1,
double, N >, N > 
ltl::indexPosDbl (const MArray< T1, N > &a, const int dim)
 

Detailed Description

Iterator object holding vector of index values for each position. In many situations one has to fill arrays with values that are expressed as functions of "coordinates" within the array, or more generally, as functions of the array's indices. Imagine setting up initial conditions for a PDE, e.g. a circular sine wave on a 2-d surface. For this purpose index iterators are provided. They behave much like normal iterators, but instead of returning the array's value they return the indices of the element they currently point to.

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 ();

Return an 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.

* MArray E(10,10);
* E = indexPos(E,1)==indexPos(E,2); // 10x10 unity matrix
*

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.

Function Documentation

template<typename T1 , int N>
ExprNode<IndexIterDimExpr<T1,int,N>, N> ltl::indexPosInt ( const MArray< T1, N > &  a,
const int  dim 
)
inline

and the wrapper... use indexPosInt( A ) in an expression to refer to the current index in MArray A during expression evaluation.

Use indexPosInt( A, i ) in an expression to refer to the i-th dimension's index in MArray A during expression evaluation. The index value is returned as an int.

References ltl::MArray< T, N >::indexBegin().

Referenced by Gaussian< TPAR, TDAT, 5, 2 >::fillExp(), and ltl::Gnuplot::send().

template<typename T1 , int N>
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.

References ltl::MArray< T, N >::indexBegin().

template<typename T1 , int N>
ExprNode<IndexIterDimExpr<T1,double,N>, N> ltl::indexPosDbl ( const MArray< T1, N > &  a,
const int  dim 
)
inline