This transform can be used to create a reference array that corresponds to a block of the original array. The resulting array will have equal or less dimensions. More...
#include <array.hpp>
Public Types | |
typedef pack<...> | size_type |
Size type of the reference array. | |
Public Member Functions | |
block (const block &other) | |
block (int n0,..., int nN) | |
Constructs a block transform with the given dimension sizes. | |
block (const size_type &block_size, int i0..., int iN) | |
Constructs a block transform using the size object block_size starting at indices (i0, ..., iN). | |
block & | operator= (const block &other) |
block | operator() (int i0..., int iN) const |
Creates a block transform with the same dimension sizes as the current one but starting at indices (i0, ..., iN) instead. | |
Public Attributes | |
size_type | block_size |
The size object that specifies the size of the resulting array. | |
int | iX |
For each X in [0,N], iX is the starting index of the block at dimension X. |
This transform can be used to create a reference array that corresponds to a block of the original array. The resulting array will have equal or less dimensions.
The following is a pseudo definition of the class:
template<int n0_ ..., int nN_> class block { public: typedef pack<...> size_type; // the size type of the block block() {} block(const block& other); block(int n0, ..., int nN); block(const size_type& block_size, int n0 ..., int nN); block& operator=(const block& other); block operator()(int i0 ..., int iN) const; size_type block_size; // the size object of the block int i0; // starting offset at dimension 0 . . . int iN; // starting offset at dimension N };
A block transform with template parameters n0_ ... nN_ can be applied to an array of N+1 dimensions. For each dimension X in [0,N]:
array<float[4][6][7]> a; // a 4x6x7 array block<0, -1, -1> b0; a[b0(2,0,0)] = 555; // the second and third indices are ignored // the above line is equivalent to: a[row(2)] = 555; block<-1, 0, -1> b1; a[b1(0,2,0)] = 555; // the left hand size is a float[4][7] array // the above line is equivalent to: a[column(2)] = 555; block<-1, 2, 2> b2; a[b2(0,3,3)] = 555; // the left hand size is a float[4][2][2] array // the above line is equivalent to: for (int i=0; i<a.size().i0; i++) for (int j=0; j<2; j++) for (int k=0; k<2; k++) a(i,3+j,3+k) = 555; typedef block<0, 1, 1> B3; B3 b3(2, 2); // the resulting array will have a non-constant size of 2x2 a[b3(3,3,3)] = 555; // returns a 2x2 reference array with signature float[1][1] // starting at index (3,3,3) // the above line is equivalent to: for (int j=0; j<b3.block_size.i0; j++) for (int k=0; k<b3.block_size.i1; k++) a(3,3+j,3+k) = 555; std::cin >> b3.block_size; // read the size of the two dimensions of the resulting array transform_traits<Array, B3>::array block_ref = a[b3(3,3,3)]; b_ref = 555;
lite::block< n0_..., nN_ >::block | ( | int | n0, | |
..., | ||||
int | nN | |||
) |
Constructs a block transform with the given dimension sizes.
Note that all arguments that correspond to non-variable sized dimensions are ignored. In other words, for any X in [0,N], if the template argument for nX_ is not 1 then nX will be ignored.
lite::block< n0_..., nN_ >::block | ( | const size_type & | block_size, | |
int | i0..., | |||
int | iN | |||
) |
Constructs a block transform using the size object block_size starting at indices (i0, ..., iN).
Note that for any X in [0,N], if the template argument for nX_ is -1 (i.e. the original dimension size is retained) then iX will be ignored (i.e. 0 will be assumed).
block lite::block< n0_..., nN_ >::operator() | ( | int | i0..., | |
int | iN | |||
) | const |
Creates a block transform with the same dimension sizes as the current one but starting at indices (i0, ..., iN) instead.
Note that for any X in [0,N], if the template argument for nX_ is -1 (i.e. the original dimension size is retained) then iX will be ignored (i.e. 0 will be assumed).