|
| | MDA_AccessConst (value_t *p=((MDA_TYPE *) 0), const size_t *sz=((size_t *) 0), const index_t *st=((index_t *) 0)) |
| | See the MDA_Access version of this function. More...
|
| |
| | MDA_AccessConst (value_t *p, const index_t *si, const index_t *sf) |
| | See the MDA_Access version of this function. More...
|
| |
| | MDA_AccessConst (value_t *p, const MDA_IndexRange< MDA_DIM > &r) |
| | See the MDA_Access version of this function. More...
|
| |
| | MDA_AccessConst (const MDA_Access< MDA_TYPE, MDA_DIM, OrderType > &r) |
| | Construct from an object of the non-const version. More...
|
| |
| const MDA_AccessConst & | operator= (const MDA_Access< MDA_TYPE, MDA_DIM, OrderType > &r) |
| | Assign value from an object of the non-const version. More...
|
| |
| | operator bool () const |
| | Conversion into boolean. More...
|
| |
| | operator value_t * () const |
| | Conversion into pointer. More...
|
| |
| void | setPointer (value_t *p) |
| | Set the data pointer. More...
|
| |
| void | setSizeAndStart (const size_t *sz=((size_t *) 0), const index_t *st=((index_t *) 0)) |
| |
| void | setInclusiveRange (const index_t first[MDA_DIM], const index_t final[MDA_DIM]) |
| |
| const range_t & | adjustDim (dim_t d, index_t first, index_t final) |
| | Adjust the dimensions. More...
|
| |
|
| bool | operator== (const MDA_Access &r) const |
| |
|
| bool | operator== (const MDA_Access &r) const |
| |
|
| bool | operator!= (const MDA_Access &r) const |
| |
| const range_t & | range () const |
| |
| const index_t & | beg (size_t i) const |
| |
| const index_t & | end (size_t i) const |
| |
| const size_t & | size (size_t i) const |
| |
| value_t & | operator() (const index_t i[MDA_DIM]) const |
| | Grant general access to item in an arbitrary dimensional array. More...
|
| |
| value_t & | operator() (index_t i0) const |
| | Grant general access to item in a 1D array. More...
|
| |
| value_t & | operator() (index_t i0, index_t i1) const |
| | Grant general access to item in a 2D array. More...
|
| |
| value_t & | operator() (index_t i0, index_t i1, index_t i2) const |
| | Grant general access to item in a 3D array. More...
|
| |
| value_t & | operator() (index_t i0, index_t i1, index_t i2, index_t i3) const |
| | Grant general access to item in a 4D array. More...
|
| |
| value_t & | operator[] (index_t i0) const |
| | Special case for 1D arrays, identical to operator(index_t), using pre-added fixed offsets. More...
|
| |
| MDA_Access< const MDA_TYPE, MDA_OrderRowMajor< MDA_DIM > ::MDA_Reduced_DIM, typename MDA_OrderRowMajor< MDA_DIM > ::reduced_order_t > | reduce (index_t i) const |
| | Fix the index of the slowest dimension and return the corresponding sub-array. More...
|
| |
| value_t * | d_ptr |
| | Pointer to data. More...
|
| |
| value_t * | d_ptr1 |
| | Value of d_ptr-beg(0), used for optimizing 1D access. More...
|
| |
| order_t | d_order |
| | Offset computing object. More...
|
| |
| void | setPtr1 () |
| |
template<class MDA_TYPE, unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
class MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >
This class is almost exactly identical to its non-const counterpart, MDA_Access. It is used when the data is const.
This class differs only in that the value type is a const. In fact, this class is trivial, except for the public inheritance of MDA_Access with the const type for the first template argument, a constructor to build an object from a MDA_Access object and an assignment operator to assign from a MDA_Access object. Other than that, see MDA_Access for documentations.
The interfaces that are added by this class are trivial, mirroring the interfaces defined in MDA_Access with minor changes.
- See also
- MDA_Access
This function is meant to facilitate optimization when using this class. In nested loops, the inner loops executes many times with the indices corresponding to outer loops remaining constants. This leads to many many repeated integer arithmetics operations that could be removed from the inner loop (but may not be removed automatically by the compiler optimization). To do this, reduce the array dimensionality one dimension at a time, by fixing index corresponding to the slowest varying dimension. (If you code is written to maximize cache data, this will NOT be the index of the innermost loop.)
To reduce multiple dimensions, string these calls together, i.e. array.reduce(i).reduce(j). However, since reduction contains loops that cost O(MDA_DIM) and may be difficult for compilers to optimize, you may want to save array.reduce(i) and reuse it.
- Parameters
-
| i | Index in slowest dimension, which is the first dimension in a row-major array and the last dimension in a column-major array. |
- Returns
- The sub-array of dimension
MDA_DIM-1, corresponding to the index given.