#include <Grid_fwd.hpp>
Class representing a simple n-dimensional grid structure, which supports indexing and storing values.
The values are stored in row-major order.
T | Type of the values stored in the grid. |
dimension | Dimension of the grid. |
IndexType | Type used for indexing. |
Usage example:
Definition at line 36 of file Grid_fwd.hpp.
Public Member Functions | |
Grid (const IndexArray &sizes) | |
Construct a zero initialized grid with given sizes. More... | |
Grid (const IndexArray &sizes, const T &value) | |
Construct a grid with given sizes initialized to value . More... | |
IndexArray | sizes () const |
Get grid sizes. More... | |
Index | size (int i) const |
Get side in i-th dimension. More... | |
Index | size () const |
Get total number of elements. More... | |
const std::vector< T > & | data () const |
Get read-only access to linear data. More... | |
std::vector< T > & | data () |
Get read-write access to linear data. More... | |
const T & | operator() (const IndexArray &index) const |
Readonly access to the grid. More... | |
T & | operator() (const IndexArray &index) |
Read-write access to the grid. More... | |
const T & | operator[] (const Index &index) const |
Readonly access to the grid. More... | |
T & | operator[] (const Index &index) |
Read-write access to the grid. More... | |
Index | linearIndex (const IndexArray &index) const |
Compute linear index from given multi-index. More... | |
IndexArray | multiIndex (const Index &index) const |
Compute multi-index from given linear index. More... | |
bool | inBounds (const IndexArray &index) const |
Check if given index in in bounds. More... | |
Public Types | |
enum | { dim = dimension } |
typedef T | value_type |
Type of the values stored in the grid. More... | |
typedef IndexType | Index |
Type of the index used. More... | |
typedef IndexArrayT | IndexArray |
Multiindex type. More... | |
Friends | |
template<typename U , int D, typename I , typename IA > | |
std::ostream & | operator<< (std::ostream &os, const Grid< U, D, I, IA > &grid) |
Output some information about given grid. More... | |
Static Private Member Functions | |
static Index | computeSize (const IndexArray &sizes) |
Compute the number of elements. More... | |
static bool | inBounds (const IndexArray &index, const IndexArray &bounds) |
Check if index is in given bounds. More... | |
static Index | linearIndex (const IndexArray &index, const IndexArray &bounds) |
Compute the linear index with respect to given bounds. More... | |
static IndexArray | multiIndex (Index index, const IndexArray &bounds) |
Compute the multi-index with respect to given bounds. More... | |
Private Attributes | |
IndexArray | sizes_ |
Boundary of the grid in all dimensions. More... | |
IndexType | size_ |
Total number of grid cells. More... | |
std::vector< T > | data_ |
Data stored in the grid. More... | |
anonymous enum |
Enumerator | |
---|---|
dim | Dimensionality of the domain. |
Definition at line 40 of file Grid_fwd.hpp.
|
inline |
Construct a zero initialized grid with given sizes.
Definition at line 50 of file Grid_fwd.hpp.
|
inline |
Construct a grid with given sizes initialized to value
.
Definition at line 52 of file Grid_fwd.hpp.
|
staticprivate |
|
inline |
Get read-write access to linear data.
Definition at line 65 of file Grid_fwd.hpp.
|
inline |
Get read-only access to linear data.
Definition at line 63 of file Grid_fwd.hpp.
|
inline |
Check if given index in in bounds.
Definition at line 85 of file Grid_fwd.hpp.
|
staticprivate |
|
inline |
Compute linear index from given multi-index.
Definition at line 80 of file Grid_fwd.hpp.
|
staticprivate |
|
inline |
Compute multi-index from given linear index.
Definition at line 82 of file Grid_fwd.hpp.
|
staticprivate |
|
inline |
|
inline |
|
inline |
Get total number of elements.
Definition at line 60 of file Grid_fwd.hpp.
|
inline |
|
inline |
Get grid sizes.
Definition at line 56 of file Grid_fwd.hpp.
|
friend |
Output some information about given grid.
|
private |
Data stored in the grid.
Definition at line 46 of file Grid_fwd.hpp.
|
private |
Total number of grid cells.
Definition at line 45 of file Grid_fwd.hpp.
|
private |
Boundary of the grid in all dimensions.
Definition at line 44 of file Grid_fwd.hpp.