TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::mc_tools::measure< MCSignType >

#include <triqs/mc_tools/mc_measure.hpp>

Detailed Description

template<DoubleOrComplex MCSignType>
class triqs::mc_tools::measure< MCSignType >

Type erasure class for MC measures.

It takes any type that models the triqs::mc_tools::MCMeasure concept and erases its type.

Optionally, the following method can be defined:

  • report() const -> std::string: Reports information about the measure in a std::string object.

Optionally, the following free functions can be defined:

  • h5_write(h5::group, std::string const &, T const &) const: Writes the measure object of type T to HDF5.
  • h5_read(h5::group, std::string const &, T &): Reads the measure object of type T from HDF5.
Template Parameters
MCSignTypeType of the sign/weight of a MC configuration (triqs::mc_tools::DoubleOrComplex).

Definition at line 62 of file mc_measure.hpp.

Public Member Functions

 measure (measure &&)=default
 Default move constructor leaves the moved from object in an empty state.
 measure (measure const &)=delete
 Deleted copy constructor.
template<typename T>
requires (MCMeasure<T, MCSignType> && !std::is_same_v<T, measure>)
 measure (T m, bool enable_timer, bool enable_report)
 Constructor takes an object that models the triqs::mc_tools::MCMeasure concept and erases its type.
void accumulate (MCSignType sign)
 Perform the measurement on the current MC configuration.
void collect_results (mpi::communicator const &c)
 Collect results from multiple MPI processes.
auto count () const
 Get the number of measurements performed.
double duration () const
 Get the duration of the cumulative accumulate() and collect_results() calls.
std::string get_timings (std::string const &name, std::string const &prefix="") const
 Get a formatted string showing the runtime of the accumulate() and collect_results() calls.
auto is_set () const
 Is the measure object a measure set?
std::vector< std::string > names () const
 Get a vector of all the measure names in a measure set.
measureoperator= (measure &&)=default
 Default move assignment operator leaves the moved from object in an empty state.
measureoperator= (measure const &)=delete
 Deleted copy assignment operator.
std::string report () const
 Report information about the measure.

Friends

void h5_read (h5::group g, std::string const &name, measure &m)
 Read the measure object from HDF5.
void h5_write (h5::group g, std::string const &name, measure const &m)
 Write the measure object to HDF5.

Constructor & Destructor Documentation

◆ measure()

template<DoubleOrComplex MCSignType>
template<typename T>
requires (MCMeasure<T, MCSignType> && !std::is_same_v<T, measure>)
triqs::mc_tools::measure< MCSignType >::measure ( T m,
bool enable_timer,
bool enable_report )
inline

Constructor takes an object that models the triqs::mc_tools::MCMeasure concept and erases its type.

Template Parameters
TOriginal type of the MC measure object.
Parameters
mMC measure object to have its type erased.
enable_timerEnable timer for measuring the duration of the accumulate() and collect_results() calls.
enable_reportEnable the report() callback method.

Definition at line 123 of file mc_measure.hpp.

Member Function Documentation

◆ accumulate()

template<DoubleOrComplex MCSignType>
void triqs::mc_tools::measure< MCSignType >::accumulate ( MCSignType sign)
inline

Perform the measurement on the current MC configuration.

It calls the accumulate method of the original measure object.

Parameters
signSign of the current MC configuration.

Definition at line 146 of file mc_measure.hpp.

◆ collect_results()

template<DoubleOrComplex MCSignType>
void triqs::mc_tools::measure< MCSignType >::collect_results ( mpi::communicator const & c)

Collect results from multiple MPI processes.

It calls the collect_results method of the original measure object.

Parameters
cMPI communicator.

Definition at line 36 of file mc_measure.cpp.

◆ get_timings()

template<DoubleOrComplex MCSignType>
std::string triqs::mc_tools::measure< MCSignType >::get_timings ( std::string const & name,
std::string const & prefix = "" ) const
nodiscard

Get a formatted string showing the runtime of the accumulate() and collect_results() calls.

Parameters
nameName of the measure.
prefixPrefix string to be added to the beginning of each line.
Returns
String containing the durations of those calls (if the timer is disabled, the results might make no sense).

Definition at line 47 of file mc_measure.cpp.

◆ names()

template<DoubleOrComplex MCSignType>
std::vector< std::string > triqs::mc_tools::measure< MCSignType >::names ( ) const
nodiscard

Get a vector of all the measure names in a measure set.

Returns
std::vector<std::string> containing the names of all registered measures if the measure is a measure set. Otherwise, an empty vector.

Definition at line 56 of file mc_measure.cpp.

◆ report()

template<DoubleOrComplex MCSignType>
std::string triqs::mc_tools::measure< MCSignType >::report ( ) const
nodiscard

Report information about the measure.

It calls the report method of the original measure object (if reports are enabled in the ctor).

Returns
If the original measure object has a report method, it returns the resulting report string, otherwise an empty string.

Definition at line 42 of file mc_measure.cpp.

◆ h5_read

template<DoubleOrComplex MCSignType>
void h5_read ( h5::group g,
std::string const & name,
measure< MCSignType > & m )
friend

Read the measure object from HDF5.

Does nothing if there is no specialized h5_read function for the original measure object.

Parameters
gh5::group to be read from.
nameName of the dataset/subgroup.
mMeasure object to be read into.

Definition at line 214 of file mc_measure.hpp.

◆ h5_write

template<DoubleOrComplex MCSignType>
void h5_write ( h5::group g,
std::string const & name,
measure< MCSignType > const & m )
friend

Write the measure object to HDF5.

Does nothing if there is no specialized h5_write function for the original measure object.

Parameters
gh5::group to be written to.
nameName of the dataset/subgroup.
mMeasure object to be written.

Definition at line 203 of file mc_measure.hpp.


The documentation for this class was generated from the following files: