StatMech
Loading...
Searching...
No Matches
MicroCanonicalAverage Class Reference

Calculate the microcanonical averages with respect to a given sorted vector 'eigVal'. More...

#include <MicroCanonicalAverage.hpp>

Collaboration diagram for MicroCanonicalAverage:
Collaboration graph

Public Member Functions

template<typename InVector_t >
__host__ __device__ MicroCanonicalAverage (InVector_t const &eigVal, double const shellWidth)
 
__host__ void status (void) const
 Show the current status of the instance.
 
__host__ __device__ int dim () const
 
__host__ __device__ double shellWidth () const
 
__host__ __device__ int dimShell (int index) const
 
__host__ __device__ Vector_t< int > & dimShell ()
 
__host__ __device__ Vector_t< int > const & dimShell () const
 
__host__ __device__ Vector_t< double > & eigVal ()
 
__host__ __device__ Vector_t< double > const & eigVal () const
 
template<class VectorType >
__host__ __device__ void operator() (VectorType &res, VectorType const &expVal) const
 

Private Types

template<class T >
using Vector_t = Eigen::VectorX< T >
 

Private Attributes

int m_dim
 
double m_shellWidth
 
Vector_t< double > m_eigVal
 
Vector_t< int > m_idMin
 
Vector_t< int > m_idMax
 
Vector_t< int > m_dimShell
 

Detailed Description

Calculate the microcanonical averages with respect to a given sorted vector 'eigVal'.

Template Parameters
int
Container

Member Typedef Documentation

◆ Vector_t

template<class T >
using MicroCanonicalAverage::Vector_t = Eigen::VectorX<T>
private

Constructor & Destructor Documentation

◆ MicroCanonicalAverage()

template<typename InVector_t >
__host__ __device__ MicroCanonicalAverage::MicroCanonicalAverage ( InVector_t const &  eigVal,
double const  shellWidth 
)
inline
40 m_idMin.resize(m_dim);
41 m_idMax.resize(m_dim);
42 m_dimShell.resize(m_dim);
43
44 // clang-format off
45 #pragma omp parallel for
46 // clang-format on
47 for(auto j = 0; j < m_dim; ++j) {
48 int idMin, idMax;
49 for(idMin = j; idMin >= 0 && eigVal[j] - eigVal[idMin] <= shellWidth; --idMin) {};
50 m_idMin[j] = (++idMin);
51 for(idMax = j; idMax < m_dim && eigVal[idMax] - eigVal[j] <= shellWidth; ++idMax) {};
52 m_idMax[j] = (--idMax);
53 m_dimShell[j] = idMax - idMin + 1;
54 }
55 }
Vector_t< int > m_dimShell
Definition MicroCanonicalAverage.hpp:34
int m_dim
Definition MicroCanonicalAverage.hpp:30
__host__ __device__ Vector_t< double > & eigVal()
Definition MicroCanonicalAverage.hpp:77
Vector_t< int > m_idMax
Definition MicroCanonicalAverage.hpp:33
double m_shellWidth
Definition MicroCanonicalAverage.hpp:31
Vector_t< double > m_eigVal
Definition MicroCanonicalAverage.hpp:32
Vector_t< int > m_idMin
Definition MicroCanonicalAverage.hpp:33
__host__ __device__ double shellWidth() const
Definition MicroCanonicalAverage.hpp:71

Member Function Documentation

◆ dim()

__host__ __device__ int MicroCanonicalAverage::dim ( ) const
inline
70{ return m_dim; }

◆ dimShell() [1/3]

__host__ __device__ Vector_t< int > & MicroCanonicalAverage::dimShell ( )
inline
74{ return m_dimShell; }

◆ dimShell() [2/3]

__host__ __device__ Vector_t< int > const & MicroCanonicalAverage::dimShell ( ) const
inline
75{ return m_dimShell; }

◆ dimShell() [3/3]

__host__ __device__ int MicroCanonicalAverage::dimShell ( int  index) const
inline
73{ return m_dimShell[index]; }

◆ eigVal() [1/2]

__host__ __device__ Vector_t< double > & MicroCanonicalAverage::eigVal ( )
inline
77{ return m_eigVal; }

◆ eigVal() [2/2]

__host__ __device__ Vector_t< double > const & MicroCanonicalAverage::eigVal ( ) const
inline
78{ return m_eigVal; }

◆ operator()()

template<class VectorType >
__host__ __device__ void MicroCanonicalAverage::operator() ( VectorType &  res,
VectorType const &  expVal 
) const
inline
81 {
82 res.resize(m_dim);
83 // clang-format off
84 #pragma omp parallel for
85 // clang-format on
86 for(int j = 0; j < m_dim; ++j) {
87 res[j] = 0;
88 for(auto id = m_idMin[j]; id <= m_idMax[j]; ++id) res[j] += expVal[id];
89 res[j] /= double(m_dimShell[j]);
90 }
91 }

◆ shellWidth()

__host__ __device__ double MicroCanonicalAverage::shellWidth ( ) const
inline
71{ return m_shellWidth; }

◆ status()

__host__ void MicroCanonicalAverage::status ( void  ) const
inline

Show the current status of the instance.

  • Mean: Mean of each elements
  • Stddev: Standard deviation of diagonal elements
  • Count: Number of random numbers generated by the instance so far
63 {
64 std::cout << "MicroCanonicalAverage.status()"
65 << "\n"
66 << "\tDim: " << this->dim() << "\n"
67 << "\tShellWidth: " << this->shellWidth() << std::endl;
68 }
__host__ __device__ int dim() const
Definition MicroCanonicalAverage.hpp:70

Member Data Documentation

◆ m_dim

int MicroCanonicalAverage::m_dim
private

◆ m_dimShell

Vector_t<int> MicroCanonicalAverage::m_dimShell
private

◆ m_eigVal

Vector_t<double> MicroCanonicalAverage::m_eigVal
private

◆ m_idMax

Vector_t<int> MicroCanonicalAverage::m_idMax
private

◆ m_idMin

Vector_t<int> MicroCanonicalAverage::m_idMin
private

◆ m_shellWidth

double MicroCanonicalAverage::m_shellWidth
private

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