MatrixIterator steps a Vector (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. Like with ArrayPositionIterator, the cursor presently only moves through the array from bottom to top in the obvious way; however one may of course iterate through a slice ("array section"). This class is derived from ArrayIterator; basically it only adds the vector() member function which allows you to access the cursor as a Vector.
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
All ArrayIterator classes should be redone.
Not implemented.
Return the matrix at the current position.
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.