Next: , Previous: , Up: Top   [Contents][Index]


6 Indirection

Indirection is the ability to modify or access an array at a set of selected index values. Blitz++ provides several forms of indirection:

indirect
Three styles of indirection. 4

In all cases, Blitz++ expects a Standard Template Library container. Some useful STL containers are list<>, vector<>, deque<> and set<>. Documentation of these classes is often provided with your compiler, or see also the good documentation at http://www.sgi.com/Technology/STL/. STL containers are used because they are widely available and provide easier manipulation of “sets” than Blitz++ arrays. For example, you can easily expand and merge sets which are stored in STL containers; doing this is not so easy with Blitz++ arrays, which are designed for numerical work.

STL containers are generally included by writing

#include <list>   // for list<>
#include <vector> // for vector<>
#include <deque>  // for deque<>
#include <set>    // for set<>

The [] operator is overloaded on arrays so that the syntax array[container] provides an indirect view of the array. So far, this indirect view may only be used as an lvalue (i.e. on the left-hand side of an assignment statement).

The examples in the next sections are available in the Blitz++ distribution in <examples/indirect.cpp>.


Footnotes

(4)

From top to bottom: (1) using a list of array positions; (2) Cartesian-product indirection; (3) using a set of strips to represent an arbitrarily-shaped subset of an array.


Next: , Previous: , Up: Top   [Contents][Index]