9 #include <alps/config.hpp> 18 #include <boost/utility.hpp> 22 #include <type_traits> 25 namespace accumulators {
50 return m_weight.get();
58 template<
typename X>
typename std::enable_if<std::conditional<
59 std::is_scalar<typename value_type<weight_type>::type>::value
60 ,
typename std::is_convertible<X, typename value_type<weight_type>::type>::type
61 ,
typename std::is_same<X, typename value_type<weight_type>::type>::type
65 (m_weight->template extract<W>())(
weight);
68 template<
typename X>
typename std::enable_if<!std::conditional<
69 std::is_scalar<typename value_type<weight_type>::type>::value
70 ,
typename std::is_convertible<X, typename value_type<weight_type>::type>::type
71 ,
typename std::is_same<X, typename value_type<weight_type>::type>::type
73 throw std::runtime_error(
"Invalid type for binary call operator" +
ALPS_STACKTRACE);
76 template<
typename S>
void print(S & os,
bool terse=
false)
const {
79 m_weight->print(os, terse);
84 ar[
"weight/value"] = *
weight();
89 ar[
"weight/value"] >> *m_weight;
92 static std::size_t
rank() {
return B::rank() + 1; }
97 bool is = weight_type::can_load(ar);
100 return is && B::can_load(ar);
109 template <
typename A>
112 throw std::logic_error(
"Merging weight_holder accumulators is not yet implemented" 117 void collective_merge(
121 B::collective_merge(comm, root);
122 m_weight->collective_merge(comm, root);
125 void collective_merge(
129 B::collective_merge(comm, root);
130 m_weight->collective_merge(comm, root);
140 std::shared_ptr< ::alps::accumulators::base_wrapper<typename value_type<weight_type>::type> > m_weight;
147 typedef typename detail::make_scalar_result_type<impl::Result,T,weight_holder_tag<W>,B>::type
scalar_result_type;
155 template<
typename A>
Result(A
const & acc)
157 , m_owner(acc.owns_weight())
163 return m_weight.get();
166 template<
typename S>
void print(S & os,
bool terse=
false)
const {
169 m_weight->print(os, terse);
174 ar[
"weight/value"] = *
weight();
179 ar[
"weight/value"] >> *m_weight;
182 static std::size_t
rank() {
return B::rank() + 1; }
187 bool is = weight_type::can_load(ar);
190 return is && B::can_load(ar);
195 std::shared_ptr< ::alps::accumulators::base_wrapper<typename value_type<weight_type>::type> >
m_weight;
static bool can_load(hdf5::archive &ar)
std::enable_if<!std::conditional< std::is_scalar< typename value_type< weight_type >::type >::value, typename std::is_convertible< X, typename value_type< weight_type >::type >::type, typename std::is_same< X, typename value_type< weight_type >::type >::type >::value >::type operator()(T const &, X const &)
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 >())
static std::size_t rank()
void load(hdf5::archive &ar)
void save(hdf5::archive &ar) const
std::vector< std::size_t > get_extent(T const &value)
static bool can_load(hdf5::archive &ar)
base_wrapper< T > const * weight() const
Encapsulation of an MPI communicator and some communicator-related operations.
void print(S &os, bool terse=false) const
Result< T, weight_holder_tag< W >, typename B::result_type > result_type
detail::make_scalar_result_type< impl::Result, T, weight_holder_tag< W >, B >::type scalar_result_type
std::shared_ptr< ::alps::accumulators::base_wrapper< typename value_type< weight_type >::type > > m_weight
void set_context(std::string const &context)
static std::size_t rank()
void reset(accumulator_wrapper &arg)
void operator()(T const &val)
void merge(const A &)
Merge placeholder.
void print(S &os, bool terse=false) const
Accumulator(ArgumentPack const &args, typename std::enable_if<!is_accumulator< ArgumentPack >::value, int >::type=0)
std::ostream & print(std::ostream &s, const dict_value &dv, bool terse)
void load(hdf5::archive &ar)
base_wrapper< typename value_type< weight_type >::type > const * weight() const
traits< Acc >::result_type result(const Acc &acc)
std::enable_if< std::conditional< std::is_scalar< typename value_type< weight_type >::type >::value, typename std::is_convertible< X, typename value_type< weight_type >::type >::type, typename std::is_same< X, typename value_type< weight_type >::type >::type >::value >::type operator()(T const &val, X const &weight)
void save(hdf5::archive &ar) const
Accumulator(Accumulator 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 >())
base_wrapper< typename value_type< T >::type > const * weight(T const &arg)