1#ifndef SPINLESSFERMIONSOBSERVABLES
2#define SPINLESSFERMIONSOBSERVABLES
4#include "bases/SpinlessFermionBase.h"
6#include "ParamHandler.h"
8template<
typename Symmetry,
typename Scalar=
double>
44 size_t locx1,
size_t locx2,
size_t locy1,
size_t locy2,
46 bool BOTH_HERMITIAN=
false)
const;
48 vector<SpinlessFermionBase<Symmetry> >
F;
51template<
typename Symmetry,
typename Scalar>
58template<
typename Symmetry,
typename Scalar>
62 ParamHandler P(params,defaults);
63 size_t Lcell = P.size();
66 for (
size_t l=0; l<L; ++l)
74template<
typename Symmetry,
typename Scalar>
76make_local (
size_t locx,
size_t locy,
const OperatorType &Op,
double factor,
bool FERMIONIC,
bool HERMITIAN)
const
78 assert(locx<F.size() and locy<F[locx].dim());
80 ss << Op.
label() <<
"(" << locx <<
"," << locy;
81 if (factor != 1.) ss <<
",factor=" << factor;
85 for (
size_t l=0; l<F.size(); ++l) Mout.
setLocBasis(F[l].get_basis().qloc(),l);
89 vector<SiteOperator<Symmetry,Scalar> > Signs(locx);
90 for (
size_t l=0; l<locx; ++l) {Signs[l] = F[l].sign().template plain<double>().template cast<Scalar>();}
92 Mout.
setLocal(locx, (factor * Op).
template plain<double>().
template cast<Scalar>(), Signs);
96 Mout.
setLocal(locx, (factor * Op).
template plain<double>().
template cast<Scalar>());
102template<
typename Symmetry,
typename Scalar>
105 size_t locx1,
size_t locx2,
size_t locy1,
size_t locy2,
107 bool BOTH_HERMITIAN)
const
109 assert(locx1<F.size() and locx2<F.size() and locy1<F[locx1].dim() and locy2<F[locx2].dim());
111 ss << name1 <<
"(" << locx1 <<
"," << locy1 <<
")"
112 << name2 <<
"(" << locx2 <<
"," << locy2 <<
")";
114 bool HERMITIAN = (BOTH_HERMITIAN and locx1==locx2 and locy1==locy2)?
true:
false;
117 for (
size_t l=0; l<F.size(); ++l) {Mout.
setLocBasis(F[l].get_basis(),l);}
119 Mout.
setLocal({locx1,locx2}, {Op1,Op2});
125template<
typename Symmetry,
typename Scalar>
127c (
size_t locx,
size_t locy)
const
129 return make_local(locx,locy, F[locx].c(locy), 1.,
true);
132template<
typename Symmetry,
typename Scalar>
134cdag (
size_t locx,
size_t locy)
const
136 return make_local(locx,locy, F[locx].cdag(locy), 1.,
true);
147template<
typename Symmetry,
typename Scalar>
149n (
size_t locx,
size_t locy)
const
151 return make_local(locx,locy, F[locx].n(locy), 1.,
false,
true);
154template<
typename Symmetry,
typename Scalar>
156nph (
size_t locx,
size_t locy)
const
158 return make_local(locx,locy, F[locx].nph(locy), 1.,
false,
true);
201template<
typename Symmetry,
typename Scalar>
203nn (
size_t locx1,
size_t locx2,
size_t locy1,
size_t locy2)
const
205 return make_corr (
"n",
"n", locx1,locx2,locy1,locy2, F[locx1].n(locy1), F[locx2].n(locy2),
true);
void setLocBasis(const std::vector< std::vector< qType > > &q)
void setLocal(std::size_t loc, const OperatorType &op)
Mpo< Symmetry, Scalar > n(size_t locx, size_t locy=0) const
SpinlessFermionsObservables(const size_t &L)
SpinlessFermionsObservables()
vector< SpinlessFermionBase< Symmetry > > F
Mpo< Symmetry, Scalar > c(size_t locx, size_t locy=0) const
Mpo< Symmetry, Scalar > nn(size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0) const
Mpo< Symmetry, Scalar > cdag(size_t locx, size_t locy=0) const
Mpo< Symmetry, Scalar > make_corr(string name1, string name2, size_t locx1, size_t locx2, size_t locy1, size_t locy2, const OperatorType &Op1, const OperatorType &Op2, bool BOTH_HERMITIAN=false) const
Mpo< Symmetry, Scalar > make_local(size_t locx, size_t locy, const OperatorType &Op, double factor, bool FERMIONIC=false, bool HERMITIAN=false) const
SpinlessFermionsObservables(const size_t &L, const vector< Param > ¶ms, const std::map< string, std::any > &defaults)
SiteOperatorQ< Symmetry, Eigen::MatrixXd > OperatorType
Mpo< Symmetry, Scalar > nph(size_t locx, size_t locy=0) const