Debian Codegraph @

src/atlas/array/IndexView.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 /// @file IndexView.h
12 /// This file contains the IndexView class, a class that allows to wrap any
13 /// contiguous raw data into
14 /// a view which is accessible with multiple indices.
15 /// This view is intended to work with Connectivity Tables storing Fortran
16 /// Numbering internally
17 /// All it needs is the strides for each index, and the shape of each index.
18 /// ATTENTION: The last index is stride 1
19 ///
20 /// Bounds-checking can be turned ON by defining
21 /// "ATLAS_INDEXVIEW_BOUNDS_CHECKING"
22 /// before including this header.
23 ///
24 /// Example:
25 /// int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9};
26 /// idx_t[2] strides = { 3, 1 };
27 /// idx_t[2] shape = { 3, 3 };
28 /// IndexView<int,2> matrix( array, strides, shape );
29 /// for( idx_t i=0; i<matrix.shape(0); ++i ) {
30 /// for( idx_t j=0; j<matrix.shape(1); ++j ) {
31 /// matrix(i,j) *= 10;
32 /// }
33 /// }
34 ///
35 /// There is also an easier way to wrap Field and Array classes:
36 /// IndexView<int,3> fieldview( Field );
37 /// IndexView<int,2> INDEXVIEW( Array );
38
39 #pragma once
40 #include "atlas/library/config.h"
41 #if ATLAS_HAVE_GRIDTOOLS_STORAGE
42 #include "atlas/array/gridtools/GridToolsIndexView.h"
43 #else
44 #include "atlas/array/native/NativeIndexView.h"
45 #endif