Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1TSMShape.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 21:08:36 2011 Кодировка: Поисковые слова: п п п п п п п п п |
Expanded IPosition for shapes. More...
#include <TSMShape.h>
Public Member Functions | |
TSMShape () | |
A zero-length TSMShape. | |
TSMShape (const IPosition &shape) | |
Construct from a shape and precalculate some values. | |
TSMShape (const TSMShape &that) | |
Copy constructor (copy semantics). | |
TSMShape & | operator= (const TSMShape &that) |
Assignment (copy semantics). | |
~TSMShape () | |
Int | operator() (uInt index) const |
Index into the TSMShape. | |
uInt | nelements () const |
The number of elements in this TSMShape. | |
Bool | conform (const TSMShape &other) const |
conform returns true if nelements() == other.nelements(). | |
size_t | offset (const IPosition &position) const |
Calculate the offset for a given position. | |
size_t | offset (const IPosition &position, const IPosition &origin) const |
IPosition | position (size_t offset) const |
Calculate the position for a given offset. | |
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. | |
IPosition | offsetIncrement (const IPosition &subShape, const IPosition &stride) const |
Private Attributes | |
IPosition | data_p |
uInt | size_p |
Expanded IPosition for shapes.
Internal
TSMShape handles the shapes for the Tiled Storage Manager.
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).
The Tiled Hypercube Storage Manager is heavily using array shapes and determining offsets from array indices. This class makes these calculations more efficient.
Definition at line 77 of file TSMShape.h.
casa::TSMShape::TSMShape | ( | ) |
A zero-length TSMShape.
casa::TSMShape::TSMShape | ( | const IPosition & | shape | ) |
Construct from a shape and precalculate some values.
casa::TSMShape::TSMShape | ( | const TSMShape & | that | ) |
Copy constructor (copy semantics).
casa::TSMShape::~TSMShape | ( | ) |
conform returns true if nelements() == other.nelements().
Definition at line 174 of file TSMShape.h.
References casa::IPosition::conform(), and data_p.
uInt casa::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.
size_t casa::TSMShape::offset | ( | const IPosition & | position | ) | const |
Calculate the offset for a given position.
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); } }
IPosition casa::TSMShape::offsetIncrement | ( | const IPosition & | subShape, | |
const IPosition & | stride | |||
) | const |
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.
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".
IPosition casa::TSMShape::position | ( | size_t | offset | ) | const |
Calculate the position for a given offset.
IPosition casa::TSMShape::data_p [private] |
Definition at line 159 of file TSMShape.h.
Referenced by conform(), and operator()().
uInt casa::TSMShape::size_p [private] |
Definition at line 160 of file TSMShape.h.
Referenced by nelements().