forked from naokin/Block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStateInfo.h
103 lines (86 loc) · 3.44 KB
/
StateInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
Developed by Sandeep Sharma and Garnet K.-L. Chan, 2012
Copyright (c) 2012, Garnet K.-L. Chan
This program is integrated in Molpro with the permission of
Sandeep Sharma and Garnet K.-L. Chan
*/
#ifndef SPIN_STATE_INFO_HEADER
#define SPIN_STATE_INFO_HEADER
#include "ObjectMatrix.h"
#include "SpinQuantum.h"
#include "csf.h"
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>
namespace SpinAdapted{
enum {
NO_PARTICLE_SPIN_NUMBER_CONSTRAINT,
PARTICLE_SPIN_NUMBER_CONSTRAINT
};
enum {
AnyQ,
LessThanQ,
EqualQ,
WITH_LIST /*< states are added together if the are allowed by the quantaList */
};
class StateInfo
{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & totalStates & initialised & unBlockedIndex & quanta & quantaStates
& leftUnMapQuanta & rightUnMapQuanta & allowedQuanta
& quantaMap & oldToNewState & hasCollectedQuanta & newQuantaMap;
if (hasCollectedQuanta)
ar & unCollectedStateInfo;
ar & hasPreviousStateInfo;
if (hasPreviousStateInfo)
ar & previousStateInfo;
ar & hasAllocatedMemory;
}
public:
bool hasAllocatedMemory;
bool hasCollectedQuanta;
bool hasPreviousStateInfo;
StateInfo* leftStateInfo;
StateInfo* rightStateInfo;
boost::shared_ptr<StateInfo> unCollectedStateInfo;
boost::shared_ptr<StateInfo> previousStateInfo;
std::vector<SpinQuantum> quanta; //the quantas present
std::vector<int> quantaStates; //the number of each quanta
ObjectMatrix<char> allowedQuanta; //
ObjectMatrix< std::vector<int> > quantaMap;
std::vector<int> leftUnMapQuanta;
std::vector<int> rightUnMapQuanta;
int totalStates;
std::vector<int> unBlockedIndex;
std::vector< std::vector<int> > oldToNewState;
std::vector<int> newQuantaMap;
bool initialised;
public:
StateInfo();
StateInfo (const int n, const SpinQuantum q [], const int qS []);
StateInfo(const std::vector< Csf >& dets, bool addWavefunctionQuanta = false);
StateInfo (const std::vector<SpinQuantum>& q, const std::vector<int>& qS, const std::vector<int>& nMap);
void UnBlockIndex();
friend ostream& operator<<(ostream& os, const StateInfo& s);
friend void TensorProduct (StateInfo& a, StateInfo& b, const SpinQuantum q, const int constraint, StateInfo& c, StateInfo* compState=0);
// interface to the above function
friend void TensorProduct (StateInfo& a, StateInfo& b, StateInfo& c, const int constraint, StateInfo* compState=0);
void quanta_distribution (std::vector<SpinQuantum>& qnumbers, std::vector<int>& distribution, const bool complement);
void Allocate();
void Free();
void AllocatePreviousStateInfo ();
void CollectQuanta();
void AllocateUnCollectedStateInfo ();
int getquantastates(int i) {return quantaStates.at(i);}
int getquantastates(int i) const {return quantaStates.at(i);}
void UnMapQuantumState (const int QS, const int secondQSTotal, int& firstQS, int& secondQS) const;
static void store(bool forward, const vector<int>& sites, const vector<StateInfo>& states);
static void restore(bool forward, const vector<int>& sites, vector<StateInfo>& states);
};
}
#endif