7 #include <boost/preprocessor/tuple/to_seq.hpp> 8 #include <boost/preprocessor/seq/for_each.hpp> 10 #include <alps/config.hpp> 15 #define ALPS_ACCUMULATOR_VALUE_TYPES_SEQ BOOST_PP_TUPLE_TO_SEQ(ALPS_ACCUMULATOR_VALUE_TYPES_SIZE, (ALPS_ACCUMULATOR_VALUE_TYPES)) 18 namespace accumulators {
25 template<
typename T,
typename B>
29 using alps::numeric::operator/;
30 using alps::numeric::operator-;
31 using alps::numeric::operator*;
40 template<
typename T,
typename B>
42 using alps::numeric::operator*;
43 using alps::numeric::operator+=;
51 template<
typename T,
typename B>
54 ar[
"mean/error"] =
error();
57 template<
typename T,
typename B>
59 using alps::numeric::operator*;
60 using alps::numeric::operator+;
64 ar[
"mean/error"] >>
error;
70 template<
typename T,
typename B>
73 const char name[]=
"mean/error";
74 const std::size_t ndim=std::is_scalar<T>::value? 0 :
get_extent(T()).size();
75 return B::can_load(ar) &&
76 detail::archive_trait<error_type>::can_load(ar, name, ndim);
80 template<
typename T,
typename B>
85 if (comm.
rank() == root) {
86 B::collective_merge(comm, root);
92 template<
typename T,
typename B>
97 B::collective_merge(comm, root);
98 if (comm.
rank() == root)
99 throw std::runtime_error(
"A const object cannot be root" +
ALPS_STACKTRACE);
105 #define ALPS_ACCUMULATOR_INST_ERROR_ACC(r, data, T) \ 106 template class Accumulator<T, error_tag, \ 107 Accumulator<T, mean_tag, \ 108 Accumulator<T, count_tag, \ 109 AccumulatorBase<T>>>>; 116 template<typename T, typename B>
117 void Result<T, error_tag, B>::
save(hdf5::archive & ar)
const {
119 ar[
"mean/error"] =
error();
122 template<
typename T,
typename B>
125 ar[
"mean/error"] >> m_error;
128 template<
typename T,
typename B>
131 const char name[]=
"mean/error";
132 const std::size_t ndim=std::is_scalar<T>::value? 0 :
get_extent(T()).size();
133 return B::can_load(ar) &&
134 detail::archive_trait<error_type>::can_load(ar, name, ndim);
137 template<
typename T,
typename B>
142 template<
typename T,
typename B>
144 using alps::numeric::operator*;
145 using alps::numeric::operator/;
150 #define NUMERIC_FUNCTION_USING \ 151 using alps::numeric::sq; \ 152 using alps::numeric::cbrt; \ 153 using alps::numeric::cb; \ 155 using alps::numeric::sqrt; \ 157 using alps::numeric::exp; \ 159 using alps::numeric::log; \ 161 using alps::numeric::abs; \ 163 using alps::numeric::pow; \ 165 using alps::numeric::sin; \ 167 using alps::numeric::cos; \ 169 using alps::numeric::tan; \ 171 using alps::numeric::sinh; \ 173 using alps::numeric::cosh; \ 175 using alps::numeric::tanh; \ 177 using alps::numeric::asin; \ 179 using alps::numeric::acos; \ 181 using alps::numeric::atan; \ 182 using alps::numeric::operator+; \ 183 using alps::numeric::operator-; \ 184 using alps::numeric::operator*; \ 185 using alps::numeric::operator/; 187 #define NUMERIC_FUNCTION_IMPLEMENTATION(FUNCTION_NAME, ERROR) \ 188 template<typename T, typename B> \ 189 void Result<T, error_tag, B>:: FUNCTION_NAME () { \ 190 B:: FUNCTION_NAME (); \ 191 NUMERIC_FUNCTION_USING \ 212 #undef NUMERIC_FUNCTION_IMPLEMENTATION 214 #define ALPS_ACCUMULATOR_INST_ERROR_RESULT(r, data, T) \ 215 template class Result<T, error_tag, \ 216 Result<T, mean_tag, \ 217 Result<T, count_tag, \ #define NUMERIC_FUNCTION_IMPLEMENTATION(FUNCTION_NAME, ERROR)
result_wrapper cbrt(result_wrapper const &arg)
void check_size(T &, U const &)
alps::numeric::scalar< error_type >::type error_scalar_type
void load(archive &ar, std::string const &path, T &value, std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t >=std::vector< std::size_t >())
boost::array< T, N > sqrt(boost::array< T, N > arg)
result_wrapper cos(result_wrapper const &arg)
result_wrapper sqrt(result_wrapper const &arg)
result_wrapper cb(result_wrapper const &arg)
#define ALPS_ACCUMULATOR_VALUE_TYPES_SEQ
result_wrapper sq(result_wrapper const &arg)
std::vector< std::size_t > get_extent(T const &value)
Encapsulation of an MPI communicator and some communicator-related operations.
mean_type< T >::type mean(T const &arg)
result_wrapper log(result_wrapper const &arg)
boost::array< T, N > exp(boost::array< T, N > arg)
alps::numeric::scalar< error_type >::type error_scalar_type
result_wrapper tanh(result_wrapper const &arg)
error_type< T >::type error(T const &arg)
result_wrapper acos(result_wrapper const &arg)
#define ALPS_ACCUMULATOR_INST_ERROR_ACC(r, data, T)
result_wrapper sin(result_wrapper const &arg)
result_wrapper asin(result_wrapper const &arg)
int rank() const
Returns process rank in this communicator.
result_wrapper tan(result_wrapper const &arg)
result_wrapper abs(result_wrapper const &arg)
alps::accumulators::error_type< B >::type error_type
result_wrapper sinh(result_wrapper const &arg)
#define ALPS_ACCUMULATOR_INST_ERROR_RESULT(r, data, T)
result_wrapper cosh(result_wrapper const &arg)
count_type< T >::type count(T const &arg)
result_wrapper atan(result_wrapper const &arg)
void save(archive &ar, std::string const &path, T const &value, std::vector< std::size_t >=std::vector< std::size_t >(), std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t >=std::vector< std::size_t >())