28 #ifndef MEASUREMENTS_LOCAL_AT_H
29 #define MEASUREMENTS_LOCAL_AT_H
34 namespace measurements {
36 template <
class Matrix,
class SymmGroup>
39 typedef std::size_t size_type;
40 typedef std::vector<block_matrix<Matrix, SymmGroup> > op_vec;
41 typedef std::vector<std::vector<size_type> > positions_type;
45 positions_type
const& positions_,
46 op_vec
const & identities_, op_vec
const & fillings_,
47 std::vector<std::pair<op_vec, bool> >
const& ops_)
50 , positions(positions_)
51 , identities(identities_)
63 for (std::size_t p = 0; p < positions.size(); ++p)
65 assert( positions[p].size() == ops.size() );
66 for (std::size_t i=1; i<ops.size(); ++i)
67 if (positions[p][i-1] >= positions[p][i])
68 throw std::runtime_error(
"measure_local_at requires i1<i2<...<in.");
73 bool with_sign =
false;
74 for (std::size_t i=0; i<ops.size(); ++i) {
75 std::size_t pos = positions[p][i];
82 if (!with_sign && ops[i].second)
gemm(fill, op, tmp);
84 hterm.
operators.push_back( std::make_pair(pos, tmp) );
87 with_sign = (ops[i].second) ? !with_sign : with_sign;
88 if (i != ops.size()-1)
89 for (; pos<positions[p][i+1]; ++pos) {
92 hterm.
operators.push_back( std::make_pair(pos, (with_sign) ? fill : ident) );
121 positions_type positions;
122 op_vec identities, fillings;
123 std::vector<std::pair<op_vec, bool> > ops;
std::vector< std::string > labels
double expval(MPS< Matrix, SymmGroup > const &mps, MPO< Matrix, SymmGroup > const &mpo, int d)
std::vector< std::string > label_strings(const Lattice &lat, const std::vector< std::vector< std::size_t > > &labels)
void evaluate(MPS< Matrix, SymmGroup > const &mps, boost::optional< reduced_mps< Matrix, SymmGroup > const & > rmps=boost::none)
local_at(std::string const &name_, const Lattice &lat, positions_type const &positions_, op_vec const &identities_, op_vec const &fillings_, std::vector< std::pair< op_vec, bool > > const &ops_)
measurement< Matrix, SymmGroup > * do_clone() const
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
definition of Measurement base class
MPS< Matrix, SymmGroup >::scalar_type overlap(MPS< Matrix, SymmGroup > const &mps1, MPS< Matrix, SymmGroup > const &mps2)
T get_prop(std::string property, pos_t site) const
MPSTensor< Matrix, SymmGroup >::scalar_type scalar_type
std::vector< op_pair_t > operators
MPS< Matrix, SymmGroup > mpo_to_smps(MPO< Matrix, SymmGroup > const &mpo, Index< SymmGroup > const &phys_i)
functions to operate on MPS and MPO (compute expectation values, etc.)
void add_term(Operator_Term< Matrix, SymmGroup > const &term)
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
MPO< Matrix, SymmGroup > create_mpo()
Index< SymmGroup > phys_psi
MPS< Matrix, SymmGroup >::scalar_type dm_trace(MPS< Matrix, SymmGroup > const &mps, Index< SymmGroup > const &phys_psi)