1 #ifndef MPQC_MATH_TENSOR_ORDER_HPP
2 #define MPQC_MATH_TENSOR_ORDER_HPP
4 #include <boost/tuple/tuple.hpp>
5 #include <boost/fusion/include/boost_tuple.hpp>
6 #include <boost/fusion/include/boost_array.hpp>
7 #include <boost/fusion/include/as_vector.hpp>
8 #include <boost/fusion/include/at_c.hpp>
9 #include <boost/fusion/include/pop_front.hpp>
10 #include <boost/fusion/include/front.hpp>
11 #include <boost/fusion/include/pop_back.hpp>
12 #include <boost/fusion/include/back.hpp>
13 #include <boost/fusion/include/accumulate.hpp>
14 #include <boost/mpl/int.hpp>
26 static boost::array<size_t,N>
strides(
const size_t *ld) {
29 for (
int i = 0; i < N; ++i) {
31 stride *= ld[N-(i+1)];
37 template<
class Index,
class Str
ides>
39 namespace fusion = boost::fusion;
40 const typename fusion::result_of::as_vector<Index>::type &v =
41 fusion::as_vector(idx);
42 ptrdiff_t diff = fusion::accumulate(fusion::pop_back(v),
49 typedef ptrdiff_t result_type;
50 const size_t *strides;
51 explicit make_index(
const size_t *strides) : strides(strides) {}
53 ptrdiff_t operator()(ptrdiff_t idx,
const T& t) {
54 return idx + t*(*strides++);
64 static boost::array<size_t,N>
strides(
const size_t *ld) {
67 for (
int i = 0; i < N; ++i) {
75 template<
class Index,
class Str
ides>
77 namespace fusion = boost::fusion;
78 const typename fusion::result_of::as_vector<Index>::type &v =
79 fusion::as_vector(idx);
80 ptrdiff_t diff = fusion::accumulate(fusion::pop_front(v),
87 typedef ptrdiff_t result_type;
88 const size_t *strides;
89 explicit make_index(
const size_t *strides) : strides(strides) {}
91 ptrdiff_t operator()(ptrdiff_t idx,
const T& t) {
92 return idx + t*(*strides++);
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
Tensor row major (i.e. last dimension is contiguous) storage order.
Definition: order.hpp:22
static boost::array< size_t, N > strides(const size_t *ld)
Constructs strides array.
Definition: order.hpp:64
static boost::array< size_t, N > strides(const size_t *ld)
Constructs strides array.
Definition: order.hpp:26
Tensor column major (i.e. first dimension is contiguous) storage order.
Definition: order.hpp:60
static ptrdiff_t index(const Index &idx, const Strides &strides)
given N-d index tuple and strides, compute 1-d index
Definition: order.hpp:76
static ptrdiff_t index(const Index &idx, const Strides &strides)
given N-d index tuple and strides, compute 1-d index
Definition: order.hpp:38
Generated at Sun Jan 26 2020 23:24:01 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.