casa
$Rev:20696$
|
A 3-D Specialization of the Array class. More...
#include <Cube.h>
Public Member Functions | |
Cube () | |
A Cube of length zero in each dimension; zero origin. | |
Cube (uInt l1, uInt l2, uInt l3) | |
A l1xl2xl3 sized cube. | |
Cube (uInt l1, uInt l2, uInt l3, const T &initialValue) | |
A l1xl2xl3 sized cube. | |
Cube (const IPosition &len) | |
A Cube where the shape ("len") is defined with IPositions. | |
Cube (const IPosition &len, const T &initialValue) | |
A Cube where the shape ("len") is defined with IPositions. | |
Cube (const Cube< T > &) | |
The copy constructor uses reference semantics. | |
Cube (const Array< T > &) | |
Construct a cube by reference from "other". | |
Cube (const IPosition &shape, T *storage, StorageInitPolicy policy=COPY) | |
Create an Cube of a given shape from a pointer. | |
Cube (const IPosition &shape, const T *storage) | |
Create an Cube of a given shape from a pointer. | |
virtual | ~Cube () |
Define a destructor, otherwise the (SUN) compiler makes a static one. | |
virtual void | assign (const Array< T > &other) |
Assign the other array (which must be dimension 3) to this cube. | |
virtual void | reference (const Array< T > &other) |
Make this cube a reference to other. | |
void | resize (uInt nx, uInt ny, uInt nz, Bool copyValues=False) |
Resize to the given shape. | |
virtual void | resize () |
Make this array a different shape. | |
virtual void | resize (const IPosition &newShape, Bool copyValues=False) |
Cube< T > & | operator= (const Cube< T > &other) |
Copy the values from other to this cube. | |
virtual Array< T > & | operator= (const Array< T > &other) |
Copy the values in other to this. | |
Array< T > & | operator= (const T &val) |
Copy val into every element of this cube; i.e. | |
Cube< T > & | operator= (const MaskedArray< T > &marray) |
Copy to this those values in marray whose corresponding elements in marray's mask are True. | |
T & | operator() (const IPosition &i) |
Single-pixel addressing. | |
const T & | operator() (const IPosition &i) const |
T & | operator() (uInt i1, uInt i2, uInt i3) |
const T & | operator() (uInt i1, uInt i2, uInt i3) const |
T & | at (uInt i1, uInt i2, uInt i3) |
const T & | at (uInt i1, uInt i2, uInt i3) const |
Cube< T > | operator() (const Slice &sliceX, const Slice &sliceY, const Slice &sliceZ) |
Take a slice of this cube. | |
const Cube< T > | operator() (const Slice &sliceX, const Slice &sliceY, const Slice &sliceZ) const |
Array< T > | operator() (const IPosition &blc, const IPosition &trc, const IPosition &incr) |
Slice using IPositions. | |
const Array< T > | operator() (const IPosition &blc, const IPosition &trc, const IPosition &incr) const |
Array< T > | operator() (const IPosition &blc, const IPosition &trc) |
Get a reference to an array section extending from start to end (inclusive). | |
const Array< T > | operator() (const IPosition &blc, const IPosition &trc) const |
Array< T > | operator() (const Slicer &slicer) |
Get a reference to an array section using a Slicer. | |
const Array< T > | operator() (const Slicer &slicer) const |
const MaskedArray< T > | operator() (const LogicalArray &mask) const |
The array is masked by the input LogicalArray. | |
MaskedArray< T > | operator() (const LogicalArray &mask) |
Return a MaskedArray. | |
const MaskedArray< T > | operator() (const MaskedLogicalArray &mask) const |
The array is masked by the input MaskedLogicalArray. | |
MaskedArray< T > | operator() (const MaskedLogicalArray &mask) |
Return a MaskedArray. | |
Matrix< T > | xyPlane (uInt zplane) |
Extract a plane as a matrix referencing the original data. | |
const Matrix< T > | xyPlane (uInt zplane) const |
Matrix< T > | xzPlane (uInt yplane) |
const Matrix< T > | xzPlane (uInt yplane) const |
Matrix< T > | yzPlane (uInt xplane) |
const Matrix< T > | yzPlane (uInt xplane) const |
void | shape (Int &s1, Int &s2, Int &s3) const |
The length of each axis of the cube. | |
const IPosition & | shape () const |
The length of each axis. | |
uInt | nrow () const |
The number of rows in the Cube, i.e. | |
uInt | ncolumn () const |
The number of columns in the Cube, i.e. | |
uInt | nplane () const |
The number of planes in the Cube, i.e. | |
virtual void | takeStorage (const IPosition &shape, T *storage, StorageInitPolicy policy=COPY) |
Replace the data values with those in the pointer storage . | |
virtual void | takeStorage (const IPosition &shape, const T *storage) |
Since the pointer is const, a copy is always taken. | |
virtual Bool | ok () const |
Checks that the cube is consistent (invariants check out). | |
Protected Member Functions | |
virtual void | doNonDegenerate (const Array< T > &other, const IPosition &ignoreAxes) |
Remove the degenerate axes from other and store result in this cube. | |
Private Member Functions | |
void | makeIndexingConstants () |
Helper fn to calculate the indexing constants. | |
Private Attributes | |
Int | xinc_p |
Cached constants to improve indexing. | |
Int | yinc_p |
Int | zinc_p |
A 3-D Specialization of the Array class.
Cube objects are three-dimensional specializations (e.g., more convenient and efficient indexing) of the general Array class. You might also want to look at the Array documentation to see inherited functionality. A tutorial on using the array classes in general is available in the "AIPS++ Programming Manual". Generally the member functions of Array are also available in Cube versions which take a pair of integers where the array needs an IPosition. Since the Cube is three-dimensional, the IPositions are overkill, although you may use those versions if you want to.
Cube<Int> ci(100,100,100); // Shape is 100x100 ci.resize(50,50,50); // Shape now 50x50
Slices may be taken with the Slice class. To take a slice, one "indexes" with one Slice(start, length, inc) for each axis, where end and inc are optional. Additionally, there is an xyPlane() member function which return a Matrix which corresponds to some plane:
Cube<Float> cube(10,20,30); for(uInt i=0; i < 30; i++) { cube.xyPlane(i) = i; // Set every 10x20 plane to its "height" }
Element-by-element arithmetic and logical operations are available (in aips/ArrayMath.h and aips/ArrayLogical.h).
As with the Arrays, if the preprocessor symbol AIPS_DEBUG is defined at compile time invariants will be checked on entry to most member functions. Additionally, if AIPS_ARRAY_INDEX_CHECK is defined index operations will be bounds-checked. Neither of these should be defined for production code.
casa::Cube< T >::Cube | ( | ) |
A Cube of length zero in each dimension; zero origin.
casa::Cube< T >::Cube | ( | uInt | l1, |
uInt | l2, | ||
uInt | l3 | ||
) |
A l1xl2xl3 sized cube.
casa::Cube< T >::Cube | ( | uInt | l1, |
uInt | l2, | ||
uInt | l3, | ||
const T & | initialValue | ||
) |
A l1xl2xl3 sized cube.
Fill it with the initial value.
casa::Cube< T >::Cube | ( | const IPosition & | len | ) |
A Cube where the shape ("len") is defined with IPositions.
casa::Cube< T >::Cube | ( | const IPosition & | len, |
const T & | initialValue | ||
) |
A Cube where the shape ("len") is defined with IPositions.
Fill it with the initial value.
casa::Cube< T >::Cube | ( | const Cube< T > & | ) |
The copy constructor uses reference semantics.
casa::Cube< T >::Cube | ( | const Array< T > & | ) |
Construct a cube by reference from "other".
"other must have ndim() of 3 or less. The warning which applies to the copy constructor is also valid here.
casa::Cube< T >::Cube | ( | const IPosition & | shape, |
T * | storage, | ||
StorageInitPolicy | policy = COPY |
||
) |
Create an Cube of a given shape from a pointer.
casa::Cube< T >::Cube | ( | const IPosition & | shape, |
const T * | storage | ||
) |
Create an Cube of a given shape from a pointer.
Because the pointer is const, a copy is always made.
virtual casa::Cube< T >::~Cube | ( | ) | [virtual] |
Define a destructor, otherwise the (SUN) compiler makes a static one.
virtual void casa::Cube< T >::assign | ( | const Array< T > & | other | ) | [virtual] |
Assign the other array (which must be dimension 3) to this cube.
If the shapes mismatch, this array is resized.
Reimplemented from casa::Array< T >.
Referenced by casa::ConvolutionFunction::setSpwSelection().
T& casa::Cube< T >::at | ( | uInt | i1, |
uInt | i2, | ||
uInt | i3 | ||
) | [inline] |
Definition at line 182 of file Cube.h.
Referenced by ASDM_TABLE_BASE::_2CASAString3D(), ASDM_TABLE_BASE::at2CASA3D(), ASDM_TABLE_BASE::basic2CASA3D(), ASDM_TABLE_BASE::ext2CASA3D(), and ASDM_TABLE_BASE::interval2CASA3D().
const T& casa::Cube< T >::at | ( | uInt | i1, |
uInt | i2, | ||
uInt | i3 | ||
) | const [inline] |
virtual void casa::Cube< T >::doNonDegenerate | ( | const Array< T > & | other, |
const IPosition & | ignoreAxes | ||
) | [protected, virtual] |
Remove the degenerate axes from other and store result in this cube.
An exception is thrown if removing degenerate axes does not result in a cube.
Reimplemented from casa::Array< T >.
void casa::Cube< T >::makeIndexingConstants | ( | ) | [private] |
Helper fn to calculate the indexing constants.
uInt casa::Cube< T >::ncolumn | ( | ) | const [inline] |
uInt casa::Cube< T >::nplane | ( | ) | const [inline] |
uInt casa::Cube< T >::nrow | ( | ) | const [inline] |
virtual Bool casa::Cube< T >::ok | ( | ) | const [virtual] |
Checks that the cube is consistent (invariants check out).
Reimplemented from casa::Array< T >.
T& casa::Cube< T >::operator() | ( | const IPosition & | i | ) | [inline] |
Single-pixel addressing.
If AIPS_ARRAY_INDEX_CHECK is defined, bounds checking is performed.
Reimplemented from casa::Array< T >.
Definition at line 159 of file Cube.h.
Referenced by casa::Cube< Complex >::operator()().
const T& casa::Cube< T >::operator() | ( | const IPosition & | i | ) | const [inline] |
Reimplemented from casa::Array< T >.
T& casa::Cube< T >::operator() | ( | uInt | i1, |
uInt | i2, | ||
uInt | i3 | ||
) | [inline] |
const T& casa::Cube< T >::operator() | ( | uInt | i1, |
uInt | i2, | ||
uInt | i3 | ||
) | const [inline] |
Cube<T> casa::Cube< T >::operator() | ( | const Slice & | sliceX, |
const Slice & | sliceY, | ||
const Slice & | sliceZ | ||
) |
Take a slice of this cube.
Slices are always indexed starting at zero. This uses reference semantics, i.e. changing a value in the slice changes the original.
Cube<Double> vd(100,100,100); //..\. vd(Slice(0,10),Slice(10,10,Slice(0,10))) = -1.0; // sub-cube set to -1.0
const Cube<T> casa::Cube< T >::operator() | ( | const Slice & | sliceX, |
const Slice & | sliceY, | ||
const Slice & | sliceZ | ||
) | const |
Array<T> casa::Cube< T >::operator() | ( | const IPosition & | blc, |
const IPosition & | trc, | ||
const IPosition & | incr | ||
) | [inline] |
Slice using IPositions.
Required to be defined, otherwise the base class versions are hidden.
Reimplemented from casa::Array< T >.
const Array<T> casa::Cube< T >::operator() | ( | const IPosition & | blc, |
const IPosition & | trc, | ||
const IPosition & | incr | ||
) | const [inline] |
Reimplemented from casa::Array< T >.
Array<T> casa::Cube< T >::operator() | ( | const IPosition & | start, |
const IPosition & | end | ||
) | [inline] |
Get a reference to an array section extending from start to end (inclusive).
Reimplemented from casa::Array< T >.
const Array<T> casa::Cube< T >::operator() | ( | const IPosition & | blc, |
const IPosition & | trc | ||
) | const [inline] |
Reimplemented from casa::Array< T >.
Array<T> casa::Cube< T >::operator() | ( | const Slicer & | ) | [inline] |
Get a reference to an array section using a Slicer.
Reimplemented from casa::Array< T >.
const Array<T> casa::Cube< T >::operator() | ( | const Slicer & | slicer | ) | const [inline] |
Reimplemented from casa::Array< T >.
const MaskedArray<T> casa::Cube< T >::operator() | ( | const LogicalArray & | mask | ) | const [inline] |
The array is masked by the input LogicalArray.
This mask must conform to the array.
Return a MaskedArray.
Reimplemented from casa::Array< T >.
MaskedArray<T> casa::Cube< T >::operator() | ( | const LogicalArray & | mask | ) | [inline] |
const MaskedArray<T> casa::Cube< T >::operator() | ( | const MaskedLogicalArray & | mask | ) | const [inline] |
The array is masked by the input MaskedLogicalArray.
The mask is effectively the AND of the internal LogicalArray and the internal mask of the MaskedLogicalArray. The MaskedLogicalArray must conform to the array.
Return a MaskedArray.
Reimplemented from casa::Array< T >.
MaskedArray<T> casa::Cube< T >::operator() | ( | const MaskedLogicalArray & | mask | ) | [inline] |
Cube<T>& casa::Cube< T >::operator= | ( | const Cube< T > & | other | ) |
Copy the values from other to this cube.
If this cube has zero elements then it will resize to be the same shape as other; otherwise other must conform to this. Note that the assign function can be used to assign a non-conforming cube.
Referenced by casa::Cube< Complex >::operator=().
virtual Array<T>& casa::Cube< T >::operator= | ( | const Array< T > & | other | ) | [virtual] |
Copy the values in other to this.
If the array on the left hand side has no elements, then it is resized to be the same size as as the array on the right hand side. Otherwise, the arrays must conform (same shapes).
IPosition shape(2,10,10); // some shape Array<Double> ad(shape); //..\. Array<Double> ad2; // N.B. ad2.nelements() == 0 ad2 = ad; // ad2 resizes, then elements // are copied. shape = 20; Array<Double> ad3(shape); ad3 = ad; // Error: arrays do not conform
Note that the assign function can be used to assign a non-conforming array.
Reimplemented from casa::Array< T >.
Array<T>& casa::Cube< T >::operator= | ( | const T & | val | ) | [inline] |
Copy val into every element of this cube; i.e.
behaves as if val were a constant conformant cube.
Reimplemented from casa::Array< T >.
Cube<T>& casa::Cube< T >::operator= | ( | const MaskedArray< T > & | marray | ) | [inline] |
Copy to this those values in marray whose corresponding elements in marray's mask are True.
Reimplemented from casa::Array< T >.
virtual void casa::Cube< T >::reference | ( | const Array< T > & | other | ) | [virtual] |
Make this cube a reference to other.
Other must be of dimensionality 3 or less.
Reimplemented from casa::Array< T >.
Referenced by casa::VBStore::reference(), and casa::LFBase::runMethod().
void casa::Cube< T >::resize | ( | uInt | nx, |
uInt | ny, | ||
uInt | nz, | ||
Bool | copyValues = False |
||
) |
Resize to the given shape.
Resize without argument is equal to resize(0,0,0).
Referenced by ASDM_TABLE_BASE::_2CASAString3D(), ASDM_TABLE_BASE::at2CASA3D(), ASDM_TABLE_BASE::ati2CASA3D(), ASDM_TABLE_BASE::basic2CASA3D(), ASDM_TABLE_BASE::enum2CASA3D(), ASDM_TABLE_BASE::ext2CASA3D(), ASDM_TABLE_BASE::interval2CASA3D(), casa::VisBuffer::modelVisCube(), casa::EPJones::setRPar(), and casa::LJJones::setRPar().
virtual void casa::Cube< T >::resize | ( | ) | [virtual] |
Make this array a different shape.
If copyValues==True
the old values are copied over to the new array. Copying is done on a per axis basis, thus a subsection with the minimum of the old and new shape is copied.
Resize without argument is equal to resize(IPosition()).
It is important to note that if multiple Array objects reference the same data storage, this Array object still references the same data storage as the other Array objects if the shape does not change. Otherwise this Array object references newly allocated storage, while the other Array objects still reference the existing data storage.
If you want to be sure that the data storage of this Array object is not referenced by other Array objects, the function unique should be called first.
Reimplemented from casa::Array< T >.
virtual void casa::Cube< T >::resize | ( | const IPosition & | newShape, |
Bool | copyValues = False |
||
) | [virtual] |
Reimplemented from casa::Array< T >.
void casa::Cube< T >::shape | ( | Int & | s1, |
Int & | s2, | ||
Int & | s3 | ||
) | const [inline] |
The length of each axis of the cube.
Definition at line 282 of file Cube.h.
Referenced by casa::VBContinuumSubtractor::checkSize(), casa::EPJones::setRPar(), and casa::LJJones::setRPar().
const IPosition& casa::Cube< T >::shape | ( | ) | const [inline] |
virtual void casa::Cube< T >::takeStorage | ( | const IPosition & | shape, |
T * | storage, | ||
StorageInitPolicy | policy = COPY |
||
) | [virtual] |
Replace the data values with those in the pointer storage
.
The results are undefined is storage does not point at nelements() or more data elements. After takeStorage() is called, unique()
is True.
Reimplemented from casa::Array< T >.
virtual void casa::Cube< T >::takeStorage | ( | const IPosition & | shape, |
const T * | storage | ||
) | [virtual] |
Since the pointer is const, a copy is always taken.
Reimplemented from casa::Array< T >.
Matrix<T> casa::Cube< T >::xyPlane | ( | uInt | zplane | ) |
Extract a plane as a matrix referencing the original data.
Of course you could also use a Matrix iterator on the cube.
const Matrix<T> casa::Cube< T >::xyPlane | ( | uInt | zplane | ) | const |
Matrix<T> casa::Cube< T >::xzPlane | ( | uInt | yplane | ) |
const Matrix<T> casa::Cube< T >::xzPlane | ( | uInt | yplane | ) | const |
Matrix<T> casa::Cube< T >::yzPlane | ( | uInt | xplane | ) |
const Matrix<T> casa::Cube< T >::yzPlane | ( | uInt | xplane | ) | const |
Int casa::Cube< T >::xinc_p [private] |
Cached constants to improve indexing.
Definition at line 323 of file Cube.h.
Referenced by casa::Cube< Complex >::at(), and casa::Cube< Complex >::operator()().
Int casa::Cube< T >::yinc_p [private] |
Definition at line 323 of file Cube.h.
Referenced by casa::Cube< Complex >::at(), and casa::Cube< Complex >::operator()().
Int casa::Cube< T >::zinc_p [private] |
Definition at line 323 of file Cube.h.
Referenced by casa::Cube< Complex >::at(), and casa::Cube< Complex >::operator()().