casa
5.7.0-16
|
Iterate an IPosition through the shape of an Array. More...
#include <ArrayPosIter.h>
Public Member Functions | |
ArrayPositionIterator (const IPosition &shape, const IPosition &origin, uInt byDim) | |
Define the shape and origin of the volume the cursor will step through. More... | |
ArrayPositionIterator (const IPosition &shape, uInt byDim) | |
ArrayPositionIterator (const IPosition &shape, const IPosition &axes, Bool axesAreCursor=True) | |
Step through an array using the given axes. More... | |
virtual | ~ArrayPositionIterator () |
virtual void | reset () |
Reset the cursor to the beginning of the volume. More... | |
void | origin () |
Bool | atStart () const |
Returns true of the cursor is at the origin. More... | |
Bool | pastEnd () const |
Returns true if the cursor has moved past the end of its volume. More... | |
const IPosition & | pos () const |
Return the position of the cursor. More... | |
IPosition | endPos () const |
Return the end position of the cursor. More... | |
virtual void | next () |
Advance the cursor to its next position. More... | |
virtual void | set (const IPosition &cursorPos) |
Set the cursor to the given position. More... | |
uInt | ndim () const |
What is the dimensionality of the volume we are iterating through? More... | |
const IPosition & | iterAxes () const |
Return the iteration axes. More... | |
const IPosition & | cursorAxes () const |
Return the cursor axes. More... | |
virtual ArrayBase & | getArray () |
Get the array in the cursor. More... | |
Protected Member Functions | |
uInt | nextStep () |
Advance cursor to its next position and tell which dimension stepped. More... | |
uInt | dimIter () const |
What is the dimensionality of the "step" the cursor takes, i.e. More... | |
Private Member Functions | |
void | setup (uInt byDim) |
Setup the object for the constructor. More... | |
void | setup (const IPosition &axes, Bool axesAreCursor) |
Private Attributes | |
IPosition | Start |
IPosition | Shape |
IPosition | End |
IPosition | Cursor |
Bool | atOrBeyondEnd |
IPosition | cursAxes |
IPosition | iterationAxes |
Iterate an IPosition through the shape of an Array.
ArrayPositionIterator manipulates an IPosition "cursor" through some volume defined by an origin and shape. This position can in turn be used to index into, or otherwise define a position in, an Array. Normally users won't use this class directly, rather they will use an ArrayIterator, VectorIterator or MatrixIterator object, which in turn uses this class. ArrayPositionIterator is also used in the implementation of Array.
Iteration can be done by any combination of axes, but it can only be done for full axes.
The iteration step always "fills up" its dimensionality. E.g., if we are stepping through a cube by matrices, the matrix completely fills up the plane. Class ArrayLattice in the lattices package can be used to iterate with partial volumes.
ArrayPositionIterator also serves as the base class of ArrayIterator. Function makeIterator
in class ArrayBase can be used to make an ArrayIterator without having to know the template type. Function getArray
in this class can be used to obtain the current contents of the cursor as an ArrayBase object.
Definition at line 87 of file ArrayPosIter.h.
casacore::ArrayPositionIterator::ArrayPositionIterator | ( | const IPosition & | shape, |
const IPosition & | origin, | ||
uInt | byDim | ||
) |
Define the shape and origin of the volume the cursor will step through.
Also define the dimensionality of the step. byDim==0 implies we are stepping by scalars (i.e. every element), byDim==1 implies that we are stepping by vector, ==2 by matrices, and so on. If uses the first byDim axes as the cursor volume and it steps through the remaining axes.
casacore::ArrayPositionIterator::ArrayPositionIterator | ( | const IPosition & | shape, |
const IPosition & | axes, | ||
Bool | axesAreCursor = True |
||
) |
Step through an array using the given axes.
The axes can be given in two ways:
E.g. when using iteration axes 2,0 for an array with shape [5,3,7], each iteration step returns a cursor (containing the data of axis 1). During the iteration axis 2 will vary most rapidly (as it was given first).
E.g. for a shape of [3,4,5,6] and cursor axes [2,0], the cursor size is [3,5] (axes 0 and 2), while the iteration is done over axes 1 and 3 (1 the fastest varying one).
|
inlinevirtual |
Definition at line 123 of file ArrayPosIter.h.
Bool casacore::ArrayPositionIterator::atStart | ( | ) | const |
Returns true of the cursor is at the origin.
|
inline |
|
inlineprotected |
What is the dimensionality of the "step" the cursor takes, i.e.
0 for scalars, 1 for vector,....
Definition at line 177 of file ArrayPosIter.h.
References cursAxes, and casacore::IPosition::nelements().
IPosition casacore::ArrayPositionIterator::endPos | ( | ) | const |
Return the end position of the cursor.
|
virtual |
Get the array in the cursor.
This is only implemented in the derived ArrayIterator class. By default it throws an exception.
Reimplemented in casacore::ArrayIterator< T >, casacore::ArrayIterator< casacore::Double >, and casacore::ArrayIterator< casacore::Bool >.
|
inline |
|
inline |
What is the dimensionality of the volume we are iterating through?
Dimensionality of the array we are iterating through.
Definition at line 193 of file ArrayPosIter.h.
References casacore::IPosition::nelements(), and Start.
|
virtual |
Advance the cursor to its next position.
Reimplemented in casacore::ArrayIterator< T >, casacore::ArrayIterator< casacore::Double >, and casacore::ArrayIterator< casacore::Bool >.
|
protected |
Advance cursor to its next position and tell which dimension stepped.
|
inline |
Definition at line 128 of file ArrayPosIter.h.
References reset().
|
inline |
Returns true if the cursor has moved past the end of its volume.
We are at the "end" if we cannot advance any more.
Definition at line 199 of file ArrayPosIter.h.
References atOrBeyondEnd.
Referenced by casa::CalStats::stats().
|
inline |
Return the position of the cursor.
This include all axes
Definition at line 140 of file ArrayPosIter.h.
References Cursor.
Referenced by casa::CalStats::stats().
|
virtual |
Reset the cursor to the beginning of the volume.
Reimplemented in casacore::ArrayIterator< T >, casacore::ArrayIterator< casacore::Double >, and casacore::ArrayIterator< casacore::Bool >.
Referenced by origin().
|
virtual |
Set the cursor to the given position.
The position can only contain the iteration axes or it can be the full position.
In the first case the position must to be given in the order of the iteration axes as given in the constructor. In the latter case the position must be given in natural order (as given by function pos
and only the cursor axes are taken into account.
Reimplemented in casacore::ArrayIterator< T >, casacore::ArrayIterator< casacore::Double >, and casacore::ArrayIterator< casacore::Bool >.
|
private |
Setup the object for the constructor.
|
private |
Definition at line 188 of file ArrayPosIter.h.
Referenced by pastEnd().
|
private |
Definition at line 189 of file ArrayPosIter.h.
Referenced by cursorAxes(), and dimIter().
|
private |
Definition at line 187 of file ArrayPosIter.h.
Referenced by pos().
|
private |
Definition at line 187 of file ArrayPosIter.h.
|
private |
Definition at line 189 of file ArrayPosIter.h.
Referenced by iterAxes().
|
private |
Definition at line 187 of file ArrayPosIter.h.
|
private |
Definition at line 187 of file ArrayPosIter.h.
Referenced by ndim().