file
IndexView.hThis file contains the IndexView class, a class that allows to wrap any contiguous raw data into a view which is accessible with multiple indices. This view is intended to work with Connectivity Tables storing Fortran Numbering internally 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_INDEXVIEW_BOUNDS_CHECKING" before including this header.
Example: int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9}; idx_t[2] strides = { 3, 1 }; idx_t[2] shape = { 3, 3 }; IndexView<int,2> matrix( array, strides, shape ); for( idx_t i=0; i<matrix.shape(0); ++i ) { for( idx_t j=0; j<matrix.shape(1); ++j ) { matrix(i,j) *= 10; } }
There is also an easier way to wrap Field and Array classes: IndexView<int,3> fieldview( Field ); IndexView<int,2> INDEXVIEW( Array );