AFF --- A container for numbers (array) by Friederich and Forbriger.
aff::Strided Class Reference

Shape for a rectangular array layout. More...

#include <strided.h>

Inheritance diagram for aff::Strided:
Collaboration diagram for aff::Strided:

Public Types

typedef SimpleRigidArray< Tsize, Mmax_dimenTSizeVec
 type of size and stride array (always positive) More...
 
typedef SimpleRigidArray< Tsubscript, Mmax_dimenTIndexVec
 type of limit arrays (any sign) More...
 
typedef aff::util::StridedStepper Tstepper
 type of stepper More...
 

Public Member Functions

Constructors
 Strided ()
 construct and initialize to zero More...
 
 Strided (const TSizeVec &sizes, const Tsubscript &first=1, const Tsubscript &shift=0)
 construct do given size and first index More...
 
 Strided (const TIndexVec &first, const TIndexVec &last, const Tsubscript &shift=0)
 construct Fortran layout to given first and last index More...
 
 Strided (const Tsize &s0, const Tsize &s1=1, const Tsize &s2=1, const Tsize &s3=1)
 construct from given set of Fortran style sizes More...
 
Access to shape
Tsize memory_size () const
 total size of mapped memory range More...
 
Tsize size () const
 total number of mapped elements 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 Tsubscriptlast (const Tsubscript &i) const
 last index of dimension More...
 
Tsize size (const Tsubscript &i) const
 size of dimension More...
 
const Tsizestride (const Tsubscript &i) const
 stride of dimension More...
 
const TIndexVecfirst () const
 return vector of first index values More...
 
const TIndexVeclast () const
 return vector of last index values 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...
 

Static Public Attributes

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

Private Member Functions

void calculate_base (const Tsubscript &offset)
 construct do given first and last index More...
 
void setup_from_size (const TSizeVec &size, const Tsubscript &first=1, const Tsubscript &shift=0)
 setup to given size and first index More...
 

Private Attributes

TSizeVec Mstride
 
TIndexVec Mfirst
 
TIndexVec Mlast
 
TIndexVec Mbase
 

Detailed Description

Shape for a rectangular array layout.

A rectangular array layout is the usual layout for multi-dimensional arrays. This is in contrast to packed layouts for banded matrices or triangular matrices that do not hold every array element.

A Strided shape typically is constrcuted through an aff::Shaper class.

Note
dimension index is 0,1,2,... (zero-based) when calling size(i) member function e.g.
Todo:
rework documentation of Strided
Mapping of index values into linear representation range
The shape class defines how index values i0, i1, etc. are mapped into the linear adressing range used by the memory representation (see SharedHeap). The adress in the linear array is

\[ a=o+\sum\limits_{k=0}^{M-1}\;(i_k-f_k)\,s_k =\sum\limits_{k=0}^{M-1}\;i_k\,s_k+ \underbrace{o-\sum_{k=0}^{M-1}f_k\,s_k}_{=b_{M-1}}, \]

if M is the number of index values $ i_k $ passed to the access operator. In formula $ f_k $ are the elements of Mfirst, $ s_k $ are the elements of Mstride, $ b_l $ are the elements of Mbase, and $ o $ is Mbase[0] (i.e. the first accessible position within the representation.
Examples:
tests/f77test.cc, and tests/shapetest.cc.

Definition at line 117 of file strided.h.


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