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

Public Member Functions

 TraceSample (const std::string &sdomain, const std::string &sname, int sindex, int sdim, Vector< T > &ssample)
 
 TraceSample (const std::string &sdomain, const std::string &sname, int sindex, int sdim, TinyVector< int, DMAX > sshape, Vector< T > &ssample)
 
virtual ~TraceSample ()=default
 
void initialize (const std::string &sdomain, const std::string &sname, int sindex, int sdim)
 
void set_unit_size (int usize)
 
void set_data_size ()
 
void check_shape ()
 
bool same_shape (TraceSample< T > *other)
 
virtual bool is_combined ()
 
void set_buffer_range (int &bstart)
 
sum ()
 
void write_summary (int ind=-1, std::string pad=" ")
 

Public Attributes

std::string domain
 
std::string name
 
int index
 
bool array_trace
 
int dimension
 
int size
 
int unit_size
 
int data_size
 
TinyVector< int, DMAXshape
 
Vector< T > & sample
 
bool write
 
int buffer_start
 
int buffer_end
 
std::map< std::string, TraceIntmeta_int
 
std::map< std::string, TraceRealmeta_real
 
std::map< std::string, std::string > meta_string
 
bool verbose
 

Detailed Description

template<typename T>
struct qmcplusplus::TraceSample< T >

Definition at line 515 of file TraceManager.h.

Constructor & Destructor Documentation

◆ TraceSample() [1/2]

TraceSample ( const std::string &  sdomain,
const std::string &  sname,
int  sindex,
int  sdim,
Vector< T > &  ssample 
)
inline

Definition at line 534 of file TraceManager.h.

535  : sample(ssample), verbose(false)
536  {
537  initialize(sdomain, sname, sindex, sdim);
538  }
void initialize(const std::string &sdomain, const std::string &sname, int sindex, int sdim)
Definition: TraceManager.h:557

◆ TraceSample() [2/2]

TraceSample ( const std::string &  sdomain,
const std::string &  sname,
int  sindex,
int  sdim,
TinyVector< int, DMAX sshape,
Vector< T > &  ssample 
)
inline

Definition at line 541 of file TraceManager.h.

547  : sample(ssample), verbose(false)
548  {
549  initialize(sdomain, sname, sindex, sdim);
550  shape = sshape;
551  size = sample.size();
552  check_shape();
553  }
TinyVector< int, DMAX > shape
Definition: TraceManager.h:525
void initialize(const std::string &sdomain, const std::string &sname, int sindex, int sdim)
Definition: TraceManager.h:557
size_type size() const
return the current size
Definition: OhmmsVector.h:162

◆ ~TraceSample()

virtual ~TraceSample ( )
inlinevirtualdefault

Member Function Documentation

◆ check_shape()

void check_shape ( )
inline

Definition at line 575 of file TraceManager.h.

Referenced by TraceSample< TraceReal >::TraceSample().

576  {
577  bool correct_shape = true;
578  bool correct_dimension = dimension <= DMAX;
579  if (correct_dimension)
580  {
581  int tsize = 1;
582  for (int d = 0; d < dimension; ++d)
583  {
584  tsize *= shape[d];
585  correct_dimension = correct_dimension && shape[d] > 0;
586  }
587  correct_shape = tsize == size;
588  }
589  if (!correct_dimension)
590  APP_ABORT("TraceSample::check_shape dimension of sample array is incorrect");
591  if (!correct_shape)
592  APP_ABORT("TraceSample::check_shape shape and size of sample array do not match");
593  }
TinyVector< int, DMAX > shape
Definition: TraceManager.h:525
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
const unsigned int DMAX
Definition: TraceManager.h:47

◆ initialize()

void initialize ( const std::string &  sdomain,
const std::string &  sname,
int  sindex,
int  sdim 
)
inline

Definition at line 557 of file TraceManager.h.

Referenced by TraceSample< TraceReal >::TraceSample().

558  {
559  domain = sdomain, name = sname;
560  dimension = sdim;
561  index = sindex;
562  array_trace = false;
563  write = false;
564  buffer_start = -1;
565  buffer_end = -1;
566  }

◆ is_combined()

virtual bool is_combined ( )
inlinevirtual

Reimplemented in CombinedTraceSample< T >, and CombinedTraceSample< TraceReal >.

Definition at line 605 of file TraceManager.h.

605 { return false; }

◆ same_shape()

bool same_shape ( TraceSample< T > *  other)
inline

Definition at line 596 of file TraceManager.h.

Referenced by CombinedTraceSample< TraceReal >::add_component().

597  {
598  bool same = dimension == other->dimension && size == other->size;
599  if (same)
600  for (int d = 0; d < dimension; ++d)
601  same = same && shape[d] == other->shape[d];
602  return same;
603  }
TinyVector< int, DMAX > shape
Definition: TraceManager.h:525

◆ set_buffer_range()

void set_buffer_range ( int &  bstart)
inline

Definition at line 607 of file TraceManager.h.

Referenced by TraceSamples< std::complex< TraceReal > >::set_buffer_ranges().

608  {
609  set_data_size();
610  if (write)
611  {
612  buffer_start = bstart;
613  buffer_end = bstart + data_size;
614  bstart = buffer_end;
615  }
616  }

◆ set_data_size()

void set_data_size ( )
inline

◆ set_unit_size()

void set_unit_size ( int  usize)
inline

Definition at line 569 of file TraceManager.h.

569 { unit_size = usize; }

◆ sum()

T sum ( )
inline

Definition at line 619 of file TraceManager.h.

620  {
621  T s(0);
622  for (int i = 0; i < sample.size(); ++i)
623  s += sample[i];
624  return s;
625  }
size_type size() const
return the current size
Definition: OhmmsVector.h:162

◆ write_summary()

void write_summary ( int  ind = -1,
std::string  pad = "  " 
)
inline

Definition at line 627 of file TraceManager.h.

628  {
629  std::string pad2 = pad + " ";
630  if (ind == -1)
631  app_log() << pad << " TraceSample " << name << std::endl;
632  else
633  app_log() << pad << ind << " TraceSample " << name << std::endl;
634  app_log() << pad2 << "domain = " << domain << std::endl;
635  app_log() << pad2 << "name = " << name << std::endl;
636  app_log() << pad2 << "index = " << index << std::endl;
637  app_log() << pad2 << "array_trace = " << array_trace << std::endl;
638  app_log() << pad2 << "dimension = " << dimension << std::endl;
639  app_log() << pad2 << "size = " << size << std::endl;
640  app_log() << pad2 << "unit_size = " << unit_size << std::endl;
641  app_log() << pad2 << "data_size = " << data_size << std::endl;
642  app_log() << pad2 << "shape = " << shape << std::endl;
643  app_log() << pad2 << "write = " << write << std::endl;
644  app_log() << pad2 << "buffer range = [" << buffer_start << "," << buffer_end << ")" << std::endl;
645  }
TinyVector< int, DMAX > shape
Definition: TraceManager.h:525
std::ostream & app_log()
Definition: OutputManager.h:65

Member Data Documentation

◆ array_trace

◆ buffer_end

◆ buffer_start

◆ data_size

◆ dimension

◆ domain

◆ index

◆ meta_int

std::map<std::string, TraceInt> meta_int

Definition at line 529 of file TraceManager.h.

◆ meta_real

std::map<std::string, TraceReal> meta_real

Definition at line 530 of file TraceManager.h.

◆ meta_string

std::map<std::string, std::string> meta_string

Definition at line 531 of file TraceManager.h.

◆ name

◆ sample

◆ shape

◆ size

◆ unit_size

◆ verbose

bool verbose

Definition at line 532 of file TraceManager.h.

◆ write


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