QMCPACK
BlockHistogram< T > Struct Template Reference
+ Collaboration diagram for BlockHistogram< T >:

Public Types

using value_type = T
 
using reference = T &
 
using size_type = typename std::deque< T >::size_type
 
using iterator = typename std::deque< T >::iterator
 
using const_iterator = typename std::deque< T >::const_iterator
 

Public Member Functions

 BlockHistogram (size_type n=100)
 default constructor More...
 
void resize (size_type n, const T &x)
 resize the histogram More...
 
void reserve (size_type n)
 
void clear ()
 
value_type mean () const
 
value_type result () const
 
size_type size () const
 
void operator() (const T &x)
 add a value x More...
 

Public Attributes

int maxSize
 
mySum
 
myWeightInv
 
std::deque< T > myData
 

Detailed Description

template<class T>
struct BlockHistogram< T >

Definition at line 24 of file BlockHistogram.h.

Member Typedef Documentation

◆ const_iterator

using const_iterator = typename std::deque<T>::const_iterator

Definition at line 36 of file BlockHistogram.h.

◆ iterator

using iterator = typename std::deque<T>::iterator

Definition at line 35 of file BlockHistogram.h.

◆ reference

using reference = T&

Definition at line 33 of file BlockHistogram.h.

◆ size_type

using size_type = typename std::deque<T>::size_type

Definition at line 34 of file BlockHistogram.h.

◆ value_type

using value_type = T

Definition at line 32 of file BlockHistogram.h.

Constructor & Destructor Documentation

◆ BlockHistogram()

BlockHistogram ( size_type  n = 100)
inlineexplicit

default constructor

Parameters
nsize of the samples defult=100

Definition at line 41 of file BlockHistogram.h.

Member Function Documentation

◆ clear()

void clear ( )
inline

Definition at line 58 of file BlockHistogram.h.

References BlockHistogram< T >::mySum, and BlockHistogram< T >::myWeightInv.

Referenced by BlockHistogram< T >::reserve().

59  {
60  myData.clear();
61  mySum = T();
62  myWeightInv = 1;
63  }
std::deque< T > myData

◆ mean()

value_type mean ( ) const
inline

◆ operator()()

void operator() ( const T &  x)
inline

add a value x

Definition at line 73 of file BlockHistogram.h.

References BlockHistogram< T >::maxSize, BlockHistogram< T >::myData, BlockHistogram< T >::mySum, and BlockHistogram< T >::myWeightInv.

74  {
75  //add to the end
76  myData.push_back(x);
77  if (myData.size() < maxSize)
78  mySum += x;
79  else
80  {
81  mySum += x - myData.front();
82  myData.pop_front();
83  }
84  myWeightInv = 1 / static_cast<T>(myData.size());
85  }
std::deque< T > myData

◆ reserve()

void reserve ( size_type  n)
inline

Definition at line 52 of file BlockHistogram.h.

References BlockHistogram< T >::clear(), BlockHistogram< T >::maxSize, and qmcplusplus::n.

53  {
54  maxSize = n;
55  this->clear();
56  }

◆ resize()

void resize ( size_type  n,
const T &  x 
)
inline

resize the histogram

Definition at line 45 of file BlockHistogram.h.

References BlockHistogram< T >::myData, BlockHistogram< T >::mySum, BlockHistogram< T >::myWeightInv, and qmcplusplus::n.

46  {
47  myData.resize(n, x);
48  mySum = n * x;
49  myWeightInv = 1 / static_cast<T>(n);
50  }
std::deque< T > myData

◆ result()

value_type result ( ) const
inline

Definition at line 67 of file BlockHistogram.h.

References BlockHistogram< T >::mySum.

67 { return mySum; }

◆ size()

size_type size ( void  ) const
inline

Definition at line 69 of file BlockHistogram.h.

References BlockHistogram< T >::myData.

69 { return myData.size(); }
std::deque< T > myData

Member Data Documentation

◆ maxSize

int maxSize

◆ myData

std::deque<T> myData

◆ mySum

◆ myWeightInv


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