IBAMR  IBAMR version 0.19.
Public Types | Public Member Functions | Public Attributes | List of all members
MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType > Class Template Reference

Const data version of the multidimensional array access template class MDA_Access. More...

#include <MDA_Access.h>

Inheritance diagram for MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >:
Inheritance graph
[legend]

Public Types

typedef MDA_IndexRange< MDA_DIM > range_t
 
typedef range_t::dim_t dim_t
 
typedef range_t::index_t index_t
 
typedef OrderType order_t
 
typedef MDA_OrderRowMajor< MDA_DIM > ::reduced_order_t reduced_order_t
 

Public Member Functions

 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_AccessConstoperator= (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_tadjustDim (dim_t d, index_t first, index_t final)
 Adjust the dimensions. More...
 
Equivalence comparison
bool operator== (const MDA_Access &r) const
 
Equivalence comparison
bool operator== (const MDA_Access &r) const
 

Public Attributes

const typedef MDA_TYPE value_t
 Type of data. More...
 

Inequivalence comparison

bool operator!= (const MDA_Access &r) const
 
const range_trange () const
 
const index_tbeg (size_t i) const
 
const index_tend (size_t i) const
 
const size_t & size (size_t i) const
 
value_toperator() (const index_t i[MDA_DIM]) const
 Grant general access to item in an arbitrary dimensional array. More...
 
value_toperator() (index_t i0) const
 Grant general access to item in a 1D array. More...
 
value_toperator() (index_t i0, index_t i1) const
 Grant general access to item in a 2D array. More...
 
value_toperator() (index_t i0, index_t i1, index_t i2) const
 Grant general access to item in a 3D array. More...
 
value_toperator() (index_t i0, index_t i1, index_t i2, index_t i3) const
 Grant general access to item in a 4D array. More...
 
value_toperator[] (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_treduce (index_t i) const
 Fix the index of the slowest dimension and return the corresponding sub-array. More...
 
value_td_ptr
 Pointer to data. More...
 
value_td_ptr1
 Value of d_ptr-beg(0), used for optimizing 1D access. More...
 
order_t d_order
 Offset computing object. More...
 
void setPtr1 ()
 

Detailed Description

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

Member Typedef Documentation

◆ range_t

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
typedef MDA_IndexRange<MDA_DIM> MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::range_t

◆ dim_t

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
typedef range_t::dim_t MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::dim_t

◆ index_t

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
typedef range_t::index_t MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::index_t

◆ order_t

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
typedef OrderType MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::order_t

◆ reduced_order_t

typedef MDA_OrderRowMajor< MDA_DIM > ::reduced_order_t MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::reduced_order_t
inherited

Constructor & Destructor Documentation

◆ MDA_AccessConst() [1/4]

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::MDA_AccessConst ( value_t p = ((MDA_TYPE*)0),
const size_t *  sz = ((size_t*)0),
const index_t st = ((index_t*)0) 
)
inline
See also
MDA_Access::MDA_Access(value_t*,const size_t*,const index_t*)
Parameters
pPointer to data
szArray sizes
stArray starting indices

◆ MDA_AccessConst() [2/4]

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::MDA_AccessConst ( value_t p,
const index_t si,
const index_t sf 
)
inline
See also
MDA_Access::MDA_Access(value_t*,const index_t*,const index_t*)
Parameters
pPointer to data
siArray of initial indices
sfArray of final indices

◆ MDA_AccessConst() [3/4]

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::MDA_AccessConst ( value_t p,
const MDA_IndexRange< MDA_DIM > &  r 
)
inline
See also
MDA_Access::MDA_Access(value_t*,const MDA_IndexRange<MDA_DIM>&)
Parameters
pPointer to data
rArray index object

◆ MDA_AccessConst() [4/4]

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::MDA_AccessConst ( const MDA_Access< MDA_TYPE, MDA_DIM, OrderType > &  r)
inline
See also
MDA_Access::MDA_Access(const MDA_Access<const MDA_TYPE,MDA_DIM>&)

Member Function Documentation

◆ operator=()

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
const MDA_AccessConst& MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::operator= ( const MDA_Access< MDA_TYPE, MDA_DIM, OrderType > &  r)
inline

◆ operator bool()

MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator bool
inlineinherited
Returns
true iff data pointer is not NULL.

◆ operator value_t *()

MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator value_t *
inlineinherited
Returns
the data pointer.

◆ setPointer()

void MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::setPointer ( value_t p)
inlineinherited
Parameters
pPointer value

◆ setSizeAndStart()

void MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::setSizeAndStart ( const size_t *  sz = ((size_t*)0),
const index_t st = ((index_t*)0) 
)
inlineinherited

Set size and starting indices.

See also
MDA_IndexRange
Parameters
szArray sizes (NULL for no change)
stStarting indices (NULL for no change)

◆ setInclusiveRange()

void MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::setInclusiveRange ( const index_t  first[MDA_DIM],
const index_t  final[MDA_DIM] 
)
inlineinherited

Set first and final indices (inclusive).

See also
MDA_IndexRange
Parameters
firstFirst valid indices (NULL for no change)
finalFinal valid indices (NULL for no change)

◆ adjustDim()

const range_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::adjustDim ( dim_t  d,
index_t  first,
index_t  final 
)
inlineinherited
See also
MDA_IndexRange::adjustDim.
Parameters
dDimension to adjust
firstIncrement to first index
finalIncrement to final index

◆ operator==()

bool MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator== ( const MDA_Access< const MDA_TYPE, MDA_DIM, MDA_OrderRowMajor< MDA_DIM > > &  r) const
inlineinherited

◆ operator!=()

bool MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator!= ( const MDA_Access< const MDA_TYPE, MDA_DIM, MDA_OrderRowMajor< MDA_DIM > > &  r) const
inlineinherited

◆ range()

const range_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::range
inlineinherited

◆ beg()

const index_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::beg ( size_t  i) const
inlineinherited

◆ end()

const index_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::end ( size_t  i) const
inlineinherited

◆ size()

const size_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::size ( size_t  i) const
inlineinherited

◆ operator()() [1/5]

value_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator() ( const index_t  i[MDA_DIM]) const
inlineinherited

This is flexible but not efficient! You should use dimension-specific accesses whenever possible.

◆ operator()() [2/5]

value_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator() ( index_t  i0) const
inlineinherited

◆ operator()() [3/5]

value_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator() ( index_t  i0,
index_t  i1 
) const
inlineinherited

◆ operator()() [4/5]

value_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator() ( index_t  i0,
index_t  i1,
index_t  i2 
) const
inlineinherited

◆ operator()() [5/5]

value_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator() ( index_t  i0,
index_t  i1,
index_t  i2,
index_t  i3 
) const
inlineinherited

◆ operator[]()

value_t& MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::operator[] ( index_t  i0) const
inlineinherited

This may be more efficient than (i) but it only works in 1D. It is not guaranteed to work if the fixed offset is negative and has greater value than the pointer address, since the addition of the two gives a negative address, which the C standard leaves as undefined behavior.

◆ reduce()

MDA_Access<const MDA_TYPE ,MDA_OrderRowMajor< MDA_DIM > ::MDA_Reduced_DIM,typename MDA_OrderRowMajor< MDA_DIM > ::reduced_order_t> MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::reduce ( index_t  i) const
inlineinherited

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
iIndex 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.

◆ setPtr1()

void MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::setPtr1
inlineprivateinherited

Member Data Documentation

◆ value_t

template<class MDA_TYPE , unsigned short MDA_DIM, class OrderType = MDA_OrderRowMajor<MDA_DIM>>
const typedef MDA_TYPE MDA_AccessConst< MDA_TYPE, MDA_DIM, OrderType >::value_t

This declaration is redundant because it should already be inherited, but the xlC compiler on ASCI Blue does not get it.

◆ d_ptr

value_t* MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::d_ptr
privateinherited

◆ d_ptr1

value_t* MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::d_ptr1
privateinherited

The use of precomputed d_ptr1=d_ptr-beg(0) speeds up 1D offset computations by allowing us to compute d_ptr1+i0 instead of d_ptr+(i0-beg(0)), saving one integer subtraction for each 1D access. However, this could be a real problem if d_ptr<beg(0). So far, that has not happened, and we are keeping our fingers crossed.

See also
setPtr1()

◆ d_order

order_t MDA_Access< const MDA_TYPE , MDA_DIM, MDA_OrderRowMajor< MDA_DIM > >::d_order
privateinherited

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