namespace alps {
template <class OBS, class SIGN=double>
class AbstractSignedObservable
: public AbstractSimpleObservable<typename OBS::value_type>
{
public:
typedef OBS observable_type;
typedef SIGN sign_type;
typedef typename observable_type::value_type value_type;
typedef typename obs_value_traits<obs_value_type>::result_type result_type;
typedef std::size_t count_type;
typedef typename obs_value_traits<value_type>::time_type time_type;
template <class X, class Y> friend class AbstractSignedObservable;
static const int version=observable_type::version+(1<<24);
AbstractSignedObservable(const observable_type& obs, const std::string& s="Sign");
AbstractSignedObservable(const std::string& name="", const std::string& s="Sign");
template <class OBS2>
AbstractSignedObservable(const AbstractSignedObservable<OBS2,SIGN>& obs);
template <class ARG>
AbstractSignedObservable(const std::string& name,std::string& s, const ARG& arg);
template <class ARG>
AbstractSignedObservable(const std::string& name,const ARG& arg);
~AbstractSignedObservable();
uint32_t version_id() const;
void rename(const std::string& newname);
void reset(bool forequilibration);
void output(std::ostream& out) const;
void write_xml(oxstream& oxs, const boost::filesystem::path& p) const;
count_type count() const;
result_type mean() const;
result_type error() const;
bool can_set_thermalization() const;
void set_thermalization(uint32_t todiscard);
uint32_t get_thermalization() const;
template <class S>
AbstractSignedObservable<SimpleObservableEvaluator<typename obs_value_slice<value_type,S>::value_type>,SIGN>
slice(S s, const std::string& newname="") const;
template <class S>
AbstractSignedObservable<SimpleObservableEvaluator<typename obs_value_slice<value_type,S>::value_type>,SIGN>
operator[](S s) const;
void save(ODump& dump) const;
void load(IDump& dump);
Observable* clone() const;
bool is_signed() const;
void set_sign_name(const std::string& signname);
void set_sign(const Observable& sign);
void clear_sign();
const Observable& sign() const;
const std::string sign_name() const;
const Observable& signed_observable() const;
uint32_t number_of_runs() const;
Observable* get_run(uint32_t) const;
};
template <class OBS, class SIGN=double>
class SignedObservable
: public AbstractSignedObservable<OBS,SIGN>,
public RecordableObservable<typename OBS::value_type,SIGN>
{
public:
typedef SIGN sign_type;
typedef typename observable_type::value_type value_type;
SignedObservable(const observable_type& obs, const std::string& s="Sign") : base_type(obs,s);
SignedObservable(const std::string& name="", const std::string& s="Sign");
template <class ARG>
SignedObservable(const std::string& name,const ARG& arg);
template <class ARG>
SignedObservable(const std::string& name,std::string& s, const ARG& arg)
: base_type(name,s,arg) {}
~SignedObservable() {}
Observable* clone() const;
void operator<<(const value_type& x);
void add(const value_type& x);
void add(const value_type& x, sign_type s);
bool is_thermalized() const;
};
template <class OBS>
boost::shared_ptr<Observable> make_observable(const OBS& obs, bool issigned=false);
template <class OBS, class SIGN>
boost::shared_ptr<Observable> make_observable(const OBS& obs, const std::string& s, SIGN, bool issigned=true);}
is the type of observable (derived from AbstractSimpleObservabletypedef OBS observable_type;
is the type used to represent the sign of the signed measurement.typedef SIGN sign_type;
is the version id of the observable, adding 2^24 to represent a signed observable.static const int version=observable_type::version+(1<<24);
copies the observable obs. The name of the observable containing the sign, can be passed as the second argument, defaulting to "Sign".AbstractSignedObservable(const observable_type& obs, const std::string& s="Sign");
creates the observable with the given name. The name of the observable containing the sign, can be passed as the second argument, defaulting to "Sign".AbstractSignedObservable(const std::string& name="", const std::string& s="Sign");
is a generalized copy constructor.template <class OBS2>
AbstractSignedObservable(const AbstractSignedObservable<OBS2,SIGN>& obs);
constructs the observable, passing both the name and the additional argument arg to the constructor of the underlying simple observable. The name of the observable containing the sign, can be passed as the argument s, defaulting to "Sign" if not specified.template <class ARG>
AbstractSignedObservable(const std::string& name,std::string& s, const ARG& arg);
template <class ARG>
AbstractSignedObservable(const std::string& name,const ARG& arg);
The arguments to the constructors are just passed on to the base class AbstractSignedObservable.SignedObservable(const observable_type& obs, const std::string& s="Sign") : base_type(obs,s);
SignedObservable(const std::string& name="", const std::string& s="Sign");
template <class ARG>
SignedObservable(const std::string& name,const ARG& arg);
template <class ARG>
SignedObservable(const std::string& name,std::string& s, const ARG& arg);
both record a measurement. It is assumed that the value x is the product of the measurement value and the sign. Additionally, the sign needs to be recorded separately into the observable whose name matches sign_name().void operator<<(const value_type& x);
void add(const value_type& x);;
calls add(x*s).void add(const value_type& x, sign_type s);;
template <class OBS>
boost::shared_ptr<Observable> make_observable(const OBS& obs, bool issigned=false);
takes an observable and converts it in to a signed observable if the issigned argument is true. The name of the signed observable is asssumed to be "Sign" and the type of sign double.
template <class OBS, class SIGN>
boost::shared_ptr<Observable> make_observable(const OBS& obs, const std::string& s, SIGN, bool issigned=true);
takes an observable and converts it in to a signed observable if the issigned argument is true. Both the name and type of the signed observable can be specified.
copyright (c) 1994-2010 by Matthias Troyer
Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)