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>
27 using alps::numeric::operator/;
35 template<
typename T,
typename B>
37 using alps::numeric::operator+=;
45 template<
typename T,
typename B>
48 ar[
"mean/value"] =
mean();
51 template<
typename T,
typename B>
53 using alps::numeric::operator*;
57 ar[
"mean/value"] >>
mean;
63 template<
typename T,
typename B>
66 const char name[]=
"mean/value";
67 const std::size_t ndim=std::is_scalar<T>::value? 0 :
get_extent(T()).size();
68 return B::can_load(ar) &&
69 detail::archive_trait<mean_type>::can_load(ar, name, ndim);
74 template<
typename T,
typename B>
79 if (comm.
rank() == root) {
80 B::collective_merge(comm, root);
86 template<
typename T,
typename B>
91 B::collective_merge(comm, root);
92 if (comm.
rank() == root)
93 throw std::runtime_error(
"A const object cannot be root" +
ALPS_STACKTRACE);
99 template<
typename T,
typename B>
104 #define ALPS_ACCUMULATOR_INST_MEAN_ACC(r, data, T) \ 105 template class Accumulator<T, mean_tag, \ 106 Accumulator<T, count_tag, AccumulatorBase<T>>>; 113 template<typename T, typename B>
114 void Result<T, mean_tag, B>::
save(hdf5::archive & ar)
const {
116 ar[
"mean/value"] =
mean();
119 template<
typename T,
typename B>
122 ar[
"mean/value"] >> m_mean;
125 template<
typename T,
typename B>
128 const char name[]=
"mean/value";
129 const std::size_t ndim=std::is_scalar<T>::value? 0 :
get_extent(T()).size();
130 return B::can_load(ar) &&
131 detail::archive_trait<mean_type>::can_load(ar, name, ndim);
134 template<
typename T,
typename B>
136 using alps::numeric::operator-;
141 template<
typename T,
typename B>
143 using alps::numeric::operator/;
146 m_mean = one / m_mean;
150 #define NUMERIC_FUNCTION_IMPLEMENTATION(FUNCTION_NAME) \ 151 template<typename T, typename B> \ 152 void Result<T, mean_tag, B>:: FUNCTION_NAME () { \ 153 B:: FUNCTION_NAME (); \ 154 using std:: FUNCTION_NAME ; \ 155 using alps::numeric:: FUNCTION_NAME ; \ 156 m_mean = FUNCTION_NAME (m_mean); \ 172 #undef NUMERIC_FUNCTION_IMPLEMENTATION 174 #define NUMERIC_FUNCTION_IMPLEMENTATION(FUNCTION_NAME) \ 175 template<typename T, typename B> \ 176 void Result<T, mean_tag, B>:: FUNCTION_NAME () { \ 177 B:: FUNCTION_NAME (); \ 178 using alps::numeric:: FUNCTION_NAME ; \ 179 using alps::numeric:: FUNCTION_NAME ; \ 180 m_mean = FUNCTION_NAME (m_mean); \ 187 #undef NUMERIC_FUNCTION_IMPLEMENTATION 189 #define ALPS_ACCUMULATOR_INST_MEAN_RESULT(r, data, T) \ 190 template class Result<T, mean_tag, \ 191 Result<T, count_tag, ResultBase<T>>>;
result_wrapper cbrt(result_wrapper const &arg)
void check_size(T &, U const &)
#define ALPS_ACCUMULATOR_INST_MEAN_RESULT(r, data, T)
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 >())
result_wrapper cos(result_wrapper const &arg)
result_wrapper sqrt(result_wrapper const &arg)
result_wrapper cb(result_wrapper const &arg)
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.
Metafunction returning "mathematical scalar" type for type T.
#define ALPS_ACCUMULATOR_VALUE_TYPES_SEQ
mean_type< T >::type mean(T const &arg)
result_wrapper log(result_wrapper const &arg)
result_wrapper tanh(result_wrapper const &arg)
result_wrapper acos(result_wrapper const &arg)
alps::accumulators::mean_type< B >::type mean_type
#define NUMERIC_FUNCTION_IMPLEMENTATION(FUNCTION_NAME)
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)
result_wrapper sinh(result_wrapper const &arg)
#define ALPS_ACCUMULATOR_INST_MEAN_ACC(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 >())