atlas
Public Types | Public Member Functions | List of all members
atlas::array::IndexView< Value, Rank > Class Template Reference

Multidimensional access to Array or Field objects containing index fields that are compatible with Fortran indexing. More...

#include <NativeIndexView.h>

Inheritance diagram for atlas::array::IndexView< Value, Rank >:
Inheritance graph
[legend]

Public Types

typedef Value & Index
 
using data_view_t = gridtools::data_view_tt< typename std::remove_const< Value >::type, Rank, gridtools::get_access_mode< Value >()>
 
using value_type = typename remove_const< Value >::type
 
typedef Value & Index
 

Public Member Functions

 IndexView (data_view_t data_view)
 
template<typename... Coords, typename = typename std::enable_if<( sizeof...( Coords ) == Rank ), int>::type>
Index ATLAS_HOST_DEVICE operator() (Coords... c)
 
template<typename... Coords, typename = typename std::enable_if<( sizeof...( Coords ) == Rank ), int>::type>
ATLAS_HOST_DEVICE Value const operator() (Coords... c) const
 
idx_t size () const
 
void dump (std::ostream &os) const
 
 IndexView (Value *data, const idx_t shape[Rank])
 
 IndexView (Value *data, const idx_t shape[Rank], const idx_t strides[Rank])
 
template<typename... Idx>
Index operator() (Idx... idx)
 Multidimensional index operator: view(i,j,k,...)
 
template<typename... Ints>
const value_type operator() (Ints... idx) const
 Multidimensional index operator: view(i,j,k,...)
 

Detailed Description

template<typename Value, int Rank>
class atlas::array::IndexView< Value, Rank >

Multidimensional access to Array or Field objects containing index fields that are compatible with Fortran indexing.

Index fields that are compatible with Fortran are 1-based: a value 1 corresponds to the first index in a Fortran array. In C++ the first index would of course correspond to the value 0. To stay compatible, we created this class IndexView that subtracts 1 when an index value is accessed, and adds 1 when a value is set.

If Atlas is compiled without the FORTRAN feature (ATLAS_HAVE_FORTRAN==0), then the addition and substraction of 1 is compiled out, which may slightly improve performance.


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