ALPS Project: alea library
Header file alea/abstractsimpleobservable.h
This header contains the base class for standard Monte Carlo measurements.
Synopsis
namespace alps {
template <class T> class SimpleObservableEvaluator;
template <class T>
class AbstractSimpleObservable: public Observable
{
public:
typedef T value_type;
typedef typename obs_value_traits<T>::result_type result_type;
typedef std::size_t count_type;
typedef typename obs_value_traits<T>::time_type time_type;
AbstractSimpleObservable(const std::string& name="");
virtual ~AbstractSimpleObservable();
virtual count_type count() const =0;
virtual result_type mean() const =0;
virtual result_type error() const =0;
virtual bool has_variance() const;
virtual result_type variance() const;
virtual bool has_minmax() const;
virtual value_type min() const;
virtual value_type max() const;
virtual bool has_tau() const;
virtual time_type tau() const;
virtual count_type bin_number() const;
virtual count_type bin_size() const;
virtual const value_type& bin_value(count_type n) const;
virtual count_type bin_number2() const;
virtual count_type bin_size2() const;
template <class S>
SimpleObservableEvaluator::value_type>
slice(S s, const std::string& newname="") const;
operator SimpleObservableEvaluator<value_type> () const;
};
}
The AbstractSimpleObservable abstract base class
is an abstract base class for standard observables, both for evaluation
objects and for observables to perform measurements with. It is templated
on the data type of the observables. In addition to the members of the base
class Observable it provides the following members:
typedef T value_type;
is the data type of the observable.
typedef typename obs_value_traits<T>::result_type result_type;
is a type appropriate to store averages and errors of values of type value_type.
typedef std::size_t count_type;
is an integral type large enough to store the number of measurements for
the observable.
typedef typename obs_value_traits<T>::time_type time_type;
is a type appropriate to store autocorrelation times.
AbstractSimpleObservable(const std::string& name="");
The constructor takes the name as argument.
virtual count_type count() const =0;
returns the number of measurements
virtual result_type mean() const =0;
returns the mean value of the measurements.
virtual result_type error() const =0;
returns the best error estimate.
virtual bool has_variance() const;
returns true if the variance is available.
virtual result_type variance() const;
returns the variance, if has_variance() evaluates to true.
Otherwise a NoMeasurementsError is thrown.
virtual bool has_minmax() const ;
returns true if the minimum and maximum values are available.
virtual value_type min() const;
virtual value_type max() const;
return the minimum and maximum value, if has_minmax() evaluates
to true. Otherwise a std::logic_error is thrown.
virtual bool has_tau() const;
returns true if the autocorrelation time is available.
virtual time_type tau() const;
returns the autocorrelation time, if has_tau() evaluates to true.
Otherwise a std::logic_error is thrown.
virtual uint32_t bin_number() const;
returns the number of available bins, if binning is implemented for the
observable, or zero otherwise. A bin consists of the average of bin_size
measurements.
virtual uint32_t bin_size();
returns the number of measurements in a bin.
virtual const value_type& bin_value(uint32_t n) const =0;
returns the mean value of the measurements in a bin. n needs to
be lass than bin_number() or undefined behavior can result.
virtual const value_type& bin_value2(uint32_t n) const =0;
returns the mean value of the squared measurements in a bin. n
needs to be lass than bin_number() or undefined behavior can result.
virtual uint32_t bin_number2() const =0;
returns the number of available bins containing squares of the measurements,
if binning is implemented for the observable, or zero otherwise.
template <class S>
SimpleObservableEvaluator::value_type> slice(S s, const std::string& newname="") const;
returns an observable containing a slice (e.g. in case of an array-valued
observable just one entry) of the observable.
template <class S>
SimpleObservableEvaluator::value_type> operator[](S s) const;
returns an observable containing a slice (e.g. in case of an array-valued
observable just one entry) of the observable, by calling slice(s).
operator SimpleObservableEvaluator<value_type> () const;
creates a SimpleObservableEvaluator object, allowing calculations
to be performed on the observable.
copyright (c) 1994-2004 by Matthias Troyer