atlas
Namespaces | Macros
ArrayView.h File Reference

This file contains the ArrayView class, a class that allows to wrap any contiguous raw data into a view which is accessible with multiple indices. More...

#include "atlas/library/config.h"
#include "atlas/array/native/NativeArrayView.h"
Include dependency graph for ArrayView.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 atlas
 Contains all atlas classes and methods.
 
 atlas::array
 Contains classes to operate with multidimensional arrays.
 

Macros

#define EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK(TYPE, RANK)
 
#define EXPLICIT_TEMPLATE_DECLARATION(RANK)
 

Detailed Description

This file contains the ArrayView class, a class that allows to wrap any contiguous raw data into a view which is accessible with multiple indices.

All it needs is the strides for each index, and the shape of each index. ATTENTION: The last index is stride 1

Bounds-checking can be turned ON by defining "ATLAS_ARRAYVIEW_BOUNDS_CHECKING" before including this header.

Example 1: int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9}; int[2] strides = { 3, 1 }; int[2] shape = { 3, 3 }; ArrayView<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 }; ArrayView<int,2> matrix( array, shape ); which is identical for this matrix to previous Example 1

There is also an easier way to wrap Field and Array classes:

Example 3: ArrayView<int,3> fieldview( Field ); ArrayView<int,2> arrayview( Array );

Author
Willem Deconinck

Macro Definition Documentation

◆ EXPLICIT_TEMPLATE_DECLARATION

#define EXPLICIT_TEMPLATE_DECLARATION (   RANK)
Value:
EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK( int, RANK ); \
EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK( long, RANK ); \
EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK( float, RANK ); \
EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK( double, RANK );

◆ EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK

#define EXPLICIT_TEMPLATE_DECLARATION_TYPE_RANK (   TYPE,
  RANK 
)
Value:
extern template class ArrayView<TYPE, RANK>; \
extern template class ArrayView<const TYPE, RANK>;