VMPS++
Loading...
Searching...
No Matches
DmrgPivotMatrix0.h
Go to the documentation of this file.
1#ifndef STRAWBERRY_DMRG_HEFF_STUFF_0SITE_WITH_Q
2#define STRAWBERRY_DMRG_HEFF_STUFF_0SITE_WITH_Q
3
4//include "DmrgExternal.h"
5//include "tensors/Biped.h"
7//include "pivot/DmrgPivotVector.h"
8
9//-----------<definitions>-----------
10template<typename Symmetry, typename Scalar, typename MpoScalar=double>
12{
14
15 PivotMatrix0 (const Tripod<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > &L_input,
16 const Tripod<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > &R_input)
17 :L(L_input), R(R_input)
18 {}
19
21 :L(H.Terms[0].L), R(H.Terms[0].R)
22 {}
23
26};
27
28//-----------<matrix*vector>-----------
31template<typename Symmetry, typename Scalar, typename MpoScalar>
33{
34 Vout.outerResize(Vin);
35 Vout.data[0].setZero();
36
37 for (size_t qL=0; qL<H.L.dim; ++qL)
38 {
39 qarray3<Symmetry::Nq> qupleR = {H.L.out(qL), H.L.in(qL), H.L.mid(qL)};
40 auto qR = H.R.dict.find(qupleR);
41
42 if (qR != H.R.dict.end())
43 {
44 qarray2<Symmetry::Nq> qupleAin = {H.L.out(qL), H.L.out(qL)};
45 auto qAin = Vin.data[0].dict.find(qupleAin);
46
47 if (qAin != Vin.data[0].dict.end())
48 {
49 qarray2<Symmetry::Nq> qupleAout = {H.R.out(qR->second), H.R.out(qR->second)};
50 auto qAout = Vout.data[0].dict.find(qupleAout);
51
52 if (qAout != Vout.data[0].dict.end())
53 {
54 assert(H.L.block[qL].shape()[0] == H.R.block[qR->second].shape()[0]);
55 for (size_t a=0; a<H.L.block[qL].shape()[0]; ++a)
56 {
57 Matrix<Scalar,Dynamic,Dynamic> Mtmp;
58
59 if (H.L.block[qL][a][0].size() != 0 and
60 H.R.block[qR->second][a][0].size() !=0)
61 {
62 // print_size(H.L.block[qL][a][0], "H.L.block[qL][a][0]");
63 // print_size(Vin.data[0].block[qAin->second], "Vin.data[0].block[qAin->second]");
64 // print_size(H.R.block[qR->second][a][0], "H.R.block[qR->second][a][0]");
66 H.L.block[qL][a][0],
67 Vin.data[0].block[qAin->second],
68 H.R.block[qR->second][a][0],
69 Mtmp);
70 }
71
72// Scalar norm = Mtmp.norm();
73// if (norm > 0)
74// {
75// cout << "q=" << qupleAout[0] << ", a=" << a << ", Mtmp.norm()=" << Mtmp.norm() << endl;
76// }
77
78 if (Mtmp.size() != 0)
79 {
80 if (Vout.data[0].block[qAout->second].size() != 0)
81 {
82// cout << "adding L: a=" << a << ", q=" << H.L.out(qL) << ", " << H.L.in(qL) << ", " << H.L.mid(qL) << endl;
83 Vout.data[0].block[qAout->second] += Mtmp;
84 }
85 else
86 {
87// cout << "adding L: a=" << a << ", q=" << H.L.out(qL) << ", " << H.L.in(qL) << ", " << H.L.mid(qL) << endl;
88 Vout.data[0].block[qAout->second] = Mtmp;
89 }
90 }
91 }
92 }
93 }
94 }
95 }
96}
97
98template<typename Symmetry, typename Scalar, typename MpoScalar>
100{
102 HxV(H,Vinout,Vtmp);
103 Vinout = Vtmp;
104}
105
106template<typename Symmetry, typename Scalar, typename MpoScalar>
108{
109 return 0;
110}
111
112// How to calculate the Frobenius norm of this?
113template<typename Symmetry, typename Scalar, typename MpoScalar>
115{
116 return 0;
117}
118
119#endif
void optimal_multiply(Scalar alpha, const MatrixTypeA &A, const MatrixTypeB &B, const MatrixTypeC &C, MatrixTypeR &result, bool DEBUG=false)
Definition: DmrgExternal.h:191
double norm(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H)
void HxV(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H, const PivotVector< Symmetry, Scalar > &Vin, PivotVector< Symmetry, Scalar > &Vout)
size_t dim(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H)
std::array< qarray< Nq >, 2 > qarray2
Definition: qarray.h:51
std::array< qarray< Nq >, 3 > qarray3
Definition: qarray.h:52
Tripod< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > R
PivotMatrix0(const Tripod< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > &L_input, const Tripod< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > &R_input)
PivotMatrix0(const PivotMatrix1< Symmetry, Scalar, MpoScalar > &H)
Tripod< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > L
void outerResize(const PivotVector &Vrhs)
vector< Biped< Symmetry, Matrix< Scalar_, Dynamic, Dynamic > > > data