casacore
|
Modules | |
Arrays_module_internal_classes | |
Internal Arrays_module classes and functions. | |
Enumerations | |
enum | casacore::StorageInitPolicy { casacore::COPY , casacore::TAKE_OVER , casacore::SHARE } |
More... | |
Functions | |
size_t | casacore::ArrayVolume (size_t Ndim, const int *Shape) |
General global functions for Arrays. | |
A module implementing multidimensional arrays and operations.
See below for an overview of the classes in this module.
This module provides classes and global functions for multidimensional arrays.
Arrays have traditionally played an important role in scientific computation. While it is certainly true that some of the reliance on arrays was due to the paucity of other data structures in FORTRAN, it is also true that computation on arrays reflects the common occurrence of regularly sampled multi-dimensioned data in science.
The Lattices are a generalization of Arrays. They can handle memory- and disk-based arrays as well as other types of arrays (eg. expressions).
The module consists of various parts:
Array is the basic array class. It is only templated on data type, not on dimensionality like the array classes in Blitz and boost. It has a non-templated base class ArrayBase.
Vector, Matrix, and Cube are the one, two, and three dimensional specializations respectively of Array.
MaskedArray is the class used to mask an Array for operations on that Array.
ArrayError is the base class for all Array exception classes.
There are several ways o iterate through an array:
Mathematical, logical, chunked mathematical and logical, IO, and other useful operations are provided for Arrays and MaskedArrays.
ArrayMath also defines various STL-style transform functions that use the Array iterators and functors like Plus to apply the mathematical and logical operations. They can, however, also be used directly on arrays of different types making it possible to, say, add a Complex and double array with a DComplex result.
It also has a transformInPlace
to avoid needless incrementing of iterators which have to be done when using std::transform
for in-place operations.
The IPosition class name is a concatenation of "Integer Position." IPosition objects are normally used to index into, and define the shapes of, Arrays and Lattices. For example, if you have a 5-dimensional array, you need an IPosition of length 5 to index into the array (or to define its shape, etc.). It is essentially a vector of integers. The IPosition vector may point to the "top right corner" of some shape, or it may be an indicator of a specific position in n-space. The interpretation is context dependent. The constructor consists of an initial argument which specifies the number of axes, followed by the appropriate number of respective axis lengths. Thus the constructor needs N+1 arguments for an IPosition of length N. IPositions have the standard integer math relationships defined. The dimensionality of the operator arguments must be the same.
The Slicer class name may be thought of as a short form of "n-Dimensional Slice Specifier."
This object is used to bundle into one place all the information necessary to specify a regular subregion within an Array or Lattice. In other words, Slicer holds the location of a "slice" of a greater whole. Construction is with up to 3 IPositions: the start location of the subspace within the greater space; the shape or end location of the subspace within the greater space; and the stride, or multiplier to be used for each axis. The stride gives the user the chance to use every i-th piece of data, rather than every position on the axis.
It is possible to leave some values in the given start or end/length unspecified. Such unspecified values default to the boundaries of the array to which the slicer will be applied. It is also possible to use a non-zero origin when applying the slicer to an array.
The detailed discussions for the classes and global functions will describe how to use them.
A global enum used by some Array constructors.
StorageInitPolicy is used in functions where an array is formed from a shape and an ordinary pointer. This enum should be in Array but that causes gcc to be unhappy.
Enumerator | |
---|---|
COPY | COPY is used when an internal copy of the storage is to be made. The array is NOT responsible for deleting the external storage. |
TAKE_OVER | TAKE_OVER is used to indicate that the Array should just use the external storage (i.e., no copy is made). The Array class is now responsible for deleting the storage (hence it must have come from a call to new[]). |
SHARE | Share means that the Array will just use the pointer (no copy), however the Array will NOT delete it upon destruction. |
Definition at line 49 of file ArrayBase.h.
size_t casacore::ArrayVolume | ( | size_t | Ndim, |
const int * | Shape | ||
) |
General global functions for Arrays.
These are generally useful global functions which operate on all Arrays.
What is the volume of an N-dimensional array. Shape[0]*Shape[1]*...*Shape[N-1]. An Array helper function.