forked from sanshar/Block
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SpinSpace.C
87 lines (70 loc) · 1.95 KB
/
SpinSpace.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
77
78
79
80
81
82
83
84
85
86
87
/*
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 "SpinSpace.h"
#include "global.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
namespace SpinAdapted{
SpinSpace::SpinSpace(int ir) {
if (dmrginp.spinAdapted())
irrep = abs(ir);
else
irrep = ir;
}
std::vector<SpinSpace> SpinSpace::operator+=(SpinSpace rhs)
{
std::vector<SpinSpace> Spins;
if (!dmrginp.spinAdapted())
Spins.push_back(SpinSpace(irrep+rhs.irrep));
else {
for (int i=abs(irrep-rhs.irrep); i<=irrep+rhs.irrep; i+=2)
Spins.push_back(SpinSpace(i));
}
return Spins;
}
bool SpinSpace::operator==(SpinSpace rhs) const
{
return irrep == rhs.irrep;
}
bool SpinSpace::operator!=(SpinSpace rhs) const
{
return irrep != rhs.irrep;
}
std::vector<SpinSpace> operator+(SpinSpace lhs, SpinSpace rhs)
{
return lhs+=rhs;
}
SpinSpace operator-(const SpinSpace lhs)
{
int outirrep;
if (!dmrginp.spinAdapted())
outirrep = -lhs.irrep;
else
outirrep = lhs.irrep;
return SpinSpace(outirrep);
}
void SpinSpace::Save(std::ofstream &ofs)
{
boost::archive::binary_oarchive save_sym(ofs);
save_sym << *this;
}
void SpinSpace::Load (std::ifstream &ifs)
{
boost::archive::binary_iarchive load_sym(ifs);
load_sym >> *this;
}
ostream& operator<< (ostream& os, const SpinSpace s)
{
os << s.irrep;
return os;
}
bool SpinSpace::operator< (const SpinSpace s) const
{
return irrep<s.irrep;
}
int SpinSpace::getirrep() const {return irrep;}
}