QMCPACK
OutputMatrix Class Reference
+ Collaboration diagram for OutputMatrix:

Public Types

using RealType = QMCTraits::RealType
 

Public Member Functions

 OutputMatrix ()
 Constructor. More...
 
void init_file (const std::string &root_name, const std::string &name, int N)
 Open a text-formatted scalar.dat file and print the header line. More...
 
void output (Matrix< RealType > &mat)
 Print matrix to text-formatted scalar.dat file. More...
 

Private Attributes

int index_
 
std::ofstream output_file_
 

Detailed Description

Definition at line 27 of file OutputMatrix.h.

Member Typedef Documentation

◆ RealType

Definition at line 30 of file OutputMatrix.h.

Constructor & Destructor Documentation

◆ OutputMatrix()

Constructor.

Definition at line 22 of file OutputMatrix.cpp.

Member Function Documentation

◆ init_file()

void init_file ( const std::string &  root_name,
const std::string &  name,
int  N 
)

Open a text-formatted scalar.dat file and print the header line.

Definition at line 24 of file OutputMatrix.cpp.

References qmcplusplus::app_log(), qmcplusplus::Units::force::N, and OutputMatrix::output_file_.

Referenced by QMCFixedSampleLinearOptimize::run(), and QMCFixedSampleLinearOptimizeBatched::run().

25 {
26  int namelen = root_name.length();
27  // Assume that the root_name has the series suffix (".s000").
28  // Remove the series suffix to get the project id
29  std::string fname = root_name.substr(0, namelen - 5) + "." + name + ".s000.scalar.dat";
30  app_log() << "Output matrix file: " << fname << std::endl;
31 
32  output_file_.open(fname);
33  output_file_ << "# Index ";
34  for (int i = 0; i < N; i++)
35  {
36  for (int j = 0; j < N; j++)
37  {
38  std::string index_name = name + "_" + std::to_string(i) + "_" + std::to_string(j);
39  output_file_ << index_name << " ";
40  }
41  }
42  output_file_ << std::endl;
43 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::ofstream output_file_
Definition: OutputMatrix.h:44

◆ output()

void output ( Matrix< RealType > &  mat)

Print matrix to text-formatted scalar.dat file.

Definition at line 45 of file OutputMatrix.cpp.

References Matrix< T, Alloc >::cols(), OutputMatrix::index_, OutputMatrix::output_file_, and Matrix< T, Alloc >::rows().

Referenced by QMCFixedSampleLinearOptimizeBatched::one_shift_run().

46 {
47  output_file_ << index_ << " ";
48  for (int i = 0; i < mat.rows(); i++)
49  {
50  for (int j = 0; j < mat.cols(); j++)
51  {
52  output_file_ << mat(i, j) << " ";
53  }
54  }
55  output_file_ << std::endl;
56  index_++;
57 }
size_type cols() const
Definition: OhmmsMatrix.h:78
size_type rows() const
Definition: OhmmsMatrix.h:77
std::ofstream output_file_
Definition: OutputMatrix.h:44

Member Data Documentation

◆ index_

int index_
private

Definition at line 42 of file OutputMatrix.h.

Referenced by OutputMatrix::output().

◆ output_file_

std::ofstream output_file_
private

Definition at line 44 of file OutputMatrix.h.

Referenced by OutputMatrix::init_file(), and OutputMatrix::output().


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