QMCPACK
OutputMatrix.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2021 QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 /** @file OutputMatrix.cpp
14  * @brief Output the Hamiltonian and overlap matrices from linear method
15  */
16 
18 
19 
20 namespace qmcplusplus
21 {
23 
24 void OutputMatrix::init_file(const std::string& root_name, const std::string& name, int N)
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 }
44 
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 }
58 
59 
60 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
OutputMatrix()
Constructor.
std::ostream & app_log()
Definition: OutputManager.h:65
size_type cols() const
Definition: OhmmsMatrix.h:78
size_type rows() const
Definition: OhmmsMatrix.h:77
void output(Matrix< RealType > &mat)
Print matrix to text-formatted scalar.dat file.
std::ofstream output_file_
Definition: OutputMatrix.h:44
Output the Hamiltonian and overlap matrices from linear method.
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.