AFF --- A container for numbers (array) by Friederich and Forbriger.
aff::ConstArray< T > Class Template Reference

Array base classThis is a multidimensional (array) container that uses a strided memory layout (Fortran shape) and counted references to data in global memory. For examples see the various test programs. More...

#include <array.h>

Inheritance diagram for aff::ConstArray< T >:
Collaboration diagram for aff::ConstArray< T >:

Public Types

Various types

In particular due to our concept of const-correctness we need several typedefs to declare types derived from the element type of the array.

This is in particular usefull for function templates that may take any container class as argument (e.g. aff::subarray) or for other classes dealing with any container (e.g. aff::Iterator). By means of these typedefs they may retrieve appropriate types they have to deal with.

See also
Member typedefs
Notes on the const-correctness of arrays
typedef aff::ConstSharedHeap< T > Trepresentation
 Type of representation. More...
 
typedef aff::Strided Tshape
 Type of shape. More...
 
typedef Tshape::Tstepper Tstepper
 Type of shape stepper. More...
 
typedef Tshape::TIndexVec TIndexVec
 we use this for one of the access operators More...
 
typedef T Tvalue
 Element type. More...
 
typedef T * Tpointer
 Type of pointer to element. More...
 
typedef T & Treference
 Type of reference to element. More...
 
typedef const T Tconst_value
 const element type More...
 
typedef const T * Tconst_pointer
 Type of pointer to const element. More...
 
typedef const T & Tconst_reference
 Type of reference to const element. More...
 
typedef ConstArray< T > Tcontainer
 Type of this array. More...
 
typedef Tcontainer Tcontainer_of_const
 Type of the array of const values. More...
 
typedef Tcontainer Tcoc
 Short for Tcontainer_of_const. More...
 

Public Member Functions

Array< T > copyout () const
 create an identical copy (deep copy) of this array More...
 
const Tshapeshape () const
 provide access to const shape More...
 
Tshapeshape ()
 allow shape manipulation More...
 
const Trepresentationrepresentation () const
 provide restricted access representation More...
 
Constructors
Note
We use the default copy constructor, which automatically invokes the copy constructors of the base classes aff::Strided and aff::SharedHeap<T>. This essentially is a shallow copy of the array, i.e. the copy will reference to the same elements in memory. See aff::Array<T>::copyin() and aff::Array<T>::copyout() for deep copy operations.
 ConstArray ()
 construct from nothing (empty) More...
 
 ConstArray (const Tshape &shape, const Trepresentation &representation)
 construct from shape and representation More...
 
Const access operators

Although we generally distinguish between the constness of the container and the constness of the contained data (see Notes on the const-correctness of arrays), we provide const element access operators the prohibit element modification. We assume that a const version of the array is usually meant to be used only for reading.

const T & operator() (const TIndexVec &index) const
 full dimensionality access More...
 
const T & operator() (const Tsubscript &i0) const
 access from 1 index value More...
 
const T & operator() (const Tsubscript &i0, const Tsubscript &i1) const
 access from 2 index values More...
 
const T & operator() (const Tsubscript &i0, const Tsubscript &i1, const Tsubscript &i2) const
 access from 3 index values More...
 
const T & operator() (const Tsubscript &i0, const Tsubscript &i1, const Tsubscript &i2, const Tsubscript &i3) const
 access from 4 index values More...
 
Shape access
const Tsubscriptf (const Tsubscript &i) const
 return first index of dimension i More...
 
const Tsubscriptl (const Tsubscript &i) const
 return last index of dimension i More...
 
access declarations
const Tsubscriptfirst (const Tsubscript &i) const
 access to base class function More...
 
const TIndexVecfirst () const
 access to base class function More...
 
const Tsubscriptlast (const Tsubscript &i) const
 last index of dimension More...
 
const TIndexVeclast () const
 return vector of last index values More...
 
Tsize size () const
 total number of mapped elements More...
 
Tsize size (const Tsubscript &i) const
 size of dimension More...
 

Protected Member Functions

Tsubscript offset (const TIndexVec &index) const
 provide access to shape offset functions for derived class More...
 
Tsubscript offset (const Tsubscript &i0) const
 provide access to shape offset functions for derived class More...
 
Tsubscript offset (const Tsubscript &i0, const Tsubscript &i1) const
 provide access to shape offset functions for derived class More...
 
Tsubscript offset (const Tsubscript &i0, const Tsubscript &i1, const Tsubscript &i2) const
 provide access to shape offset functions for derived class More...
 
Tsubscript offset (const Tsubscript &i0, const Tsubscript &i1, const Tsubscript &i2, const Tsubscript &i3) const
 provide access to shape offset functions for derived class More...
 

Private Types

typedef SimpleRigidArray< Tsize, Mmax_dimenTSizeVec
 type of size and stride array (always positive) More...
 

Private Member Functions

void check_consistency () const
 check consitency between representation and shape More...
 
Access to shape
Tsize memory_size () const
 total size of mapped memory range More...
 
Tsize size () const
 total number of mapped elements More...
 
Tsize size (const Tsubscript &i) const
 size of dimension More...
 
Tsubscript first_offset () const
 first mapped position More...
 
Tsubscript last_offset () const
 last mapped position More...
 
const Tsubscriptfirst (const Tsubscript &i) const
 first index of dimension More...
 
const TIndexVecfirst () const
 return vector of first index values More...
 
const Tsubscriptlast (const Tsubscript &i) const
 last index of dimension More...
 
const TIndexVeclast () const
 return vector of last index values More...
 
const Tsizestride (const Tsubscript &i) const
 stride of dimension More...
 
const TSizeVecstride () const
 return vector of stride values More...
 
Map index values to linear representation range
Tsubscript offset (const TIndexVec &index) const
 full dimensionality access More...
 
Tsubscript offset (const Tsubscript &i0) const
 offset from 1 index value More...
 
Tsubscript offset (const Tsubscript &i0, const Tsubscript &i1) const
 offset from 2 index values More...
 
Tsubscript offset (const Tsubscript &i0, const Tsubscript &i1, const Tsubscript &i2) const
 offset from 3 index values More...
 
Tsubscript offset (const Tsubscript &i0, const Tsubscript &i1, const Tsubscript &i2, const Tsubscript &i3) const
 offset from 4 index values More...
 
Support for slices and subarrays
Note
We intentionally call the subarray and slice functions shrink and collapse (rather than subarray and slice), because they do not return another shape instance, which is a subarray or slice. They in fact manipulate the existing instance and return itself! To get a copy, you must first create a copy and then call shrink, collapse, shift or setfirst for this copy.
Stridedshrink (const TIndexVec &last)
 subarray More...
 
Stridedshrink (const TIndexVec &first, const TIndexVec &last)
 subarray More...
 
Stridedshrink (const Tdim &i, const Tsubscript &first, const Tsubscript &last)
 subarray More...
 
Stridedshrink (const Tdim &i, const Tsubscript &last)
 subarray More...
 
Stridedcollapse (const Tdim &i, const Tsubscript &index)
 slice More...
 
Stridedshift (const Tdim &i, const Tsubscript &index)
 shift More...
 
Stridedshift (const TIndexVec &index)
 shift More...
 
Stridedsetfirst (const Tdim &i, const Tsubscript &index)
 setfirst More...
 
Stridedsetfirst (const TIndexVec &index)
 setfirst More...
 

Private Attributes

Trepresentation Mrepresentation
 representation member More...
 

Static Private Attributes

static const Tdim Mmax_dimen =4
 instantiate static member (otherwise the linker won't find it) More...
 

Detailed Description

template<class T>
class aff::ConstArray< T >

Array base class

This is a multidimensional (array) container that uses a strided memory layout (Fortran shape) and counted references to data in global memory. For examples see the various test programs.

See also
Multidimensional arrays
Common interface concepts
Notes on the const-correctness of arrays
The concept of represented memory
Replicated ConstSharedHeap
aff::Strided
aff::SharedHeap
tests/arraytest.cc
tests/f77test.cc
tests/helpertest.cc
Examples:
tests/arraytest.cc, tests/f77test.cc, tests/helpertest.cc, and tests/operatortest.cc.

Definition at line 172 of file array.h.


The documentation for this class was generated from the following file: