forked from sanshar/Block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orbstring.C
77 lines (64 loc) · 1.58 KB
/
orbstring.C
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
/*
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
*/
#include "orbstring.h"
#include "global.h"
namespace SpinAdapted{
namespace OrbstringParams
{
int orb_size;
bool initialised;
}
}
int SpinAdapted::Orbstring::size () const
{
return OrbstringParams::orb_size;
}
void SpinAdapted::Orbstring::init (const int o)
{
OrbstringParams::orb_size = o;
OrbstringParams::initialised = true;
}
SpinAdapted::Orbstring::Orbstring () {
sign =0;
empty = true;
occ_rep = std::vector<bool>(OrbstringParams::orb_size, 0);
}
SpinAdapted::Orbstring& SpinAdapted::Orbstring::c (int i)
// applies creation operator i to ket
{
assert ((i >= 0) && (i < OrbstringParams::orb_size));
if (empty)
return *this;
else if (occ_rep[i])
{
empty = true;
return *this;
}
else
{
sign *= this->parity(i);
occ_rep[i] = 1;
}
return *this;
}
SpinAdapted::Orbstring& SpinAdapted::Orbstring::d (int i) // applies destruction operator i to ket
{
assert ((i >= 0) && (i < OrbstringParams::orb_size));
if (empty)
return *this;
else if (!occ_rep[i])
{
empty = true;
return *this;
}
else
{
sign *= this->parity(i);
occ_rep[i] = 0;
}
return *this;
}