v2DM-DOCI  1.0
OptIndex.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <assert.h>
3 
4 #include "OptIndex.h"
5 #include "Hamiltonian.h"
6 
8 
9 OptIndex::OptIndex(const int L, const int _Group, const int * NORBin)
10 {
11  this->L = L;
12  SymmInfo.setGroup(_Group);
14 
15  NORB.resize(Nirreps);
16  NORBcumulative.resize(Nirreps+1);
17 
18  int sum_check = 0;
19  NORBcumulative[0] = 0;
20  for (int irrep=0; irrep<Nirreps; irrep++)
21  {
22  NORB[irrep] = NORBin[irrep];
23 
24  sum_check += NORB[irrep];
25 
26  NORBcumulative[irrep+1] = NORBcumulative[irrep] + NORB[irrep];
27  }
28 
29  if (sum_check != L)
30  std::cerr << "OptIndex::OptIndex : Sum over all orbitals is not L." << std::endl;
31 
32  irrep_each_orbital.resize(NORBcumulative[Nirreps]);
33 
34  for (int irrep=0; irrep<Nirreps; irrep++)
35  for (int cnt=0; cnt<NORB[irrep]; cnt++)
36  irrep_each_orbital[ NORBcumulative[irrep] + cnt ] = irrep;
37 }
38 
40 {
42  this->L = ham.L;
43  this->Nirreps = ham.SymmInfo.getNumberOfIrreps();
44 
45  NORB.resize(Nirreps);
46  NORBcumulative.resize(Nirreps+1);
47 
48  int sum_check = 0;
49  NORBcumulative[0] = 0;
50  for (int irrep=0; irrep<Nirreps; irrep++)
51  {
52  NORB[irrep] = ham.irrep2num_orb[irrep];
53 
54  sum_check += NORB[irrep];
55 
56  NORBcumulative[irrep+1] = NORBcumulative[irrep] + NORB[irrep];
57  }
58 
59  if (sum_check != L)
60  std::cerr << "OptIndex::OptIndex : Sum over all orbitals is not L." << std::endl;
61 
62  irrep_each_orbital.resize(NORBcumulative[Nirreps]);
63 
64  for (int irrep=0; irrep<Nirreps; irrep++)
65  for (int cnt=0; cnt<NORB[irrep]; cnt++)
66  irrep_each_orbital[ NORBcumulative[irrep] + cnt ] = irrep;
67 }
68 
69 int OptIndex::getL() const { return L; }
70 
71 int OptIndex::getNirreps() const { return Nirreps; }
72 
73 int OptIndex::getNORB(const int irrep) const { return NORB[irrep]; }
74 
75 int OptIndex::getNstart(const int irrep) const { return NORBcumulative[irrep]; }
76 
77 const int * OptIndex::get_irrep_each_orbital() const { return irrep_each_orbital.data(); }
78 
79 int OptIndex::getNgroup() const { return SymmInfo.getGroupNumber(); }
80 
81 void OptIndex::Print() const
82 {
83  using std::cout;
84  using std::endl;
85 
86  cout << "NORB = [ ";
87  for (int irrep=0; irrep<Nirreps-1; irrep++)
88  cout << NORB[irrep] << " , ";
89  cout << NORB[Nirreps-1] << " ]" << endl;
90 }
CheMPS2::Irreps SymmInfo
Definition: OptIndex.h:26
int getL() const
Definition: OptIndex.cpp:69
bool setGroup(const int nGroup)
Set the group.
Definition: Irreps.cpp:50
int getNumberOfIrreps() const
Get the number of irreps for the currently activated group.
Definition: Irreps.cpp:94
const int * get_irrep_each_orbital() const
Definition: OptIndex.cpp:77
OptIndex(const int L, const int Group, const int *NORBin)
Definition: OptIndex.cpp:9
int getGroupNumber() const
Get the group number.
Definition: Irreps.cpp:66
std::vector< int > irrep_each_orbital
Definition: OptIndex.h:31
int getNORB(const int irrep) const
Definition: OptIndex.cpp:73
int getNstart(const int irrep) const
Definition: OptIndex.cpp:75
void Print() const
Definition: OptIndex.cpp:81
int getNgroup() const
Definition: OptIndex.cpp:79
std::vector< int > NORB
Definition: OptIndex.h:29
std::vector< int > NORBcumulative
Definition: OptIndex.h:30
int getNirreps() const
Definition: OptIndex.cpp:71
int getNGroup() const
Get the group number.
std::unique_ptr< int[]> irrep2num_orb
Definition: Hamiltonian.h:190