VMPS++
Loading...
Searching...
No Matches
TwoSiteGate.h
Go to the documentation of this file.
1#ifndef TWO_SITE_GATE_H_
2#define TWO_SITE_GATE_H_
3
4#include "tensors/Qbasis.h"
5
6template<typename Symmetry, typename Scalar>
8{
9public:
11 TwoSiteGate(const vector<vector<vector<vector<vector<Scalar> > > > > &data_in) : data(data_in){};
12 TwoSiteGate(const Qbasis<Symmetry> &s1, const Qbasis<Symmetry> &s2);
13
14 void print() const;
15
16 //
17 // s1p s2p
18 // | |
19 // swap= ****** = delta(s1,s2p)*delta(s2,s1p)
20 // | |
21 // s1 s2
22 //
23 void setSwapGate(bool FERMIONIC=false);
24
25 void setIdentity();
26
27 Qbasis<Symmetry> midBasis() const {return Bmid;}
28 Qbasis<Symmetry> leftBasis() const {return B1;}
29 Qbasis<Symmetry> rightBasis() const {return B2;}
30
31//private:
32 //data[s1][s2][s1_p][s2_p][k]:
33 //
34 // s1p s2p s1p s2p
35 // | | \ /
36 // ^ ^ \ /
37 // | | ^
38 // ****** |
39 // *gate* CGC: k
40 // ****** ^
41 // | | |
42 // ^ ^ / \
43 // | | / \
44 // s1 s2 s1 s2
45 //
46 vector<vector<vector<vector<vector<Scalar> > > > > data;
48
49 vector<qarray<Symmetry::Nq> > qloc1, qloc2, qmid;
50
51 void resize();
52};
53
54template<typename Symmetry, typename Scalar>
57 : B1(s1),B2(s2)
58{
59 //Bmid is the combined basis from B1 and B2.
60 Bmid = B1.combine(B2);
61 qloc1 = B1.qloc();
62 qloc2 = B2.qloc();
63 qmid = Bmid.qs();
64 resize();
65}
66
67template<typename Symmetry, typename Scalar>
69resize()
70{
71 data.resize(qloc1.size());
72 for (size_t s1=0; s1< qloc1.size(); s1++)
73 {
74 data[s1].resize(qloc2.size());
75 for (size_t s2=0; s2<qloc2.size(); s2++)
76 {
77 data[s1][s2].resize(qloc1.size());
78 for (size_t s1p=0; s1p<qloc1.size(); s1p++)
79 {
80 data[s1][s2][s1p].resize(qloc2.size());
81 for (size_t s2p=0; s2p<qloc2.size(); s2p++)
82 {
83 data[s1][s2][s1p][s2p].resize(qmid.size());
84 }
85 }
86 }
87 }
88}
89
90
91template<typename Symmetry, typename Scalar>
93setSwapGate(bool FERMIONIC)
94{
95 assert(!FERMIONIC and "Fermionic swap gates are not yet implemented.");
96 for (size_t s1=0; s1<qloc1.size(); s1++)
97 for (size_t s2=0; s2<qloc2.size(); s2++)
98 for (size_t s1p=0; s1p<qloc1.size(); s1p++)
99 for (size_t s2p=0; s2p<qloc2.size(); s2p++)
100 for (size_t k=0; k<qmid.size(); k++)
101 {
102 if (!Symmetry::triangle({qloc1[s1],qloc2[s2],qmid[k]})) {continue;}
103 if (!Symmetry::triangle({qloc1[s1p],qloc2[s2p],qmid[k]})) {continue;}
104 if (s1 == s2p and s2 == s1p)
105 {
106 // cout << "s1=" << s1 << "," << qloc1[s1] << ", s2p=" << s2p << "," << qloc2[s2p] << ", s2=" << s2 << "," << qloc2[s2] << ", s1p=" << s1p << "," << qloc1[s1p] << ", k=" << k << "," << qmid[k] << endl;
107 // cout << "CGC phase=" << Symmetry::coeff_swapPhase(qloc1[s1],qloc2[s2],qmid[k]) << endl;
108 data[s1][s2][s1p][s2p][k] = Symmetry::coeff_swapPhase(qloc1[s1],qloc2[s2],qmid[k])*Scalar(1.);
109 }
110 else {data[s1][s2][s1p][s2p][k] = Scalar(0.);}
111 }
112}
113
114template<typename Symmetry, typename Scalar>
117{
118 for (size_t s1=0; s1<qloc1.size(); s1++)
119 for (size_t s2=0; s2<qloc2.size(); s2++)
120 for (size_t s1p=0; s1p<qloc1.size(); s1p++)
121 for (size_t s2p=0; s2p<qloc2.size(); s2p++)
122 for (size_t k=0; k<qmid.size(); k++)
123 {
124 if (s1 == s1p and s2 == s2p)
125 {
126 data[s1][s2][s1p][s2p][k] = Scalar(1.);
127 }
128 else {data[s1][s2][s1p][s2p][k] = Scalar(0.);}
129 }
130}
131
132template<typename Symmetry, typename Scalar>
134print() const
135{
136 for (size_t s1=0; s1<qloc1.size(); s1++)
137 for (size_t s2=0; s2<qloc2.size(); s2++)
138 for (size_t s1p=0; s1p<qloc1.size(); s1p++)
139 for (size_t s2p=0; s2p<qloc2.size(); s2p++)
140 for (size_t k=0; k<qmid.size(); k++)
141 {
142 cout << "data[" << s1 << "][" << s2 << "][" << s1p << "][" << s2p << "][" << k << "]=" << data[s1][s2][s1p][s2p][k] << endl;
143 }
144}
145
146
147#endif
Definition: Qbasis.h:39
vector< qarray< Symmetry::Nq > > qmid
Definition: TwoSiteGate.h:49
Qbasis< Symmetry > B1
Definition: TwoSiteGate.h:47
Qbasis< Symmetry > rightBasis() const
Definition: TwoSiteGate.h:29
Qbasis< Symmetry > Bmid
Definition: TwoSiteGate.h:47
Qbasis< Symmetry > midBasis() const
Definition: TwoSiteGate.h:27
void resize()
Definition: TwoSiteGate.h:69
void setSwapGate(bool FERMIONIC=false)
Definition: TwoSiteGate.h:93
Qbasis< Symmetry > B2
Definition: TwoSiteGate.h:47
TwoSiteGate(const vector< vector< vector< vector< vector< Scalar > > > > > &data_in)
Definition: TwoSiteGate.h:11
void print() const
Definition: TwoSiteGate.h:134
vector< qarray< Symmetry::Nq > > qloc1
Definition: TwoSiteGate.h:49
Qbasis< Symmetry > leftBasis() const
Definition: TwoSiteGate.h:28
vector< vector< vector< vector< vector< Scalar > > > > > data
Definition: TwoSiteGate.h:46
vector< qarray< Symmetry::Nq > > qloc2
Definition: TwoSiteGate.h:49
void setIdentity()
Definition: TwoSiteGate.h:116