QMCPACK
ScalarEstimatorBase Struct Referenceabstract

Abstract class for an estimator of a scalar operator. More...

+ Inheritance diagram for ScalarEstimatorBase:
+ Collaboration diagram for ScalarEstimatorBase:

Public Types

using RealType = QMCTraits::FullPrecRealType
 
using accumulator_type = accumulator_set< RealType >
 
using Walker_t = MCWalkerConfiguration::Walker_t
 
using MCPWalker = Walker< QMCTraits, PtclOnLatticeTraits >
 
using WalkerIterator = MCWalkerConfiguration::const_iterator
 
using RecordListType = RecordNamedProperty< RealType >
 

Public Member Functions

 ScalarEstimatorBase ()
 
virtual ~ScalarEstimatorBase ()
 
virtual bool isMainEstimator () const
 Is this estimator a main estimator i.e. the estimator required for a particular driver. More...
 
virtual std::string getName () const =0
 
RealType average (int i=0) const
 return average of the More...
 
RealType variance (int i=0) const
 return a variance More...
 
std::pair< RealType, RealTypeoperator[] (int i) const
 retrun mean and variance More...
 
virtual int size () const
 return the size of scalars it manages More...
 
void clear ()
 clear the scalars to collect More...
 
template<typename IT >
void takeBlockAverage (IT first)
 take block average and write to a common container More...
 
template<typename IT >
void takeBlockAverage (IT first, IT first_sq)
 take block average and write to common containers for values and squared values More...
 
template<typename IT >
void addAccumulated (IT first)
 add the block accumulated scalars More...
 
virtual void accumulate (const MCWalkerConfiguration &W, WalkerIterator first, WalkerIterator last, RealType wgt)=0
 a virtual function to accumulate observables or collectables More...
 
virtual void accumulate (const RefVector< MCPWalker > &)=0
 a virtual function to accumulate observables or collectables More...
 
virtual void add2Record (RecordNamedProperty< RealType > &record)=0
 add the content of the scalar estimator to the record More...
 
virtual void registerObservables (std::vector< ObservableHelper > &h5dec, hdf_archive &file)=0
 add descriptors of observables to utilize hdf5 More...
 
virtual ScalarEstimatorBaseclone ()=0
 clone the object More...
 
virtual const std::string & getSubTypeStr () const =0
 String representation of the derived type of the ScalarEstimator. More...
 

Public Attributes

int FirstIndex
 first index within an record of the first element handled by an object More...
 
int LastIndex
 last index within an record of the first element handled by an object More...
 
std::vector< accumulator_typescalars
 scalars to be measured More...
 
std::vector< accumulator_typescalars_saved
 scalars saved More...
 

Detailed Description

Abstract class for an estimator of a scalar operator.

ScalarEstimators derived from ScalarEstimatorBase implement three main functions

  • accumulate : measure and accumulate its value and the square of the value
  • add2Record :
    Todo:
    document this

Definition at line 40 of file ScalarEstimatorBase.h.

Member Typedef Documentation

◆ accumulator_type

Definition at line 43 of file ScalarEstimatorBase.h.

◆ MCPWalker

Definition at line 45 of file ScalarEstimatorBase.h.

◆ RealType

Definition at line 42 of file ScalarEstimatorBase.h.

◆ RecordListType

Definition at line 47 of file ScalarEstimatorBase.h.

◆ Walker_t

◆ WalkerIterator

Constructor & Destructor Documentation

◆ ScalarEstimatorBase()

ScalarEstimatorBase ( )
inline

Definition at line 59 of file ScalarEstimatorBase.h.

59 : FirstIndex(0), LastIndex(0) {}
int FirstIndex
first index within an record of the first element handled by an object
int LastIndex
last index within an record of the first element handled by an object

◆ ~ScalarEstimatorBase()

virtual ~ScalarEstimatorBase ( )
inlinevirtual

Definition at line 61 of file ScalarEstimatorBase.h.

61 {}

Member Function Documentation

◆ accumulate() [1/2]

virtual void accumulate ( const MCWalkerConfiguration W,
WalkerIterator  first,
WalkerIterator  last,
RealType  wgt 
)
pure virtual

a virtual function to accumulate observables or collectables

Parameters
Wconst MCWalkerConfiguration
firstconst_iterator for the first walker
lastconst_iterator for the last walker
wgtweight

Pass W along with the iterators so that the properties of W can be utilized.

Implemented in LocalEnergyEstimator, RMCLocalEnergyEstimator, CollectablesEstimator, LocalEnergyOnlyEstimator, and FakeEstimator.

◆ accumulate() [2/2]

virtual void accumulate ( const RefVector< MCPWalker > &  )
pure virtual

a virtual function to accumulate observables or collectables

Parameters
global_walkers_walkers per ranks or walkers total?
RefVectorof MCPWalkers
wgtweight or maybe norm

Implemented in LocalEnergyEstimator, CSEnergyEstimator, RMCLocalEnergyEstimator, LocalEnergyOnlyEstimator, CollectablesEstimator, and FakeEstimator.

◆ add2Record()

virtual void add2Record ( RecordNamedProperty< RealType > &  record)
pure virtual

add the content of the scalar estimator to the record

Parameters
recordscalar data list

Each ScalarEstimatorBase object adds 1 to many accumulator_type

Implemented in FakeEstimator.

◆ addAccumulated()

void addAccumulated ( IT  first)
inline

add the block accumulated scalars

Parameters
firststarting iterator of values

Definition at line 125 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::FirstIndex, and ScalarEstimatorBase::scalars.

126  {
127  first += FirstIndex;
128  for (int i = 0; i < scalars.size(); i++)
129  {
130  *first++ += scalars[i].result();
131  scalars[i].clear();
132  }
133  }
int FirstIndex
first index within an record of the first element handled by an object
std::vector< accumulator_type > scalars
scalars to be measured

◆ average()

RealType average ( int  i = 0) const
inline

return average of the

Definition at line 68 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::scalars_saved.

68 { return scalars_saved[i].mean(); }
std::vector< accumulator_type > scalars_saved
scalars saved

◆ clear()

void clear ( )
inline

clear the scalars to collect

Definition at line 78 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::scalars.

Referenced by CollectablesEstimator::add2Record(), LocalEnergyOnlyEstimator::add2Record(), LocalEnergyEstimator::add2Record(), CSEnergyEstimator::add2Record(), and RMCLocalEnergyEstimator::add2Record().

79  {
80  for (int i = 0; i < scalars.size(); i++)
81  scalars[i].clear();
82  }
std::vector< accumulator_type > scalars
scalars to be measured
void clear()
clear the scalars to collect

◆ clone()

◆ getName()

virtual std::string getName ( ) const
pure virtual

◆ getSubTypeStr()

virtual const std::string& getSubTypeStr ( ) const
pure virtual

String representation of the derived type of the ScalarEstimator.

Implemented in RMCLocalEnergyEstimator, LocalEnergyEstimator, CSEnergyEstimator, LocalEnergyOnlyEstimator, CollectablesEstimator, and FakeEstimator.

◆ isMainEstimator()

virtual bool isMainEstimator ( ) const
inlinevirtual

Is this estimator a main estimator i.e. the estimator required for a particular driver.

Reimplemented in RMCLocalEnergyEstimator, LocalEnergyEstimator, and CSEnergyEstimator.

Definition at line 64 of file ScalarEstimatorBase.h.

64 { return false; }

◆ operator[]()

std::pair<RealType, RealType> operator[] ( int  i) const
inline

retrun mean and variance

Definition at line 72 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::scalars.

72 { return scalars[i].mean_and_variance(); }
std::vector< accumulator_type > scalars
scalars to be measured

◆ registerObservables()

virtual void registerObservables ( std::vector< ObservableHelper > &  h5dec,
hdf_archive file 
)
pure virtual

add descriptors of observables to utilize hdf5

Parameters
h5descdescriptor of a data stored in a h5 group
filefile to which each statistical data will be stored

Implemented in RMCLocalEnergyEstimator, CSEnergyEstimator, LocalEnergyEstimator, LocalEnergyOnlyEstimator, CollectablesEstimator, and FakeEstimator.

◆ size()

virtual int size ( void  ) const
inlinevirtual

return the size of scalars it manages

Definition at line 75 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::scalars.

75 { return scalars.size(); }
std::vector< accumulator_type > scalars
scalars to be measured

◆ takeBlockAverage() [1/2]

void takeBlockAverage ( IT  first)
inline

take block average and write to a common container

Definition at line 86 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::FirstIndex, ScalarEstimatorBase::scalars, and ScalarEstimatorBase::scalars_saved.

87  {
88  first += FirstIndex;
89  for (int i = 0; i < scalars.size(); i++)
90  {
91  *first++ = scalars[i].mean();
92  scalars_saved[i] = scalars[i]; //save current block
93  scalars[i].clear();
94  }
95  }
int FirstIndex
first index within an record of the first element handled by an object
std::vector< accumulator_type > scalars
scalars to be measured
std::vector< accumulator_type > scalars_saved
scalars saved

◆ takeBlockAverage() [2/2]

void takeBlockAverage ( IT  first,
IT  first_sq 
)
inline

take block average and write to common containers for values and squared values

Parameters
firststarting iterator of values
first_sqstarting iterator of squared values

Definition at line 102 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::FirstIndex, ScalarEstimatorBase::scalars, and ScalarEstimatorBase::scalars_saved.

103  {
104  first += FirstIndex;
105  first_sq += FirstIndex;
106  for (int i = 0; i < scalars.size(); i++)
107  {
108  *first++ = scalars[i].mean();
109  *first_sq++ = scalars[i].mean2();
110  // For mixed precision this is where data goes from Actual QMCT::RealType
111  // to the local RealType which is hard coded to QMCTFullPrecRealType.
112  // I think it is a bad idea to have RealType to have a changing meaning,
113  // I also feel like having the floating point expension needed to write always to
114  // double in hdf5 is poor form especially since I had to figure this out in many
115  // years later.
116  scalars_saved[i] = scalars[i]; //save current block
117  scalars[i].clear();
118  }
119  }
int FirstIndex
first index within an record of the first element handled by an object
std::vector< accumulator_type > scalars
scalars to be measured
std::vector< accumulator_type > scalars_saved
scalars saved

◆ variance()

RealType variance ( int  i = 0) const
inline

return a variance

Definition at line 70 of file ScalarEstimatorBase.h.

References ScalarEstimatorBase::scalars_saved.

70 { return scalars_saved[i].variance(); }
std::vector< accumulator_type > scalars_saved
scalars saved

Member Data Documentation

◆ FirstIndex

◆ LastIndex

int LastIndex

◆ scalars

◆ scalars_saved


The documentation for this struct was generated from the following file: