namespace alps {
class NoMeasurementsError : public std::runtime_error {
public:
NoMeasurementsError();
};
class Observable
{
public:
typedef uint32_t version_type;
Observable();
Observable(const std::string& n);
Observable(const Observable& o);
virtual ~Observable();
virtual Observable* clone() const = 0;
const std::string& name() const;
void rename (const std::string& newname);
virtual void reset(bool equilibrated=false) = 0;
virtual void output(std::ostream&) const = 0;
virtual void write_xml(std::ostream&, const boost::filesystem::path& fn_hdf5=boost::filesystem::path()) const;
virtual void write_xml(oxstream& oxs, const boost::filesystem::path& fn_hdf5=boost::filesystem::path()) const;
virtual uint32_t version_id() const =0;
virtual void save(ODump& dump) const;
virtual void load(IDump& dump);
virtual bool can_set_thermalization() const;
virtual void set_thermalization(uint32_t todiscard);
virtual uint32_t get_thermalization() const=0;
virtual bool is_signed() const;
virtual void set_sign_name(const std::string& signname);
virtual void set_sign(const Observable& sign);
virtual void clear_sign();
virtual const Observable& sign() const;
virtual const Observable& signed_observable() const;
virtual const std::string& sign_name() const;
virtual uint32_t number_of_runs() const;
virtual Observable* get_run(uint32_t) const;
virtual void compact();
template <class T> void operator<<(const T& x);
};
std::ostream& operator<<(std::ostream& out, const Observable& o);
ODump& operator<<(ODump& od, const Observable& m);
IDump& operator>>(IDump& id, Observable& m);
}
is an integer storing a unique integer identifier of the derived leaf class.typedef uint32_t version_type;
the default constructor. Note that the observable needs to be given a name before it can be used in an ObservableSet.Observable();
creates an observable with a given name. Every observable has a name.Observable(const std::string& n);
is the copy constructor. A special copy constructor is needed, because information about which ObservableSet an observable belongs to is invalidated when copying.Observable(const Observable& o);
copies the observable and returns a pointer to the copy.virtual Observable* clone() const = 0;
returns the name of the observable.const std::string& name() const;
renames the observable. This is only possible for an Observable not in an ObservableSet, otherwise a std::runtime_error is thrown.void rename(const std::string& newname);
resets the observable and restarts the collection of measurements. If the argument is false, the observable collects information during an equilibration phase, while it collects real measurements of the argument is true.virtual void reset(bool equilibrated=false) = 0;
Important note: This function has to be called with a true argument before any real measurements are recorded.
writes the results of the collected measurements to a std::ostream.virtual void output(std::ostream&) const = 0;
writes the results of the measurement in XML, using the schema presented at http://xml.comp-phys.org to an X. If time series information is present and a second nonempty argument the time series information is written into a file specified by that name.virtual void write_xml(oxstream& oxs, const boost::filesystem::path& fn_hdf5=boost::filesystem::path()) const;
returns a unique integer identifier for the leaf class, used in serialization and deserialization of inhomogeneous collections of observables.virtual uint32_t version_id() const =0;
are virtual functions used to implement serialization and deserialization.virtual void save(ODump& dump) const;
virtual void load(IDump& dump);
returns true if the thermalization (equilibration) time can be changed after the measurements have been performed.virtual bool can_set_thermalization() const;
sets the thermalization (equilibration) time to discard the given number of measurements. Throws std::logic_error if the thermalization (equilibration) time cannot be changed for the observable.virtual void set_thermalization(uint32_t todiscard);
returns the thermalization (equilibration) time.virtual uint32_t get_thermalization() const=0;
returns true if the observable has a sign or phase problem.virtual bool is_signed() const;
sets the name of the observable containing the sign or phase. Throws a std::logic_error for observables without a sign or phase problem.virtual void set_sign_name(const std::string& signname);
sets the observable containing the sign or phase. A pointer is stored with the observable. Throws a std::logic_error for observables without a sign or phase problem.virtual void set_sign(const Observable& sign);
removes any previously set sign or phase observable. Throws a std::logic_error for observables without a sign or phase problem.virtual void clear_sign();
returns a reference to the sign or phase observable. Throws a std::runtime_error if no sign or phase observable has been set. Throws a std::logic_error for observables without a sign or phase problem.virtual const Observable& sign() const;
returns a reference to the observable which records the signed measurements (i.e. recording the product of sign an observable, before division by the average sign). Throws a std::logic_error for observables without a sign or phase problem.virtual const Observable& signed_observable() const;
returns the name of the sign or phase observables. Throws a std::logic_error for observables without a sign or phase problem.virtual const std::string& sign_name() const;
returns the number of runs (time series) which have contributed to this observable.virtual uint32_t number_of_runs() const;
creates an observable containing data from only one specified run (time series).virtual Observable* get_run(uint32_t) const;
compacts the observable, reducing the memory allocation, while still enabling access to the most important results. Usually the ability to modify the observable (e.g. change thermalization, get crosscorrelations, ...) gets lost though.virtual void compact();
is a helper function, dispatiching to the derived class:template <class T> void operator<<(const T& x);
calls the output function of an Observable to write it to a std::ostream.std::ostream& operator<<(std::ostream& out, const alps::Observable& o);
serializes and deserializes an Obseravble object. They call the save and load functions of the obseravble.ODump& operator<<(ODump& od, const Observable& m);
IDump& operator>>(IDump& id, Observable& m);
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)