21 #ifndef GRPPI_SEQ_DIVIDECONQUER_H 22 #define GRPPI_SEQ_DIVIDECONQUER_H 49 template <
typename Input,
typename Div
ider,
typename Solver,
typename Combiner>
50 typename std::result_of<Solver(Input)>::type
53 Divider && divider_op, Solver && solver_op,
54 Combiner && combiner_op)
56 auto subproblems = divider_op(input);
58 if (subproblems.size()<=1)
return solver_op(input);
60 using Output =
typename std::result_of<Solver(Input)>::type;
61 std::vector<Output> partials;
63 for (
auto && item : subproblems) {
66 std::forward<Divider>(divider_op), std::forward<Solver>(solver_op),
67 std::forward<Combiner>(combiner_op)));
70 Output out = partials[0] ;
72 for(
int i = 1; i<partials.size();i++){
73 out = combiner_op(out,partials[i]);
Definition: callable_traits.h:24
std::result_of< Solver(Input)>::type divide_conquer(parallel_execution_native &ex, Input &problem, Divider &÷_op, Solver &&solve_op, Combiner &&combine_op)
Invoke Divide/conquer pattern with native parallel execution.
Definition: native/divideconquer.h:124
Sequential execution policy.
Definition: sequential_execution.h:31