Next: TinyVector, Previous: Customized Arrays, Up: Top [Contents][Index]
| • Indirection position list: | Indirection using lists of array positions | |
| • Indirection Cartesian product: | Cartesian-product indirection | |
| • Indirection strip list: | Indirection with lists of strips |
Indirection is the ability to modify or access an array at a set of selected index values. Blitz++ provides several forms of indirection:
I of rows and a list
J of columns, and you want to modify the array at all (i,j) positions
where i is in I and j is in J. This is a cartesian
product of the index sets I and J.
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>.
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: TinyVector, Previous: Customized Arrays, Up: Top [Contents][Index]