casacore
Public Member Functions | Private Member Functions | List of all members
casacore::MatrixIterator< T > Class Template Reference

Iterate a Matrix cursor through another Array. More...

#include <MatrixIter.h>

Public Member Functions

 MatrixIterator (Array< T > &a)
 Iterate by matrices through array "a". More...
 
 MatrixIterator (Array< T > &a, uInt cursorAxis1, uInt cursorAxis2)
 Iterate by matrices through array "a". More...
 
Matrix< T > & matrix ()
 Return the matrix at the current position. More...
 
- Public Member Functions inherited from casacore::ArrayIterator< T >
 ArrayIterator (const Array< T > &arr, uInt byDim=1)
 Step through array "arr" over the first byDim axes (using a cursor of dimensionality "byDim"). More...
 
 ArrayIterator (const Array< T > &arr, const IPosition &axes, Bool axesAreCursor=True)
 Step through an array using the given axes. More...
 
virtual ~ArrayIterator ()
 
virtual void next ()
 Move the cursor to the next position. More...
 
virtual void set (const IPosition &cursorPos)
 Set the cursor to the given position. More...
 
virtual void reset ()
 Reset the cursor to the beginning. More...
 
Array< T > & array ()
 Return the cursor. More...
 
virtual ArrayBasegetArray ()
 

Private Member Functions

 MatrixIterator (const MatrixIterator< T > &)
 Not implemented. More...
 
MatrixIterator< T > & operator= (const MatrixIterator< T > &)
 Not implemented. More...
 

Additional Inherited Members

- Protected Attributes inherited from casacore::ArrayIterator< T >
Array< T > * ap_p
 A pointer to the cursor. More...
 

Detailed Description

template<class T>
class casacore::MatrixIterator< T >

Iterate a Matrix cursor through another Array.

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.


Tip: 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

Definition at line 69 of file MatrixIter.h.

Constructor & Destructor Documentation

◆ MatrixIterator() [1/3]

template<class T >
casacore::MatrixIterator< T >::MatrixIterator ( Array< T > &  a)
explicit

Iterate by matrices through array "a".

The first 2 axes form the cursor axes.

◆ MatrixIterator() [2/3]

template<class T >
casacore::MatrixIterator< T >::MatrixIterator ( Array< T > &  a,
uInt  cursorAxis1,
uInt  cursorAxis2 
)

Iterate by matrices through array "a".

The given axes form the cursor axes.

◆ MatrixIterator() [3/3]

template<class T >
casacore::MatrixIterator< T >::MatrixIterator ( const MatrixIterator< T > &  )
private

Not implemented.

Member Function Documentation

◆ matrix()

template<class T >
Matrix<T>& casacore::MatrixIterator< T >::matrix ( )
inline

Return the matrix at the current position.

Definition at line 81 of file MatrixIter.h.

References casacore::ArrayIterator< T >::ap_p.

◆ operator=()

template<class T >
MatrixIterator<T>& casacore::MatrixIterator< T >::operator= ( const MatrixIterator< T > &  )
private

Not implemented.


The documentation for this class was generated from the following file:
casacore::Float
float Float
Definition: aipstype.h:54
casacore::MatrixIterator::MatrixIterator
MatrixIterator(Array< T > &a)
Iterate by matrices through array "a".
casacore::cube
TableExprNode cube(const TableExprNode &node)
Definition: ExprNode.h:1308