Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
o2scl::expval_matrix Class Reference

Matrix expectation value. More...

#include <expval.h>

Inheritance diagram for o2scl::expval_matrix:
o2scl::expval_base

Public Types

typedef boost::numeric::ublas::vector< double > ubvector
 
typedef boost::numeric::ublas::matrix< double > ubmatrix
 
typedef boost::numeric::ublas::vector_slice< ubvectorubvector_slice
 
typedef boost::numeric::ublas::slice slice
 

Public Member Functions

 expval_matrix (size_t rows, size_t cols, size_t n_blocks=1, size_t n_per_block=1)
 Create for a vector of size n with n_blocks blocks and n_per_block points block.
 
 expval_matrix (const expval_matrix &ev)
 Copy constructor.
 
expval_matrixoperator= (const expval_matrix &ev)
 Copy constructor.
 
virtual void set_blocks (size_t rows, size_t cols, size_t n_blocks, size_t n_per_block)
 Set for a matrix with n_blocks blocks and n_per_block points block.
 
virtual void free ()
 Free allocated data (but do not change the current values of n_blocks or n_per_block)
 
template<class mat_t >
void add (mat_t &val)
 Add measurement of value val.
 
const tensor3get_data () const
 Return the current data for all blocks.
 
Report statistics
template<class mat_t , class mat2_t , class mat3_t >
void current_avg_stats (mat_t &avg, mat2_t &std_dev, mat3_t &avg_err, size_t &m_block, size_t &m_per_block)
 Report current average, standard deviation, and the error in the average and include block information. More...
 
template<class mat_t , class mat2_t , class mat3_t >
void current_avg (mat_t &avg, mat2_t &std_dev, mat3_t &avg_err)
 Report current average, standard deviation, and the error in the average. More...
 
template<class mat_t , class mat2_t , class mat3_t >
void reblock_avg_stats (size_t new_blocks, mat_t &avg, mat2_t &std_dev, mat3_t &avg_err, size_t &m_per_block) const
 Report average, standard deviation, and the error in the average assuming a new block size.
 
template<class mat_t , class mat2_t , class mat3_t >
void reblock_avg (size_t new_blocks, mat_t &avg, mat2_t &std_dev, mat3_t &avg_err) const
 Report average, standard deviation, and the error in the average assuming a new block size.
 
- Public Member Functions inherited from o2scl::expval_base
 expval_base (size_t n_blocks=1, size_t n_per_block=1)
 Create with n_blocks blocks and n_per_block points per block. More...
 
 expval_base (const expval_base &ev)
 Copy constructor.
 
expval_baseoperator= (const expval_base &ev)
 Copy constructor with operator=()
 
virtual void set_blocks (size_t n_blocks, size_t n_per_block)
 Reset for n_blocks blocks and n_per_block points per block. More...
 
virtual void get_blocks (size_t &n_blocks, size_t &n_per_block) const
 Get the number of blocks and the number of points per block.
 
virtual void get_block_indices (size_t &i_block, size_t &i_curr_block) const
 Get the block index and the index within the current block.
 
virtual bool finished () const
 Returns true if all blocks have been stored. More...
 
virtual double progress () const
 Report progress as a fraction between zero to one (inclusive) More...
 
void is_valid () const
 Internal consistency check.
 

Protected Attributes

tensor3 vals
 The average for each block.
 
ubmatrix current
 The current rolling average.
 
size_t nr
 The number of rows (zero for an empty expval_matrix object)
 
size_t nc
 The number of columns (zero for an empty expval_matrix object)
 
- Protected Attributes inherited from o2scl::expval_base
size_t iblock
 Index denoting the current block number.
 
size_t i
 Index for the number of values in the current block.
 
size_t nblocks
 Total number of blocks (default 1) More...
 
size_t nperblock
 Number of measurements per block (default 1) More...
 

Friends

void o2scl_hdf::hdf_output (o2scl_hdf::hdf_file &hf, expval_matrix &t, std::string name)
 
void o2scl_hdf::hdf_input (o2scl_hdf::hdf_file &hf, expval_matrix &t, std::string name)
 

Additional Inherited Members

- Public Attributes inherited from o2scl::expval_base
std::string name
 The name of the expectation value.
 
std::string short_name
 The shortened name.
 

Detailed Description

See expval_base for some general notes on this and related classes.

This is a similar to expval_scalar, except that it allows updating and statistics for a set of matrices en masse. The data is stored internally in ublas matrix and tensor3 objects, but the public member functions operate with template types which are compatible with any vector class which provides double &operator[]. It is assumed that each call to add() contains a new measurement for all of the matrix entries.

Definition at line 579 of file expval.h.

Member Function Documentation

◆ current_avg()

template<class mat_t , class mat2_t , class mat3_t >
void o2scl::expval_matrix::current_avg ( mat_t &  avg,
mat2_t &  std_dev,
mat3_t &  avg_err 
)
inline
Idea for Future:
This should be made const.

Definition at line 789 of file expval.h.

◆ current_avg_stats()

template<class mat_t , class mat2_t , class mat3_t >
void o2scl::expval_matrix::current_avg_stats ( mat_t &  avg,
mat2_t &  std_dev,
mat3_t &  avg_err,
size_t &  m_block,
size_t &  m_per_block 
)
inline
Idea for Future:

This should be made const.

Avoid the copy associated with vector_slice().

Definition at line 718 of file expval.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).