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.
A l1xl2xl3 sized cube.
A l1xl2xl3 sized cube. Fill it with the initial value.
A Cube where the shape ("len") is defined with IPositions.
A Cube where the shape ("len") is defined with IPositions. Fill it with the initial value.
The copy constructor uses reference semantics.
The copy constructor should normally be avoided. More details are available under the documentation for Array.
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.
Create an Cube of a given shape from a pointer.
Define a destructor, otherwise the (SUN) compiler makes a static one.
Assign the other array (which must be dimension 3) to this cube. If the shapes mismatch, this array is resized.
Make this cube a reference to other. Other must be of dimensionality 3 or less.
Resize to the given shape. Resize without argument is equal to resize(0,0,0).
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.
Copy val into every element of this cube; i.e. behaves as if val were a constant conformant cube.
Copy to this those values in marray whose corresponding elements in marray's mask are True.
Single-pixel addressing. If AIPS_ARRAY_INDEX_CHECK is defined, bounds checking is performed.
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
Slice using IPositions. Required to be defined, otherwise the base class versions are hidden.
The array is masked by the input LogicalArray. This mask must conform to the array.
Return a MaskedArray.
The array is masked by the input LogicalArray. This mask must conform to the array.
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.
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.
Extract a plane as a cube. We could have xzPlane, etc also if that would be of use to anyone. Of course you could also use a Matrix iterator on the cube.
The length of each axis of the cube.
The number of rows in the Cube, i.e. the length of the first axis.
The number of columns in the Cube, i.e. the length of the 2nd axis.
The number of planes in the Cube, i.e. the length of the 3rd axis.
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.
Since the pointer is const, a copy is always taken.
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.
Checks that the cube is consistent (invariants check out).