QMCPACK
ci_configuration Struct Reference
+ Collaboration diagram for ci_configuration:

Public Member Functions

 ci_configuration ()
 
 ci_configuration (std::vector< bool > &v, int n)
 
 ci_configuration (const ci_configuration &c)
 
 ~ci_configuration ()
 
bool operator== (const ci_configuration &c) const
 
bool isSingle (const ci_configuration &c, int &rem, int &add) const
 
int count () const
 
void add_occupation (std::string &str)
 

Public Attributes

std::vector< bool > occup
 
bool taken
 
int nExct
 

Detailed Description

Definition at line 23 of file ci_configuration.h.

Constructor & Destructor Documentation

◆ ci_configuration() [1/3]

ci_configuration ( )
inline

Definition at line 30 of file ci_configuration.h.

◆ ci_configuration() [2/3]

ci_configuration ( std::vector< bool > &  v,
int  n 
)
inline

◆ ci_configuration() [3/3]

ci_configuration ( const ci_configuration c)
inline

Definition at line 33 of file ci_configuration.h.

33 : occup(c.occup), taken(c.taken), nExct(c.nExct) {}

◆ ~ci_configuration()

~ci_configuration ( )
inline

Definition at line 35 of file ci_configuration.h.

35 {}

Member Function Documentation

◆ add_occupation()

void add_occupation ( std::string &  str)
inline

Definition at line 119 of file ci_configuration.h.

References ci_configuration::occup.

120  {
121  int str_size = str.size();
122  occup.resize(str_size);
123  for (int i = 0; i < str_size; i++)
124  occup[i] = str[i] - '0';
125  }

◆ count()

int count ( ) const
inline

Definition at line 110 of file ci_configuration.h.

References ci_configuration::occup.

Referenced by ci_configuration::isSingle(), and ci_configuration::operator==().

111  {
112  int res = 0;
113  for (int i = 0; i < occup.size(); i++)
114  if (occup[i])
115  res++;
116  return res;
117  }

◆ isSingle()

bool isSingle ( const ci_configuration c,
int &  rem,
int &  add 
) const
inline

Definition at line 70 of file ci_configuration.h.

References qmcplusplus::simd::add(), APP_ABORT, ci_configuration::count(), ci_configuration::nExct, and ci_configuration::occup.

71  {
72  if (c.nExct - nExct != 1)
73  return false;
74  if (occup.size() != c.occup.size())
75  {
76  APP_ABORT("ci_configuration::isSingle() - ci_configurations are not compatible.");
77  }
78  if (count() != c.count())
79  {
80  APP_ABORT(
81  "ci_configuration::isSingle() - ci_configurations are not compatible. Unequal number of occupied states. ");
82  }
83  int nr = 0, na = 0, r = -1, a = -1;
84  for (int i = 0; i < occup.size(); i++)
85  {
86  if (occup[i] ^ c.occup[i])
87  {
88  if (occup[i])
89  {
90  nr++;
91  r = i;
92  }
93  else
94  {
95  na++;
96  a = i;
97  }
98  }
99  }
100  if (na == 1 && nr == 1)
101  {
102  rem = r;
103  add = a;
104  return true;
105  }
106  else
107  return false;
108  }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void add(int n, const T *restrict in, T *restrict out)
Definition: vmath.hpp:95

◆ operator==()

bool operator== ( const ci_configuration c) const
inline

Definition at line 37 of file ci_configuration.h.

References APP_ABORT, qmcplusplus::app_log(), ci_configuration::count(), ci_configuration::nExct, and ci_configuration::occup.

38  {
39  if (nExct != c.nExct)
40  {
41  return false;
42  }
43  if (occup.size() != c.occup.size())
44  {
45  APP_ABORT("ci_configuration::operator==() - ci_configurations are not compatible.");
46  }
47  if (count() != c.count())
48  {
49  app_log() << "c0: ";
50  for (int i = 0; i < occup.size(); i++)
51  app_log() << occup[i];
52  app_log() << std::endl << "c1: ";
53  for (int i = 0; i < c.occup.size(); i++)
54  app_log() << c.occup[i];
55  app_log() << std::endl;
56  APP_ABORT(
57  "ci_configuration::operator==() - ci_configurations are not compatible. Unequal number of occupied states. ");
58  }
59  for (int i = 0; i < occup.size(); i++)
60  {
61  if (occup[i] ^ c.occup[i])
62  {
63  return false;
64  }
65  }
66  return true;
67  }
std::ostream & app_log()
Definition: OutputManager.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

Member Data Documentation

◆ nExct

int nExct

Definition at line 28 of file ci_configuration.h.

Referenced by ci_configuration::isSingle(), and ci_configuration::operator==().

◆ occup

◆ taken

bool taken

Definition at line 27 of file ci_configuration.h.


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