20#ifndef VOTCA_TOOLS_NDIMVECTOR_H
21#define VOTCA_TOOLS_NDIMVECTOR_H
43template <
class T,
int dim>
46 static constexpr int dim_ = dim;
48 template <
typename... IndexTypes>
50 static_assert((
sizeof...(otherDimensions) + 1 ==
dim_),
51 "Number of dimensions given does not match rank");
52 std::array<Index, dim_> indices = {firstDimension, otherDimensions...};
53 assert(std::all_of(indices.begin(), indices.end(),
55 "All indeces must be non-negative");
56 assert(std::equal(indices.begin(), indices.end(),
dimensions_.begin(),
58 return index < dimension;
60 "All indeces must be smaller than dimension");
61 return std::inner_product(indices.begin(), indices.end(),
offsets_.begin(),
70 template <
typename... IndexTypes>
74 static_assert((
sizeof...(otherDimensions) + 1 ==
dim_),
75 "Number of dimensions given does not match rank");
80 "All dimensions must be larger 0");
82 std::multiplies<Index>());
86 offsets_.begin() + 1, std::multiplies<Index>());
89 template <
typename... IndexTypes>
92 static_assert((
sizeof...(otherDimensions) + 1 ==
dim_),
93 "Number of dimensions given does not match rank");
94 std::array<Index, dim_> indices = {firstDimension, otherDimensions...};
96 std::inner_product(indices.begin(), indices.end(),
offsets_.begin(), 0);
100 template <
typename... IndexTypes>
102 IndexTypes... otherDimensions)
const {
110 typename std::vector<T>::iterator
end() {
return storage_.end(); }
111 typename std::vector<T>::const_iterator
begin()
const {
114 typename std::vector<T>::const_iterator
end()
const {
return storage_.end(); }
base class for all analysis tools