MatrixIter.h
Classes
- MatrixIterator -- Iterate a Matrix cursor through another Array. (full description)
- ReadOnlyMatrixIterator -- Iterate a Matrix cursor through a R/O Array. (full description)
Interface
- Public Members
- explicit MatrixIterator(Array<T> &a)
- MatrixIterator(Array<T> &a, uInt cursorAxis1, uInt cursorAxis2)
- Matrix<T> &matrix()
- Private Members
- MatrixIterator(const MatrixIterator<T> &)
- MatrixIterator<T> &operator=(const MatrixIterator<T> &)
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
MatrixIterator steps a Matrix (the "cursor") through an array.
The cursor "refers" to storage in the array, so that changing the
values in the cursor changes values in the original array.
This class is derived from ArrayIterator; basically it only adds the
matrix() member function which allows you to access the cursor as a Matrix.
The origin of the cursor, i.e. the subarray that moves through the
larger array, is always zero.
In this example we want to make a "moment" map of a cube, i.e. collapse
the "Z" axis by averaging it.
Cube<Float> cube;
MatrixIterator planeIter(cube);
Matrix<Float> average(planeIter.matrix().copy()); // init with first plane
planeIter.next(); // advance the iterator
while (! planeIter.pastEnd()) {
average += planeIter.matrix(); // Sum the next plane
planeIter.next();
}
average /= Float(cube.shape()(2)); // divide by the number of planes
Member Description
Iterate by matrices through array "a".
The first 2 axes form the cursor axes.
MatrixIterator(Array<T> &a, uInt cursorAxis1, uInt cursorAxis2)
Iterate by matrices through array "a".
The given axes form the cursor axes.
Return the matrix at the current position.
Not implemented.
MatrixIterator<T> &operator=(const MatrixIterator<T> &)
Not implemented.
Interface
Public Members
- ReadOnlyMatrixIterator(const Array<T> &a) : mi(const_cast<Array<T>&>(a))
- ReadOnlyMatrixIterator(const Array<T> &a, uInt cursorAxis1, uInt cursorAxis2) : mi(const_cast<Array<T>&>(a), cursorAxis1, cursorAxis2)
- void next()
- void reset()
- void origin()
- const Array<T> &array()
- const Matrix<T> &matrix()
- Bool atStart() const
- Bool pastEnd() const
- const IPosition &pos() const
- IPosition endPos() const
- uInt ndim() const
Private Members
- ReadOnlyMatrixIterator(const ReadOnlyMatrixIterator<T> &)
- ReadOnlyMatrixIterator<T> &operator=(const ReadOnlyMatrixIterator<T> &)
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
ReadOnlyMatrixIterator behaves exactly like MatrixIterator (cf.) only
it should be used on const Arrays.
Note that the R/O MatrixIterator is not derived from R/O
ArrayIterator.
Member Description
Not implemented.
ReadOnlyMatrixIterator<T> &operator=(const ReadOnlyMatrixIterator<T> &)
Not implemented.