casacore
Public Member Functions | Private Attributes | List of all members

More...

#include <TSMShape.h>

Public Member Functions

 TSMShape ()
 A zero-length TSMShape. More...
 
 TSMShape (const IPosition &shape)
 Construct from a shape and precalculate some values. More...
 
 TSMShape (const TSMShape &that)
 Copy constructor (copy semantics). More...
 
TSMShapeoperator= (const TSMShape &that)
 Assignment (copy semantics). More...
 
 ~TSMShape ()
 
Int operator() (uInt index) const
 Index into the TSMShape. More...
 
uInt nelements () const
 The number of elements in this TSMShape. More...
 
Bool conform (const TSMShape &other) const
 conform returns true if nelements() == other.nelements(). More...
 
size_t offset (const IPosition &position) const
 Calculate the offset for a given position. More...
 
size_t offset (const IPosition &position, const IPosition &origin) const
 
IPosition position (size_t offset) const
 Calculate the position for a given offset. More...
 
IPosition position (size_t offset, const IPosition &origin) const
 
IPosition offsetIncrement (const IPosition &subShape) const
 Calculate the increments when stepping through an array in a linear way. More...
 
IPosition offsetIncrement (const IPosition &subShape, const IPosition &stride) const
 

Private Attributes

IPosition data_p
 
uInt size_p
 

Detailed Description

Expanded IPosition for shapes.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Etymology

TSMShape handles the shapes for the Tiled Storage Manager.

Synopsis

TSMShape is an extension of class IPosition to handle shapes. It contains some precalculated values to speed up the calculation of an array offset from an array index (and vice-versa).

Motivation

The Tiled Hypercube Storage Manager is heavily using array shapes and determining offsets from array indices. This class makes these calculations more efficient.

To Do

Definition at line 77 of file TSMShape.h.

Constructor & Destructor Documentation

◆ TSMShape() [1/3]

casacore::TSMShape::TSMShape ( )

A zero-length TSMShape.

◆ TSMShape() [2/3]

casacore::TSMShape::TSMShape ( const IPosition shape)

Construct from a shape and precalculate some values.

◆ TSMShape() [3/3]

casacore::TSMShape::TSMShape ( const TSMShape that)

Copy constructor (copy semantics).

◆ ~TSMShape()

casacore::TSMShape::~TSMShape ( )

Member Function Documentation

◆ conform()

Bool casacore::TSMShape::conform ( const TSMShape other) const
inline

conform returns true if nelements() == other.nelements().

Definition at line 174 of file TSMShape.h.

References casacore::IPosition::conform(), and data_p.

◆ nelements()

uInt casacore::TSMShape::nelements ( ) const
inline

The number of elements in this TSMShape.

Since TSMShape objects use zero-based indexing, the maximum available index is nelements() - 1.

Definition at line 164 of file TSMShape.h.

References size_p.

◆ offset() [1/2]

size_t casacore::TSMShape::offset ( const IPosition position) const

Calculate the offset for a given position.

◆ offset() [2/2]

size_t casacore::TSMShape::offset ( const IPosition position,
const IPosition origin 
) const

◆ offsetIncrement() [1/2]

IPosition casacore::TSMShape::offsetIncrement ( const IPosition subShape) const

Calculate the increments when stepping through an array in a linear way.

This can be used to update the array offset without recalculating it after each step. For example:

template<class T>
Array<T> someFunc (const Array<T>& array,
const IPosition& subArrayShape,
const IPosition& subArrayStart) const
{
TSMShape TSM (array.shape());
IPosition offsetIncr = TSM.offsetIncrement (subArrayShape);
Array<T> subArray(subArrayShape);
Bool deleteMain;
const T* mainData = array.getStorage (deleteMain);
mainData += TSM.offset (subArrayStart)
Bool deleteSub;
T* subData = subArray.getStorage (deleteSub);
for (uInt i=0; i<subArrayShape(2); i++) {
for (uInt j=0; j<subArrayShape(1); j++) {
for (uInt k=0; k<subArrayShape(0); k++) {
*subData++ = *mainData++;
}
mainData += offsetIncr(1);
}
mainData += offSetIncr(2);
}
}
TSMShape()
A zero-length TSMShape.
unsigned int uInt
Definition: aipstype.h:51
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1929
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42

◆ offsetIncrement() [2/2]

IPosition casacore::TSMShape::offsetIncrement ( const IPosition subShape,
const IPosition stride 
) const

◆ operator()()

Int casacore::TSMShape::operator() ( uInt  index) const
inline

Index into the TSMShape.

Indices are zero-based. If the preprocessor symbol AIPS_ARRAY_INDEX_CHECK is defined, "index" will be checked to ensure it is not out of bounds. If this check fails, an AipsError will be thrown.

Definition at line 169 of file TSMShape.h.

References data_p.

◆ operator=()

TSMShape& casacore::TSMShape::operator= ( const TSMShape that)

Assignment (copy semantics).

"this" and "that" must either be conformant (same size) or "this" must be 0-length, in which case it will resize itself to be the same length as "that".

◆ position() [1/2]

IPosition casacore::TSMShape::position ( size_t  offset) const

Calculate the position for a given offset.

◆ position() [2/2]

IPosition casacore::TSMShape::position ( size_t  offset,
const IPosition origin 
) const

Member Data Documentation

◆ data_p

IPosition casacore::TSMShape::data_p
private

Definition at line 159 of file TSMShape.h.

Referenced by conform(), and operator()().

◆ size_p

uInt casacore::TSMShape::size_p
private

Definition at line 160 of file TSMShape.h.

Referenced by nelements().


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