1 #ifndef MPQC_MATH_TENSOR_FUNCTIONAL_HPP
2 #define MPQC_MATH_TENSOR_FUNCTIONAL_HPP
4 #include "mpqc/math/tensor/forward.hpp"
5 #include "mpqc/math/tensor/exception.hpp"
7 #include <boost/mpl/int.hpp>
8 #include <boost/fusion/include/vector.hpp>
14 template<
class F,
typename T,
typename U,
size_t N,
class Order,
class Seq>
15 void apply(F f, TensorBase<T,N,Order> t, TensorBase<U,N,Order> u,
16 const integral_tie<Seq> &idx) {
20 template<
class F,
typename T,
typename U,
size_t N,
class Order,
class Seq>
21 void apply(F f, TensorBase<T,N,Order> t, TensorBase<U,N,Order> u,
22 boost::mpl::int_<0>,
const Seq &idx) {
23 typedef integral_tie<Seq> tie;
24 f(t(tie(idx)), u(tie(idx)));
27 template<
class F,
typename T,
typename U,
size_t N,
class Order,
29 void apply(F f, TensorBase<T,N,Order> t, TensorBase<U,N,Order> u,
30 boost::mpl::int_<I>,
const Seq &idx) {
32 if (t.dims()[I-1] != u.dims()[I-1]) {
33 throw TensorDimensionsException(I-1, t.dims()[I-1], u.dims()[I-1]);
36 int n = t.dims()[I-1];
37 for (
int i = 0; i < n; ++i) {
38 apply(f, t, u, boost::mpl::int_<I-1>(),
39 boost::fusion::push_front(idx, boost::cref(i)));
43 template<
class F,
typename T,
typename U,
size_t N,
class Order>
44 void apply(F f, TensorBase<T,N,Order> t, TensorBase<U,N,Order> u) {
45 apply(f, t, u, boost::mpl::int_<N>(), boost::fusion::vector<>());
52 template <
typename T,
typename U>
53 void operator()(T &t,
const U &u)
const {
62 void operator()(T &t)
const {
73 void operator()(T &t)
const {
81 template <
typename T,
typename S>
82 void operator()(T &t,
const S &s)
const {
88 template <
typename T,
typename S>
89 void operator()(T &t,
const S &s)
const {