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

More...

#include <MatrixIter.h>

Public Member Functions

 MatrixIterator (Array< T, Alloc > &a)
 Iterate by matrices through array "a". More...
 
 MatrixIterator (Array< T, Alloc > &a, size_t cursorAxis1, size_t cursorAxis2)
 Iterate by matrices through array "a". More...
 
Matrix< T, Alloc > & matrix ()
 Return the matrix at the current position. More...
 
- Public Member Functions inherited from casacore::ArrayIterator< T, std::allocator< T > >
 ArrayIterator (const Array< T, std::allocator< T > > &arr, size_t byDim=1)
 Step through array "arr" over the first byDim axes (using a cursor of dimensionality "byDim"). More...
 
 ArrayIterator (const Array< T, std::allocator< T > > &arr, const IPosition &axes, bool axesAreCursor=true)
 Step through an array using the given axes. More...
 
virtual void next () override
 Move the cursor to the next position. More...
 
virtual void set (const IPosition &cursorPos) override
 Set the cursor to the given position. More...
 
virtual void reset () override
 Reset the cursor to the beginning. More...
 
Array< T, std::allocator< T > > & array ()
 Return the cursor. More...
 
virtual ArrayBasegetArray () override
 Get the array in the cursor. More...
 
- Public Member Functions inherited from casacore::ArrayPositionIterator
 ArrayPositionIterator (const IPosition &shape, const IPosition &origin, size_t byDim)
 Define the shape and origin of the volume the cursor will step through. More...
 
 ArrayPositionIterator (const IPosition &shape, size_t byDim)
 
 ArrayPositionIterator (const IPosition &shape, const IPosition &axes, bool axesAreCursor=true)
 Step through an array using the given axes. More...
 
virtual ~ArrayPositionIterator ()
 
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 IPositionpos () const
 Return the position of the cursor. More...
 
IPosition endPos () const
 Return the end position of the cursor. More...
 
size_t ndim () const
 What is the dimensionality of the volume we are iterating through? More...
 
const IPositioniterAxes () const
 Return the iteration axes. More...
 
const IPositioncursorAxes () const
 Return the cursor axes. More...
 

Private Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from casacore::ArrayPositionIterator
size_t nextStep ()
 Advance cursor to its next position and tell which dimension stepped. More...
 
size_t dimIter () const
 What is the dimensionality of the "step" the cursor takes, i.e. More...
 
- Protected Attributes inherited from casacore::ArrayIterator< T, std::allocator< T > >
std::unique_ptr< Array< T, std::allocator< T > > > ap_p
 The cursor. More...
 

Detailed Description

template<typename T, typename Alloc = std::allocator<T>>
class casacore::MatrixIterator< T, Alloc >

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
MatrixIterator(Array< T, Alloc > &a)
Iterate by matrices through array "a".
TableExprNode cube(const TableExprNode &node)
Definition: ExprNode.h:1351

Definition at line 68 of file MatrixIter.h.

Constructor & Destructor Documentation

◆ MatrixIterator() [1/3]

template<typename T , typename Alloc = std::allocator<T>>
casacore::MatrixIterator< T, Alloc >::MatrixIterator ( Array< T, Alloc > &  a)
explicit

Iterate by matrices through array "a".

The first 2 axes form the cursor axes.

◆ MatrixIterator() [2/3]

template<typename T , typename Alloc = std::allocator<T>>
casacore::MatrixIterator< T, Alloc >::MatrixIterator ( Array< T, Alloc > &  a,
size_t  cursorAxis1,
size_t  cursorAxis2 
)

Iterate by matrices through array "a".

The given axes form the cursor axes.

◆ MatrixIterator() [3/3]

template<typename T , typename Alloc = std::allocator<T>>
casacore::MatrixIterator< T, Alloc >::MatrixIterator ( const MatrixIterator< T, Alloc > &  )
privatedelete

Not implemented.

Member Function Documentation

◆ matrix()

template<typename T , typename Alloc = std::allocator<T>>
Matrix<T, Alloc>& casacore::MatrixIterator< T, Alloc >::matrix ( )
inline

Return the matrix at the current position.

Definition at line 80 of file MatrixIter.h.

References casacore::ArrayIterator< T, std::allocator< T > >::ap_p.

◆ operator=()

template<typename T , typename Alloc = std::allocator<T>>
MatrixIterator<T, Alloc>& casacore::MatrixIterator< T, Alloc >::operator= ( const MatrixIterator< T, Alloc > &  )
privatedelete

Not implemented.


The documentation for this class was generated from the following file: