9 #include <alps/config.hpp> 18 #include <boost/utility.hpp> 20 #include <type_traits> 28 namespace accumulators {
35 template<
typename U>
static char check(
typename U::result_type *);
36 template<
typename U>
static double check(...);
37 typedef std::integral_constant<bool, sizeof(char) == sizeof(check<T>(0))>
type;
38 constexpr
static bool value = type::value;
41 #define NUMERIC_FUNCTION_OPERATOR(OP_NAME, OP, OP_TOKEN) \ 43 using ::alps::numeric:: OP_NAME ; \ 44 template<typename T, typename U> struct has_operator_ ## OP_TOKEN ## _impl { \ 45 template<typename R> static char helper(R); \ 46 template<typename C, typename D> static char check(std::integral_constant<std::size_t, sizeof(helper(C() OP D()))>*); \ 47 template<typename C, typename D> static double check(...); \ 48 typedef std::integral_constant<bool, sizeof(char) == sizeof(check<T, U>(0))> type; \ 51 template<typename T, typename U> struct has_operator_ ## OP_TOKEN : public detail::has_operator_ ## OP_TOKEN ## _impl<T, U> {}; 57 #undef NUMERIC_FUNCTION_OPERATOR 60 typedef typename T::value_type
type;
66 template <
template<
typename,
typename,
typename>
class R,
67 typename T,
typename F,
typename B>
68 class make_scalar_result_type {
70 typedef typename B::scalar_result_type parent_scalar_result_type_;
71 typedef R<scalar_type_, F, parent_scalar_result_type_> this_scalar_result_type_;
73 typedef typename std::conditional<alps::is_scalar<T>::value,
83 typedef typename std::conditional<alps::is_scalar<T>::value,
91 throw std::runtime_error(
"A result cannot be merged " +
ALPS_STACKTRACE);
95 inline void collective_merge(
134 throw std::runtime_error(
"The Function operator += is not implemented for accumulators, only for results" +
ALPS_STACKTRACE);
137 throw std::runtime_error(
"The Function operator -= is not implemented for accumulators, only for results" +
ALPS_STACKTRACE);
140 throw std::runtime_error(
"The Function operator *= is not implemented for accumulators, only for results" +
ALPS_STACKTRACE);
143 throw std::runtime_error(
"The Function operator /= is not implemented for accumulators, only for results" +
ALPS_STACKTRACE);
146 throw std::runtime_error(
"The Function negate is not implemented for accumulators, only for results" +
ALPS_STACKTRACE);
149 throw std::runtime_error(
"The Function inverse is not implemented for accumulators, only for results" +
ALPS_STACKTRACE);
152 void sin() {
throw std::runtime_error(
"The Function sin is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
153 void cos() {
throw std::runtime_error(
"The Function cos is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
154 void tan() {
throw std::runtime_error(
"The Function tan is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
155 void sinh() {
throw std::runtime_error(
"The Function sinh is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
156 void cosh() {
throw std::runtime_error(
"The Function cosh is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
157 void tanh() {
throw std::runtime_error(
"The Function tanh is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
158 void asin() {
throw std::runtime_error(
"The Function asin is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
159 void acos() {
throw std::runtime_error(
"The Function acos is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
160 void atan() {
throw std::runtime_error(
"The Function atan is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
161 void abs() {
throw std::runtime_error(
"The Function ags is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
162 void sq() {
throw std::runtime_error(
"The Function sq is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
163 void sqrt() {
throw std::runtime_error(
"The Function sqrt is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
164 void cb() {
throw std::runtime_error(
"The Function cb is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
165 void cbrt() {
throw std::runtime_error(
"The Function cbrt is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
166 void exp() {
throw std::runtime_error(
"The Function exp is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
167 void log() {
throw std::runtime_error(
"The Function log is not implemented for accumulators, only for results" +
ALPS_STACKTRACE); }
171 template <
typename U,
typename Op>
void static reduce_if(
178 alps::alps_mpi::reduce(comm, arg, res, op, root);
180 template <
typename U,
typename Op>
void static reduce_if(
187 throw std::logic_error(
"No alps::mpi::reduce available for this type " + std::string(
typeid(U).name()) +
ALPS_STACKTRACE);
190 template <
typename U,
typename Op>
void static reduce_if(
196 alps::alps_mpi::reduce(comm, arg, op, root);
198 template <
typename U,
typename Op>
void static reduce_if(
204 throw std::logic_error(
"No alps::mpi::reduce available for this type " + std::string(
typeid(U).name()) +
ALPS_STACKTRACE);
209 template<
typename T,
typename F,
typename B>
class Accumulator {};
211 template<
typename T,
typename F,
typename B>
class Result {};
213 template<
typename T,
typename F,
typename B>
class BaseWrapper {};
std::conditional< alps::is_scalar< T >::value, void, ResultBase< typename alps::numeric::scalar< T >::type > >::type scalar_result_type
void operator+=(U const &)
#define NUMERIC_FUNCTION_OPERATOR(OP_NAME, OP, OP_TOKEN)
ResultBase< T > result_type
Encapsulation of an MPI communicator and some communicator-related operations.
Metafunction returning "mathematical scalar" type for type T.
void merge(const A &)
Dummy function for merging results (always throws an exception)
void operator/=(U const &)
void operator-=(U const &)
std::integral_constant< bool, sizeof(char)==sizeof(check< T >0))> type
void operator*=(U const &)