28 #ifndef MEASUREMENTS_LOCAL_H
29 #define MEASUREMENTS_LOCAL_H
36 namespace measurements {
38 template <
class Matrix,
class SymmGroup>
42 typedef std::vector<block_matrix<Matrix, SymmGroup> > op_vec;
43 typedef std::vector<std::pair<op_vec, bool> > bond_element;
47 op_vec
const & identities_, op_vec
const & fillings_,
48 std::vector<bond_element>
const& terms)
51 , identities(identities_)
60 op_vec
const & identities_, op_vec
const & fillings_,
64 , identities(identities_)
68 , mpo_terms(std::vector<bond_element>(1, bond_element(1, std::make_pair(op, false)) ))
78 typedef typename SymmGroup::subcharge subcharge;
87 subcharge type = lattice.
get_prop<subcharge>(
"type", p);
88 typename Matrix::value_type res = 0.;
89 bool evaluated =
false;
90 if (site_term[type].n_blocks() > 0) {
92 temp.
set(0, 0, site_term[type]);
95 res += mps[p].scalar_overlap(vec2);
100 this->
labels.push_back( lattice.
get_prop<std::string>(
"label", p) );
108 return new local(*
this);
113 typedef typename SymmGroup::subcharge subcharge;
114 typedef std::map<std::string, typename Matrix::value_type> result_type;
122 for (
typename std::vector<bond_element>::const_iterator it = mpo_terms.begin(); it != mpo_terms.end(); ++it) {
123 typedef std::map<std::string, MPO<Matrix, SymmGroup> > mpo_map;
127 for (
typename mpo_map::const_iterator mit = mpos.begin(); mit != mpos.end(); ++mit) {
128 typename result_type::iterator match = res.find(mit->first);
129 if (match == res.end())
130 boost::tie(match, boost::tuples::ignore) = res.insert( std::make_pair(mit->first, 0.) );
133 match->second +=
expval(mps, mit->second);
139 match->second += val/nn;
147 for (
typename result_type::const_iterator it = res.begin(); it != res.end(); ++it) {
148 this->
labels.push_back(it->first);
155 op_vec identities, fillings;
158 std::vector<bond_element> mpo_terms;
void set(index_type li, index_type ri, op_t const &op, value_type scale_=1.0)
void evaluate_with_mpo(MPS< Matrix, SymmGroup > const &mps)
std::vector< std::string > labels
double expval(MPS< Matrix, SymmGroup > const &mps, MPO< Matrix, SymmGroup > const &mpo, int d)
bool all_true(InputIterator first, InputIterator last, Predicate pred)
static MPSTensor< Matrix, SymmGroup > site_hamil2(MPSTensor< Matrix, SymmGroup > ket_tensor, Boundary< OtherMatrix, SymmGroup > const &left, Boundary< OtherMatrix, SymmGroup > const &right, MPOTensor< Matrix, SymmGroup > const &mpo)
measurement< Matrix, SymmGroup > * do_clone() const
std::map< std::string, MPO< Matrix, SymmGroup > > local(const Lattice &lat, std::vector< block_matrix< Matrix, SymmGroup > > const &identities, std::vector< block_matrix< Matrix, SymmGroup > > const &fillings, std::vector< std::pair< std::vector< block_matrix< Matrix, SymmGroup > >, bool > > const &ops)
void evaluate(MPS< Matrix, SymmGroup > const &mps, boost::optional< reduced_mps< Matrix, SymmGroup > const & > rmps=boost::none)
local(std::string const &name_, const Lattice &lat, op_vec const &identities_, op_vec const &fillings_, std::vector< bond_element > const &terms)
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
definition of Measurement base class
bool is_hermitian_meas(std::vector< block_matrix< Matrix, SymmGroup > > const &ops)
UTILITIES.
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
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.)
Index< SymmGroup > phys_psi
local(std::string const &name_, const Lattice &lat, op_vec const &identities_, op_vec const &fillings_, op_vec const &op)
functions to prepare MPO objects needed in measurements
MPS< Matrix, SymmGroup >::scalar_type dm_trace(MPS< Matrix, SymmGroup > const &mps, Index< SymmGroup > const &phys_psi)