VMPS++
Loading...
Searching...
No Matches
DmrgPivotOverlap1.h
Go to the documentation of this file.
1#ifndef DMRGPIVOTOVERLAP1
2#define DMRGPIVOTOVERLAP1
3
4//include "DmrgTypedefs.h"
5//include "tensors/Biped.h"
6//include "tensors/Multipede.h"
8
9template<typename Symmetry, typename Scalar>
11{
13 PivotOverlap1(const Biped<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > &L_input,
14 const Biped<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > &R_input,
15 const vector<qarray<Symmetry::Nq> > &qloc_input)
16 :L(L_input), R(R_input), qloc(qloc_input)
17 {};
18
21
22 vector<qarray<Symmetry::Nq> > qloc;
23};
24
25template<typename Symmetry, typename Scalar>
27{
28 Vout.outerResize(Vin);
29
30 for (size_t s=0; s<H.qloc.size(); ++s)
31 for (size_t qL=0; qL<H.L.dim; ++qL)
32 {
33 vector<tuple<qarray2<Symmetry::Nq>,size_t,size_t> > ix;
34 bool FOUND_MATCH = LAA(H.L.in[qL], H.L.out[qL], s, H.qloc, Vout.data, Vin.data, ix);
35
36 if (FOUND_MATCH)
37 {
38 for (size_t n=0; n<ix.size(); ++n)
39 {
40 size_t qAbra = get<1>(ix[n]);
41 size_t qAket = get<2>(ix[n]);
42 auto qR = H.R.dict.find(get<0>(ix[n]));
43
44 if (qR != H.R.dict.end() and
45 H.L.block[qL].size() != 0 and
46 Vin.data[s].block[qAket].size() != 0 and
47 H.R.block[qR->second].size() != 0)
48 {
49 Matrix<Scalar,Dynamic,Dynamic> Mtmp;
50
51 if (H.L.block[qL].cols() == Vin.data[s].block[qAket].rows() and
52 Vin.data[s].block[qAket].cols() == H.R.block[qR->second].rows())
53 {
55 H.L.block[qL],
56 Vin.data[s].block[qAket],
57 H.R.block[qR->second],
58 Mtmp);
59 }
60 else
61 {
62 lout << termcolor::red << "Warning: Mismatched matrix dimensions in LRxV (PivotOverlap1)!" << termcolor::reset << endl;
63 print_size(H.L.block[qL],"H.L.block[qL]");
64 print_size(Vin.data[s].block[qAket],"Vin.data[s].block[qAket]");
65 print_size(H.R.block[qR->second],"H.R.block[qR->second]");
66 lout << "qnums: " << H.L.in[qL] << "-" << H.L.out[qL] << ", "
67 << Vin.data[s].in[qAket] << "-" << Vin.data[s].out[qAket] << ", "
68 << H.R.in[qR->second] << "-" << H.R.out[qR->second]
69 << endl;
70 lout << endl;
71 }
72
73 if (Mtmp.size() != 0)
74 {
75 if (Vout.data[s].block[qAbra].size() != 0)
76 {
77 Vout.data[s].block[qAbra] += Mtmp;
78 }
79 else
80 {
81 Vout.data[s].block[qAbra] = Mtmp;
82 }
83 }
84 }
85 }
86 }
87 }
88}
89
90template<typename Symmetry, typename Scalar>
92{
94 LRxV(H,Vinout,Vtmp);
95 Vinout = Vtmp;
96}
97
98#endif
void print_size(const MatrixType &M, string label)
Definition: DmrgExternal.h:184
void optimal_multiply(Scalar alpha, const MatrixTypeA &A, const MatrixTypeB &B, const MatrixTypeC &C, MatrixTypeR &result, bool DEBUG=false)
Definition: DmrgExternal.h:191
bool LAA(qarray< Symmetry::Nq > Lin, qarray< Symmetry::Nq > Lout, size_t s, vector< qarray< Symmetry::Nq > > qloc, const vector< Biped< Symmetry, MatrixType > > &Abra, const vector< Biped< Symmetry, MatrixType > > &Aket, vector< tuple< qarray2< Symmetry::Nq >, size_t, size_t > > &result)
void LRxV(const PivotOverlap1< Symmetry, Scalar > &H, const PivotVector< Symmetry, Scalar > &Vin, PivotVector< Symmetry, Scalar > &Vout)
Definition: Biped.h:64
std::unordered_map< std::array< qType, 2 >, std::size_t > dict
Definition: Biped.h:104
std::vector< MatrixType_ > block
Definition: Biped.h:96
std::vector< qType > in
Definition: Biped.h:87
std::size_t dim
Definition: Biped.h:82
std::vector< qType > out
Definition: Biped.h:90
Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > L
vector< qarray< Symmetry::Nq > > qloc
PivotOverlap1(const Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > &L_input, const Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > &R_input, const vector< qarray< Symmetry::Nq > > &qloc_input)
Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > R
void outerResize(const PivotVector &Vrhs)
vector< Biped< Symmetry, Matrix< Scalar_, Dynamic, Dynamic > > > data
Definition: qarray.h:26