ArrayBase.h

Classes

StorageInitPolicy -- A global enum used by some Array constructors. (full description)
ArrayBase -- Non-templated base class for templated Array class. (full description)
Global Functions -- General global functions for Arrays. (full description)

enum StorageInitPolicy

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.

Description

Synopsis

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.

class ArrayBase

Interface

Public Members
ArrayBase()
explicit ArrayBase (const IPosition& shape)
ArrayBase (const ArrayBase& other)
ArrayBase& operator= (const ArrayBase&)
virtual ~ArrayBase()
uInt ndim() const
uInt nelements() const
uInt size() const
Bool contiguousStorage() const
virtual Bool ok() const
const IPosition& shape() const
IPosition endPosition() const
const IPosition& steps() const
static uInt arrayVersion()
Protected Members
void baseCopy (const ArrayBase& that)
Bool isStorageContiguous() const
void checkVectorShape()
void checkMatrixShape()
void checkCubeShape()
void baseReform (ArrayBase& tmp, const IPosition& shape) const
void baseNonDegenerate (ArrayBase& other, const IPosition& ignoreAxes)
void baseAddDegenerate (ArrayBase&, uInt numAxes)
Int makeSubset (ArrayBase& out, const IPosition& b, const IPosition& e, const IPosition& i)
Bool conform2 (const ArrayBase& other) const
void baseMakeSteps()
void validateConformance (const ArrayBase&) const
void validateIndex (const IPosition&) const

Description

ArrayBase is only used to factor out common code from the templated Array class.

Member Description

ArrayBase()

explicit ArrayBase (const IPosition& shape)

Create an array of the given shape, i.e. after construction array.ndim() == shape.nelements() and array.shape() == shape. The origin of the Array is zero.

ArrayBase (const ArrayBase& other)

Copy constructor.

ArrayBase& operator= (const ArrayBase&)

Assignment.

virtual ~ArrayBase()

Destructor.

uInt ndim() const

The dimensionality of this array.

uInt nelements() const
uInt size() const

How many elements does this array have? Product of all axis lengths.

Bool contiguousStorage() const

Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a copy.

virtual Bool ok() const

Check to see if the Array is consistent. This is about the same thing as checking for invariants. If AIPS_DEBUG is defined, this is invoked after construction and on entry to most member functions.

const IPosition& shape() const

The length of each axis.

IPosition endPosition() const

A convenience function: endPosition(i) = shape(i) - 1; i.e. this is the IPosition of the last element of the Array.

const IPosition& steps() const

Return steps to be made if stepping one element in a dimension. This is the 'physical' step, thus it also works correctly for non-contiguous arrays. E.g. data() + steps(0) gives the second element of the first axis.

static uInt arrayVersion()

Array version for major change (used by ArrayIO). enum did not work properly with cfront 3.0.1), so replaced by a static inline function. Users won't normally use this.

void baseCopy (const ArrayBase& that)

Bool isStorageContiguous() const

Determine if the storage of a subset is contiguous.

void checkVectorShape()

Check if the shape of a vector is correct. If possible, adjust if not. It is possible if at most one axis has length > 1.

void checkMatrixShape()

Check if the shape of a matrix is correct. Adjust it if smaller.

void checkCubeShape()

Check if the shape of a cube is correct. Adjust it if smaller.

void baseReform (ArrayBase& tmp, const IPosition& shape) const

Reform the array to a shape with the same nr of elements.

void baseNonDegenerate (ArrayBase& other, const IPosition& ignoreAxes)

Remove the degenerate axes from the Array object. This is the implementation of the nonDegenerate functions. It has a different name to be able to make it virtual without having the "hide virtual function" message when compiling derived classes.

void baseAddDegenerate (ArrayBase&, uInt numAxes)

These member functions return an Array reference with the specified number of extra axes, all of length one, appended to the end of the Array. Note that the reform function can also be used to add extra axes.

Int makeSubset (ArrayBase& out, const IPosition& b, const IPosition& e, const IPosition& i)

Make a subset of an array. It checks if start,end,incr are within the array limits. It returns the offset of the subset in the array.

Bool conform2 (const ArrayBase& other) const

Are the shapes identical?

void baseMakeSteps()

Make the indexing step sizes.

void validateConformance (const ArrayBase&) const
void validateIndex (const IPosition&) const

Various helper functions.


General global functions for Arrays. (source)

Interface

uInt ArrayVolume (uInt Ndim, const Int* Shape)
uInt ArrayIndexOffset (uInt Ndim, const Int* Shape, const Int* Origin, const Int* Inc, const IPosition& Index)
uInt ArrayIndexOffset (uInt Ndim, const Int* Shape, const Int* Inc, const IPosition& Index)

Description

Review Status

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

Prerequisite

Synopsis

These are generally useful global functions which operate on all Arrays.

Member Description

uInt ArrayVolume (uInt Ndim, const Int* Shape)

What is the volume of an N-dimensional array. Shape[0]*Shape[1]*...*Shape[N-1]. An Array helper function.

uInt ArrayIndexOffset (uInt Ndim, const Int* Shape, const Int* Origin, const Int* Inc, const IPosition& Index)
uInt ArrayIndexOffset (uInt Ndim, const Int* Shape, const Int* Inc, const IPosition& Index)

What is the linear index into an "Ndim" dimensional array of the given "Shape", "Origin", and "Increment" for a given IPosition Index. An Array helper function.