1#ifndef VUMPSLINEARALGEBRA
2#define VUMPSLINEARALGEBRA
7template<
typename Symmetry,
typename MpoScalar>
18 B.setIdentity(Obs.inBasis(0).inner_dim(Symmetry::qvacuum()), 1, V.
inBasis(0));
19 for (
size_t l=0; l<Obs.length(); ++l)
27 return contract_LR(std::make_pair(Symmetry::qvacuum(),0ul),
B.template cast<Matrix<complex<double>,Dynamic,Dynamic> >(), Teigen);
30template<
typename Symmetry,
typename MpoScalar>
41 B.setIdentity(Obs.outBasis(Obs.length()-1).inner_dim(Symmetry::qvacuum()), 1, V.
outBasis((Obs.length()-1)%V.
length()));
42 for (
size_t l=0; l<Obs.length(); ++l)
45 contract_R(
B, V.
A_at(g,l), Obs.W_at(l), V.
A_at(g,l), Obs.locBasis(l), Obs.opBasis(l), Bnext);
51 return contract_LR(std::make_pair(Symmetry::qvacuum(),0ul), Teigen,
B.template cast<Matrix<complex<double>,Dynamic,Dynamic> >());
55template<
typename Symmetry,
typename MpoScalar,
typename Scalar>
66 if (Obs.length() != Vket.
length() and Vket.
Qtarget() != Symmetry::qvacuum())
68 assert(Obs.length()%Vket.
length() == 0);
69 Ncells =
static_cast<size_t>(Obs.length()/Vket.
length());
71 Obs.transform_base(transformed_Qtot,
false);
75 Obs.transform_base(Vket.
Qtarget(),
false);
78 if (Obs.length() != Vket.
length() and Vket.
Qtarget() != Symmetry::qvacuum())
80 auto Vbra_copy = Vbra;
81 auto Vket_copy = Vket;
84 Vket_copy.adjustQN(Ncells);
86 B.setIdentity(Obs.inBasis(0).inner_dim(Symmetry::qvacuum()), 1, Vket_copy.inBasis(0));
87 for (
size_t l=0; l<Obs.length(); ++l)
91 Vbra_copy.A_at(g,l%Vket.
length()), Obs.W_at(l),
92 Vket_copy.A_at(g,l%Vket.
length()), Obs.locBasis(l), Obs.opBasis(l), Bnext);
98 IdR.
setIdentity(Obs.outBasis(Obs.length()-1).inner_dim(Symmetry::qvacuum()), 1, Vket_copy.outBasis((Obs.length()-1)%Vket.
length()));
102 B.setIdentity(Obs.inBasis(0).inner_dim(Symmetry::qvacuum()), 1, Vket.
inBasis(0));
103 for (
size_t l=0; l<Obs.length(); ++l)
108 Vket.
A_at(g,l%Vket.
length()), Obs.locBasis(l), Obs.opBasis(l), Bnext);
114 IdR.
setIdentity(Obs.outBasis(Obs.length()-1).inner_dim(Symmetry::qvacuum()), 1, Vket.
outBasis((Obs.length()-1)%Vket.
length()));
159template<
typename Symmetry,
typename MpoScalar,
typename Scalar>
172 if (Obs1.length() != Vket.
length() and Vket.
Qtarget() != Symmetry::qvacuum())
174 assert(Obs1.length()%Vket.
length() == 0);
175 Ncells =
static_cast<size_t>(Obs1.length()/Vket.
length());
177 Obs1.transform_base(transformed_Qtot,
false);
178 Obs2.transform_base(transformed_Qtot,
false);
182 Obs1.transform_base(Vket.
Qtarget(),
false);
183 Obs2.transform_base(Vket.
Qtarget(),
false);
186 if (Obs1.length() != Vket.
length() and Vket.
Qtarget() != Symmetry::qvacuum())
188 auto Vbra_copy = Vbra;
189 auto Vket_copy = Vket;
192 Vket_copy.adjustQN(Ncells);
194 B.setIdentity(Obs1.outBasis(Obs1.length()-1).inner_dim(Symmetry::qvacuum()), 1, Vket_copy.outBasis((Obs1.length()-1)%Vket.
length()));
195 for (
size_t l=O1.
length()-1; l!=-1; --l)
200 Vbra_copy.A_at(g,l%Vket.
length()), Obs1.W_at(l), Obs2.W_at(l), Vket_copy.A_at(g,l%Vket.
length()),
201 Obs1.locBasis(l), Obs1.opBasis(l), Obs2.opBasis(l),
207 IdL.
setIdentity(Obs1.inBasis(0).inner_dim(Symmetry::qvacuum()), 1, Vket_copy.inBasis(0));
211 B.setIdentity(Obs1.outBasis(Obs1.length()-1).inner_dim(Symmetry::qvacuum()), 1, Vket.
outBasis((Obs1.length()-1)%Vket.
length()));
212 for (
size_t l=O1.
length()-1; l!=-1; --l)
218 Obs1.locBasis(l), Obs1.opBasis(l), Obs2.opBasis(l),
231template<
typename Symmetry,
typename MpoScalar,
typename Scalar>
238 for (
int t=0; t<O.size(); ++t)
241 out +=
avg(Vbra,O[t],Vket);
246template<
typename Symmetry,
typename MpoScalar,
typename Scalar>
254 for (
int i=0; i<O1.size(); ++i)
255 for (
int j=0; j<O2.size(); ++j)
257 cout <<
"partial val=" <<
avg(Vbra, O1[i], O2[j], Vket) << endl;
258 out +=
avg(Vbra, O1[i], O2[j], Vket);
complex< double > calc_formfactor_R(const Biped< Symmetry, Matrix< complex< double >, Dynamic, Dynamic > > &Teigen, const Mpo< Symmetry, MpoScalar > &O, const Umps< Symmetry, double > &V)
Scalar avg(const Umps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O, const Umps< Symmetry, Scalar > &Vket)
complex< double > calc_formfactor_L(const Biped< Symmetry, Matrix< complex< double >, Dynamic, Dynamic > > &Teigen, const Mpo< Symmetry, MpoScalar > &O, const Umps< Symmetry, double > &V)
void transform_base(const qType &qShift, const bool PRINT=false, const int factor=-1, const std::size_t powre=0ul)
std::size_t length() const
const vector< Biped< Symmetry, MatrixType > > & A_at(GAUGE::OPTION g, size_t loc) const
Qbasis< Symmetry > inBasis(size_t loc) const
qarray< Nq > Qtarget() const
Qbasis< Symmetry > outBasis(size_t loc) const
void adjustQN(const size_t number_cells)
void contract_R(const Tripod< Symmetry, MatrixType2 > &Rold, const vector< Biped< Symmetry, MatrixType > > &Abra, const vector< vector< vector< Biped< Symmetry, MpoMatrixType > > > > &W, const vector< Biped< Symmetry, MatrixType > > &Aket, const vector< qarray< Symmetry::Nq > > &qloc, const vector< qarray< Symmetry::Nq > > &qOp, Tripod< Symmetry, MatrixType2 > &Rnew, bool RANDOMIZE=false, tuple< CONTRACT_LR_MODE, size_t > MODE_input=make_pair(FULL, 0), const std::unordered_map< pair< qarray< Symmetry::Nq >, size_t >, size_t > &basis_order_map={})
void contract_L(const Tripod< Symmetry, MatrixType2 > &Lold, const vector< Biped< Symmetry, MatrixType > > &Abra, const vector< vector< vector< Biped< Symmetry, MpoMatrixType > > > > &W, const vector< Biped< Symmetry, MatrixType > > &Aket, const vector< qarray< Symmetry::Nq > > &qloc, const vector< qarray< Symmetry::Nq > > &qOp, Tripod< Symmetry, MatrixType2 > &Lnew, bool RANDOMIZE=false, tuple< CONTRACT_LR_MODE, size_t > MODE_input=make_pair(FULL, 0), const std::unordered_map< pair< qarray< Symmetry::Nq >, size_t >, size_t > &basis_order_map={})
Scalar contract_LR(const Tripod< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > &L, const vector< Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > > &Abra, const vector< vector< vector< Biped< Symmetry, MpoMatrixType > > > > &W, const vector< Biped< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > > &Aket, const Tripod< Symmetry, Matrix< Scalar, Dynamic, Dynamic > > &R, const vector< qarray< Symmetry::Nq > > &qloc, const vector< qarray< Symmetry::Nq > > &qOp)
void setIdentity(size_t Drows, size_t Dcols, size_t amax=1, size_t bmax=1)