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

Public Member Functions

 CombinedTraceSample (const std::string &sdomain, const std::string &sname, int sindex, int sdim, Vector< T > &ssample)
 
 CombinedTraceSample (const std::string &sdomain, const std::string &sname, int sindex, int sdim, TinyVector< int, DMAX > sshape, Vector< T > &ssample)
 
bool is_combined () override
 
void reset ()
 
void add_component (TraceSample< T > *component, TraceReal weight)
 
void combine ()
 
void write_summary_combined (int ind, std::string pad=" ")
 
- Public Member Functions inherited from TraceSample< T >
 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)
 
void set_buffer_range (int &bstart)
 
sum ()
 
void write_summary (int ind=-1, std::string pad=" ")
 

Public Attributes

bool combined
 
std::vector< TraceRealweights
 
std::vector< TraceSample< T > * > components
 
- Public Attributes inherited from TraceSample< T >
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::CombinedTraceSample< T >

Definition at line 650 of file TraceManager.h.

Constructor & Destructor Documentation

◆ CombinedTraceSample() [1/2]

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

Definition at line 657 of file TraceManager.h.

662  : TraceSample<T>(sdomain, sname, sindex, sdim, ssample)
663  {
664  reset();
665  }

◆ CombinedTraceSample() [2/2]

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

Definition at line 668 of file TraceManager.h.

674  : TraceSample<T>(sdomain, sname, sindex, sdim, sshape, ssample)
675  {
676  reset();
677  }

Member Function Documentation

◆ add_component()

void add_component ( TraceSample< T > *  component,
TraceReal  weight 
)
inline

Definition at line 684 of file TraceManager.h.

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

685  {
686  if (components.size() == 0)
687  {
688  this->dimension = component->dimension;
689  this->size = component->size;
690  this->shape = component->shape;
691  this->data_size = component->data_size;
692  this->array_trace = component->array_trace;
693  this->sample.resize(component->size);
694  }
695  else if (!this->same_shape(component))
696  {
697  APP_ABORT("CombinedTraceSample::add_component attempted to add a different shape component\n my domain: " +
698  this->domain + "\n my name: " + this->name + "\n component domain: " + component->domain +
699  "\n component name: " + component->name);
700  }
701  else if (this->domain != component->domain)
702  APP_ABORT("CombinedTraceSample::add_component attempted to add a different domain component\n my domain: " +
703  this->domain + "\n my name: " + this->name + "\n component domain: " + component->domain +
704  "\n component name: " + component->name);
705  weights.push_back(weight);
706  components.push_back(component);
707  }
TinyVector< int, DMAX > shape
Definition: TraceManager.h:525
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
std::vector< TraceSample< T > * > components
Definition: TraceManager.h:654
std::vector< TraceReal > weights
Definition: TraceManager.h:653
bool same_shape(TraceSample< T > *other)
Definition: TraceManager.h:596
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ combine()

void combine ( )
inline

Definition at line 710 of file TraceManager.h.

Referenced by qmcplusplus::accum_constant(), qmcplusplus::accum_sample(), and EnergyDensityEstimator::evaluate().

711  {
712  std::fill(this->sample.begin(), this->sample.end(), T(0));
713  for (int i = 0; i < components.size(); ++i)
714  {
715  T weight = weights[i];
716  auto& component = components[i]->sample;
717  for (int j = 0; j < this->sample.size(); ++j)
718  this->sample[j] += weight * component[j];
719  }
720  combined = true;
721  }
std::vector< TraceSample< T > * > components
Definition: TraceManager.h:654
size_type size() const
return the current size
Definition: OhmmsVector.h:162
std::vector< TraceReal > weights
Definition: TraceManager.h:653

◆ is_combined()

bool is_combined ( )
inlineoverridevirtual

Reimplemented from TraceSample< T >.

Definition at line 679 of file TraceManager.h.

679 { return true; }

◆ reset()

void reset ( )
inline

◆ write_summary_combined()

void write_summary_combined ( int  ind,
std::string  pad = "  " 
)
inline

Definition at line 724 of file TraceManager.h.

725  {
726  std::string pad2 = pad + " ";
727  std::string pad3 = pad2 + " ";
728  app_log() << pad << ind << " CombinedTraceSample " << this->name << std::endl;
729  app_log() << pad2 << "domain = " << this->domain << std::endl;
730  app_log() << pad2 << "ncomponents = " << components.size() << std::endl;
731  app_log() << pad2 << "components" << std::endl;
732  for (int i = 0; i < components.size(); ++i)
733  {
734  TraceSample<T>& c = *components[i];
735  app_log() << pad3 << c.name << " " << c.index << " " << weights[i] << std::endl;
736  }
737  app_log() << pad2 << "end components" << std::endl;
738  app_log() << pad2 << "vector address = " << (size_t) & this->sample << std::endl;
739  }
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< TraceSample< T > * > components
Definition: TraceManager.h:654
std::vector< TraceReal > weights
Definition: TraceManager.h:653

Member Data Documentation

◆ combined

◆ components

◆ weights


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