26 #ifndef MLN_FUN_P2P_FOLD_HH
27 # define MLN_FUN_P2P_FOLD_HH
33 # include <mln/core/concept/function.hh>
34 # include <mln/core/site_set/box.hh>
48 template <
typename F,
typename P>
53 template <
typename P,
69 # ifndef MLN_INCLUDE_ONLY
74 template <
int dim,
typename F>
75 struct do_fold_helper;
78 struct do_fold_helper< 1, fold< P, -1, -1, -1 > >
80 static P run(
const P&
p,
const box<P>& b)
82 P tmp(p[0] % b.
len(0));
87 template <
typename P,
int dir_0,
int dir_1>
88 struct do_fold_helper< 2, fold< P, dir_0, dir_1, -1 > >
90 static P run(
const P&
p,
const box<P>& b)
92 P tmp(dir_0 ? p[0] % b.
len(0) : p[0],
93 dir_1 ? p[1] % b.
len(1) : p[1]);
98 template <
typename P,
int dir_0,
int dir_1,
int dir_2>
99 struct do_fold_helper< 3, fold< P, dir_0, dir_1, dir_2 > >
101 static P run(
const P& p,
const box<P>& b)
103 P tmp(dir_0 ? p[0] % b.len(0) : p[0],
104 dir_1 ? p[1] % b.len(1) : p[1],
105 dir_2 ? p[2] % b.len(2) : p[2]);
110 template <
typename F,
typename P>
113 do_fold(
const F&,
const P& p,
const box<P>& b)
115 return do_fold_helper<P::dim, F>::run(p, b);
123 template <
typename P,
int dir_0,
int dir_1,
int dir_2>
129 template <
typename P,
int dir_0,
int dir_1,
int dir_2>
136 template <
typename P,
int dir_0,
int dir_1,
int dir_2>
144 # endif // ! MLN_INCLUDE_ONLY
153 #endif // ! MLN_FUN_P2P_FOLD_HH