DOCI-Exact  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  CheMPS2::Irreps SymmInfo;
13  SymmInfo.setGroup(_Group);
14  this->Nirreps = SymmInfo.getNumberOfIrreps();
15 
16  NORB.resize(Nirreps);
17  NORBcumulative.resize(Nirreps+1);
18 
19  int sum_check = 0;
20  NORBcumulative[0] = 0;
21  for (int irrep=0; irrep<Nirreps; irrep++)
22  {
23  NORB[irrep] = NORBin[irrep];
24 
25  sum_check += NORB[irrep];
26 
27  NORBcumulative[irrep+1] = NORBcumulative[irrep] + NORB[irrep];
28  }
29 
30  if (sum_check != L)
31  std::cerr << "OptIndex::OptIndex : Sum over all orbitals is not L." << std::endl;
32 
33  irrep_each_orbital.resize(NORBcumulative[Nirreps]);
34 
35  for (int irrep=0; irrep<Nirreps; irrep++)
36  for (int cnt=0; cnt<NORB[irrep]; cnt++)
37  irrep_each_orbital[ NORBcumulative[irrep] + cnt ] = irrep;
38 }
39 
41 {
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 int * OptIndex::get_irrep_each_orbital() { return irrep_each_orbital.data(); }
78 
79 void OptIndex::Print() const
80 {
81  using std::cout;
82  using std::endl;
83 
84  cout << "NORB = [ ";
85  for (int irrep=0; irrep<Nirreps-1; irrep++)
86  cout << NORB[irrep] << " , ";
87  cout << NORB[Nirreps-1] << " ]" << endl;
88 }
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
OptIndex(const int L, const int Group, const int *NORBin)
Definition: OptIndex.cpp:9
int * get_irrep_each_orbital()
Definition: OptIndex.cpp:77
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:79
int getNirreps() const
Definition: OptIndex.cpp:71