atlas
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
atlas::array::LocalView< Value, Rank > Class Template Reference

Multi-dimensional access existing POD array pointer. More...

#include <LocalView.h>

Public Types

using value_type = Value
 
using return_type = value_type
 

Public Member Functions

 LocalView (value_type *data, const idx_t shape[], const idx_t strides[])
 
 LocalView (value_type *data, const idx_t shape[], const idx_t strides[])
 
 LocalView (value_type *data, const idx_t shape[])
 
 LocalView (value_type *data, const idx_t shape[])
 
template<typename value_type , typename = typename std::enable_if<std::is_const<Value>::value && !std::is_const<value_type>::value>::type>
 LocalView (value_type *data, const ArrayShape &shape)
 
 LocalView (value_type *data, const ArrayShape &shape)
 
 operator const LocalView< value_type, Rank > & () const
 
template<typename... Ints>
value_type & operator() (Ints... idx)
 
template<typename... Ints>
const value_type & operator() (Ints... idx) const
 
template<typename Int , bool EnableBool = true>
std::enable_if<(Rank==1 &&EnableBool), const value_type & >::type operator[] (Int idx) const
 
template<typename Int , bool EnableBool = true>
std::enable_if<(Rank==1 &&EnableBool), value_type & >::type operator[] (Int idx)
 
idx_t size () const
 
template<typename Int >
idx_t shape (Int idx) const
 
template<typename Int >
idx_t stride (Int idx) const
 
const idx_tshape () const
 
const idx_tstrides () const
 
value_type const * data () const
 
value_type * data ()
 
bool contiguous () const
 
ENABLE_IF_NON_CONST void assign (const value_type &value)
 
void dump (std::ostream &os) const
 
template<typename... Args>
slice_t< Args... >::type slice (Args... args)
 
template<typename... Args>
const_slice_t< Args... >::type slice (Args... args) const
 

Static Public Member Functions

static constexpr idx_t rank ()
 

Static Public Attributes

static constexpr int RANK {Rank}
 

Friends

std::ostream & operator<< (std::ostream &out, const LocalView &x)
 

Detailed Description

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

Multi-dimensional access existing POD array pointer.

A LocalView is a wrapper around data that enables multidimensional access, and has the exact same API as ArrayView.

The data may be strided.

Example 1:

int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9};
int[2] strides = { 3, 1 };
int[2] shape = { 3, 3 };
LocalView<int,2> matrix( array, shape, strides );
for( idx_t i=0; i<matrix.shape(0); ++i ) {
for( idx_t j=0; j<matrix.shape(1); ++j ) {
matrix(i,j) *= 10;
}
}

Strides can also be omitted as for most common cases it can be inferred from the shape.

Example 2:

int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9};
int[2] shape = { 3, 3 };
LocalView<int,2> matrix( array, shape );
which is identical for this matrix to previous Example 1

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