13template<
typename Symmetry,
typename Scalar,
typename MpoScalar=
double>
34 boost::multi_array<MpoScalar,4>
h;
36 vector<Biped<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > >
AL;
37 vector<Biped<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > >
AR;
39 vector<qarray<Symmetry::Nq> >
qloc;
45template<
typename Symmetry,
typename Scalar,
typename MpoScalar=
double>
57 boost::multi_array<MpoScalar,4>
h;
59 vector<Biped<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > >
AL;
60 vector<Biped<Symmetry,Matrix<Scalar,Dynamic,Dynamic> > >
AR;
62 vector<qarray<Symmetry::Nq> >
qloc;
67template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
70 size_t D = H.
h.shape()[0];
76 for (
size_t s1=0; s1<D; ++s1)
77 for (
size_t s2=0; s2<D; ++s2)
78 for (
size_t s3=0; s3<D; ++s3)
79 for (
size_t s4=0; s4<D; ++s4)
81 if (H.
h[s1][s2][s3][s4] != 0.)
83 for (
size_t q1=0; q1<H.
AL[s1].dim; ++q1)
85 auto A2outs = Symmetry::reduceSilent(H.
AL[s1].in[q1], H.
qloc[s2]);
86 for (
const auto &A2out : A2outs)
89 if (it2 != H.
AL[s2].dict.end())
91 auto A4outs = Symmetry::reduceSilent(H.
AL[s2].out[it2->second], H.
qloc[s4]);
92 for (
const auto &A4out : A4outs)
95 if (it4 != H.
AL[s4].dict.end())
97 Matrix<Scalar,Dynamic,Dynamic> Mtmp;
99 H.
AL[s1].block[q1].adjoint(),
100 H.
AL[s2].block[it2->second],
101 Vin.
data[s4].block[it4->second],
105 if (Mtmp.size() != 0)
108 auto it = Vout.
data[s3].dict.find(quple);
110 if (it != Vout.
data[s3].dict.end())
112 if (Vout.
data[s3].block[it->second].rows() != Mtmp.rows() and
113 Vout.
data[s3].block[it->second].cols() != Mtmp.cols())
115 Vout.
data[s3].block[it->second] = Mtmp;
119 Vout.
data[s3].block[it->second] += Mtmp;
124 cout << termcolor::red <<
"pushback that shouldn't be: PivumpsMatrix1 term 1" << termcolor::reset << endl;
125 Vout.
data[s3].push_back(quple, Mtmp);
137 for (
size_t s1=0; s1<D; ++s1)
138 for (
size_t s2=0; s2<D; ++s2)
139 for (
size_t s3=0; s3<D; ++s3)
140 for (
size_t s4=0; s4<D; ++s4)
142 if (H.
h[s1][s2][s3][s4] != 0.)
144 for (
size_t q2=0; q2<Vin.
data[s2].dim; ++q2)
146 auto A4outs = Symmetry::reduceSilent(Vin.
data[s2].out[q2], H.
qloc[s4]);
147 for (
const auto &A4out : A4outs)
150 if (it4 != H.
AR[s4].dict.end())
152 auto A3ins = Symmetry::reduceSilent(H.
AR[s4].out[it4->second], Symmetry::flip(H.
qloc[s3]));
153 for (
const auto &A3in : A3ins)
156 if (it3 != H.
AR[s3].dict.end())
158 Matrix<Scalar,Dynamic,Dynamic> Mtmp;
160 Vin.
data[s2].block[q2],
161 H.
AR[s4].block[it4->second],
162 H.
AR[s3].block[it3->second].adjoint(),
166 if (Mtmp.size() != 0)
169 auto it = Vout.
data[s1].dict.find(quple);
171 if (it != Vout.
data[s1].dict.end())
173 if (Vout.
data[s1].block[it->second].rows() != Mtmp.rows() and
174 Vout.
data[s1].block[it->second].cols() != Mtmp.cols())
176 Vout.
data[s1].block[it->second] = Mtmp;
180 Vout.
data[s1].block[it->second] += Mtmp;
185 cout << termcolor::red <<
"pushback that shouldn't be: PivumpsMatrix1 term 2" << termcolor::reset << endl;
186 Vout.
data[s1].push_back(quple, Mtmp);
197 for (
size_t s=0; s<D; ++s)
203 Vtmp = Vin.
data[s].contract(H.
R);
209template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
218template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
221 size_t D = H.
h.shape()[0];
227 for (
size_t s1=0; s1<D; ++s1)
228 for (
size_t s2=0; s2<D; ++s2)
229 for (
size_t s3=0; s3<D; ++s3)
230 for (
size_t s4=0; s4<D; ++s4)
232 if (H.
h[s1][s2][s3][s4] != 0.)
234 for (
size_t q1=0; q1<H.
AL[s1].dim; ++q1)
236 auto A2outs = Symmetry::reduceSilent(H.
AL[s1].in[q1], H.
qloc[s2]);
237 for (
const auto &A2out : A2outs)
240 auto itC = Vin.
data[0].dict.find(qupleC);
243 if (it2 != H.
AL[s2].dict.end() and itC != Vin.
data[0].dict.end())
245 auto A4outs = Symmetry::reduceSilent(H.
AL[s2].out[it2->second], H.
qloc[s4]);
246 for (
const auto &A4out : A4outs)
249 if (it4 != H.
AR[s4].dict.end())
251 auto A3ins = Symmetry::reduceSilent(H.
AR[s4].out[it4->second], Symmetry::flip(H.
qloc[s3]));
252 for (
const auto &A3in : A3ins)
255 if (it3 != H.
AR[s3].dict.end())
257 Matrix<Scalar,Dynamic,Dynamic> Mtmp;
258 Mtmp = H.
h[s1][s2][s3][s4] *
259 H.
AL[s1].block[q1].adjoint() *
260 H.
AL[s2].block[it2->second] *
261 Vin.
data[0].block[itC->second] *
262 H.
AR[s4].block[it4->second] *
263 H.
AR[s3].block[it3->second].adjoint();
265 if (Mtmp.size() != 0)
268 auto it = Vout.
data[0].dict.find(quple);
270 if (it != Vout.
data[0].dict.end())
272 if (Vout.
data[0].block[it->second].rows() != Mtmp.rows() and
273 Vout.
data[0].block[it->second].cols() != Mtmp.cols())
275 Vout.
data[0].block[it->second] = Mtmp;
279 Vout.
data[0].block[it->second] += Mtmp;
284 cout << termcolor::red <<
"pushback that shouldn't be: HxC term 1" << termcolor::reset << endl;
285 cout <<
"q=" << quple[0] <<
", " << quple[1] << endl;
286 Vout.
data[0].push_back(quple, Mtmp);
301 Vout.
data[0] += Vtmp;
305 Vtmp = Vin.
data[0].contract(H.
R);
306 Vout.
data[0] += Vtmp;
310template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
318template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
325template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
331template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
338template<
typename Symmetry,
typename Scalar,
typename MpoScalar>
void optimal_multiply(Scalar alpha, const MatrixTypeA &A, const MatrixTypeB &B, const MatrixTypeC &C, MatrixTypeR &result, bool DEBUG=false)
double norm(const PivumpsMatrix1< Symmetry, Scalar, MpoScalar > &H)
void HxV(const PivumpsMatrix1< Symmetry, Scalar, MpoScalar > &H, const PivotVector< Symmetry, Scalar > &Vin, PivotVector< Symmetry, Scalar > &Vout)
size_t dim(const PivumpsMatrix1< Symmetry, Scalar, MpoScalar > &H)
std::array< qarray< Nq >, 2 > qarray2
Biped< Symmetry, MatrixType_ > contract(const Biped< Symmetry, MatrixType_ > &A, const contract::MODE MODE=contract::MODE::UNITY) const
void outerResize(const PivotVector &Vrhs)
vector< Biped< Symmetry, Matrix< Scalar_, Dynamic, Dynamic > > > data
vector< Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > > AR
boost::multi_array< MpoScalar, 4 > h
vector< Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > > AL
PivumpsMatrix0(const PivumpsMatrix1< Symmetry, Scalar, MpoScalar > &H)
vector< qarray< Symmetry::Nq > > qloc
Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > R
Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > L
vector< Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > > AR
Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > R
Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > L
boost::multi_array< MpoScalar, 4 > h
vector< Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > > AL
vector< qarray< Symmetry::Nq > > qloc