ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
measurements::local_at< Matrix, SymmGroup > Class Template Reference

#include <local_at.h>

Inheritance diagram for measurements::local_at< Matrix, SymmGroup >:
measurement< Matrix, SymmGroup >

Public Types

typedef Matrix::value_type value_type
 

Public Member Functions

 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_)
 
void evaluate (MPS< Matrix, SymmGroup > const &mps, boost::optional< reduced_mps< Matrix, SymmGroup > const & > rmps=boost::none)
 
template<class Archive >
void save (Archive &) const
 
void write_xml (alps::oxstream &) const
 
virtual void print (std::ostream &os) const
 
std::string const & name () const
 
int & eigenstate_index ()
 
int eigenstate_index () const
 
void set_super_meas (Index< SymmGroup > const &phys_psi_)
 
measurementclone () const
 

Protected Member Functions

measurement< Matrix, SymmGroup > * do_clone () const
 

Protected Attributes

bool cast_to_real
 
bool is_super_meas
 
std::vector< std::string > labels
 
value_type result
 
std::vector< typename MPS
< Matrix, SymmGroup >
::scalar_type > 
vector_results
 
Index< SymmGroup > phys_psi
 

Detailed Description

template<class Matrix, class SymmGroup>
class measurements::local_at< Matrix, SymmGroup >

Definition at line 37 of file local_at.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef Matrix::value_type measurement< Matrix, SymmGroup >::value_type
inherited

Definition at line 55 of file measurement.h.

Constructor & Destructor Documentation

template<class Matrix , class SymmGroup >
measurements::local_at< Matrix, SymmGroup >::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_ 
)
inline

Definition at line 44 of file local_at.h.

48  : base(name_)
49  , lattice(lat)
50  , positions(positions_)
51  , identities(identities_)
52  , fillings(fillings_)
53  , ops(ops_)
54  {
55  this->labels = label_strings(lattice, positions);
56  this->cast_to_real = false;
57  }
std::vector< std::string > labels
Definition: measurement.h:78
std::vector< std::string > label_strings(const Lattice &lat, const std::vector< std::vector< std::size_t > > &labels)
Definition: measurement.h:190
bool cast_to_real
Definition: measurement.h:77

Member Function Documentation

template<class Matrix, class SymmGroup>
measurement* measurement< Matrix, SymmGroup >::clone ( ) const
inlineinherited

Definition at line 72 of file measurement.h.

72 { return do_clone(); }
virtual measurement * do_clone() const =0
template<class Matrix , class SymmGroup >
measurement<Matrix, SymmGroup>* measurements::local_at< Matrix, SymmGroup >::do_clone ( ) const
inlineprotectedvirtual

Implements measurement< Matrix, SymmGroup >.

Definition at line 114 of file local_at.h.

115  {
116  return new local_at(*this);
117  }
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_)
Definition: local_at.h:44
template<class Matrix, class SymmGroup>
int& measurement< Matrix, SymmGroup >::eigenstate_index ( )
inlineinherited

Definition at line 67 of file measurement.h.

67 { return eigenstate; }
template<class Matrix, class SymmGroup>
int measurement< Matrix, SymmGroup >::eigenstate_index ( ) const
inlineinherited

Definition at line 68 of file measurement.h.

68 { return eigenstate; }
template<class Matrix , class SymmGroup >
void measurements::local_at< Matrix, SymmGroup >::evaluate ( MPS< Matrix, SymmGroup > const &  mps,
boost::optional< reduced_mps< Matrix, SymmGroup > const & >  rmps = boost::none 
)
inlinevirtual

Implements measurement< Matrix, SymmGroup >.

Definition at line 59 of file local_at.h.

60  {
61  this->vector_results.clear();
62  this->vector_results.reserve(positions.size());
63  for (std::size_t p = 0; p < positions.size(); ++p)
64  {
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.");
69 
70  generate_mpo::MPOMaker<Matrix, SymmGroup> mpom(lattice, identities, fillings);
72 
73  bool with_sign = false;
74  for (std::size_t i=0; i<ops.size(); ++i) {
75  std::size_t pos = positions[p][i];
76 
77  block_matrix<Matrix, SymmGroup> const& fill = fillings[lattice.get_prop<int>("type", pos)];
78  block_matrix<Matrix, SymmGroup> const& op = ops[i].first[lattice.get_prop<int>("type", pos)];
79 
81  op_t tmp;
82  if (!with_sign && ops[i].second) gemm(fill, op, tmp);
83  else tmp = op;
84  hterm.operators.push_back( std::make_pair(pos, tmp) );
85 
86  pos++;
87  with_sign = (ops[i].second) ? !with_sign : with_sign;
88  if (i != ops.size()-1)
89  for (; pos<positions[p][i+1]; ++pos) {
90  block_matrix<Matrix, SymmGroup> const& fill = fillings[lattice.get_prop<int>("type", pos)];
91  block_matrix<Matrix, SymmGroup> const& ident = identities[lattice.get_prop<int>("type", pos)];
92  hterm.operators.push_back( std::make_pair(pos, (with_sign) ? fill : ident) );
93  }
94  }
95  hterm.with_sign = false; // filling already taken care above
96  mpom.add_term(hterm);
97  MPO<Matrix, SymmGroup> mpo = mpom.create_mpo();
98 
99  if (!this->is_super_meas){
100  typename MPS<Matrix, SymmGroup>::scalar_type val = expval(mps, mpo);
101  this->vector_results.push_back(val);
102  } else {
103  typename MPS<Matrix, SymmGroup>::scalar_type nn = dm_trace(mps, this->phys_psi);
104  MPS<Matrix, SymmGroup> super_mpo = mpo_to_smps(mpo, this->phys_psi);
105  // static_cast needed for icpc 12.x
106  typedef typename MPS<Matrix, SymmGroup>::scalar_type (*overlap_func)(MPS<Matrix, SymmGroup> const &, MPS<Matrix, SymmGroup> const &);
107  typename MPS<Matrix, SymmGroup>::scalar_type val = ::overlap(super_mpo, mps);
108  this->vector_results.push_back(val/nn);
109  }
110  }
111  }
double expval(MPS< Matrix, SymmGroup > const &mps, MPO< Matrix, SymmGroup > const &mpo, int d)
Definition: mps_mpo_ops.h:72
bool is_super_meas
Definition: measurement.h:77
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
Definition: measurement.h:80
Definition: mpo.h:36
MPS< Matrix, SymmGroup >::scalar_type overlap(MPS< Matrix, SymmGroup > const &mps1, MPS< Matrix, SymmGroup > const &mps2)
Definition: mps_mpo_ops.h:136
Definition: mps.h:40
T get_prop(std::string property, pos_t site) const
Definition: lattice.h:103
MPSTensor< Matrix, SymmGroup >::scalar_type scalar_type
Definition: mps.h:51
std::vector< op_pair_t > operators
Definition: utils.hpp:118
MPS< Matrix, SymmGroup > mpo_to_smps(MPO< Matrix, SymmGroup > const &mpo, Index< SymmGroup > const &phys_i)
Definition: super_mpo.h:60
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
Index< SymmGroup > phys_psi
Definition: measurement.h:82
MPS< Matrix, SymmGroup >::scalar_type dm_trace(MPS< Matrix, SymmGroup > const &mps, Index< SymmGroup > const &phys_psi)
Definition: mps_mpo_ops.h:258
template<class Matrix, class SymmGroup>
std::string const& measurement< Matrix, SymmGroup >::name ( ) const
inlineinherited

Definition at line 66 of file measurement.h.

66 { return name_; }
template<class Matrix , class SymmGroup >
void measurement< Matrix, SymmGroup >::print ( std::ostream &  os) const
virtualinherited

Definition at line 160 of file measurement.h.

161 {
162  os << "MEASURE[" << name_ << "]";
163 }
template<class Matrix , class SymmGroup >
template<class Archive >
void measurement< Matrix, SymmGroup >::save ( Archive &  ar) const
inherited

Definition at line 107 of file measurement.h.

108 {
109  if (vector_results.size() > 0) {
110  if (cast_to_real) {
111  save_val_at_index(ar, storage::encode(name()) + std::string("/mean/value"), maquis::real(vector_results), eigenstate_index());
112  } else {
113  save_val_at_index(ar, storage::encode(name()) + std::string("/mean/value"), vector_results, eigenstate_index());
114  }
115  if (labels.size() > 0)
116  ar[storage::encode(name()) + std::string("/labels")] << labels;
117  } else {
118  if (cast_to_real) {
119  save_val_at_index(ar, storage::encode(name()) + std::string("/mean/value"), maquis::real(result), eigenstate_index());
120  } else {
121  save_val_at_index(ar, storage::encode(name()) + std::string("/mean/value"), result, eigenstate_index());
122  }
123  }
124 }
std::vector< std::string > labels
Definition: measurement.h:78
value_type result
Definition: measurement.h:79
std::string encode(std::string const &s)
Definition: archive.h:82
void save_val_at_index(Archive &ar, std::string const &archive_path, T const &val, std::size_t eig)
Definition: measurement.h:96
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
Definition: measurement.h:80
int & eigenstate_index()
Definition: measurement.h:67
bool cast_to_real
Definition: measurement.h:77
alps::numeric::real_type< T >::type real(T f)
Definition: bindings.hpp:38
std::string const & name() const
Definition: measurement.h:66
template<class Matrix , class SymmGroup >
void measurement< Matrix, SymmGroup >::set_super_meas ( Index< SymmGroup > const &  phys_psi_)
inherited

Definition at line 153 of file measurement.h.

154 {
155  phys_psi = phys_psi_;
156  is_super_meas = true;
157 }
bool is_super_meas
Definition: measurement.h:77
Index< SymmGroup > phys_psi
Definition: measurement.h:82
template<class Matrix , class SymmGroup >
void measurement< Matrix, SymmGroup >::write_xml ( alps::oxstream &  out) const
inherited

Definition at line 127 of file measurement.h.

128 {
129  if (labels.size() > 0) {
130  out << alps::start_tag("VECTOR_AVERAGE") << alps::attribute("name", name());
131  for (int i=0; i<labels.size(); ++i) {
132  out << alps::start_tag("SCALAR_AVERAGE");
133  out << alps::attribute("indexvalue",labels[i]) << alps::no_linebreak;
134 
135  if (cast_to_real) {
136  out << alps::start_tag("MEAN") << alps::no_linebreak << maquis::real(vector_results[i]) << alps::end_tag("MEAN");
137  } else {
138  out << alps::start_tag("MEAN") << alps::no_linebreak << vector_results[i] << alps::end_tag("MEAN");
139  }
140  out << alps::end_tag("SCALAR_AVERAGE");
141 
142  }
143  out << alps::end_tag("VECTOR_AVERAGE");
144  } else {
145  out << alps::start_tag("SCALAR_AVERAGE") << alps::attribute("name", name()) << alps::no_linebreak;
146  out << alps::start_tag("MEAN") << alps::no_linebreak << ((cast_to_real) ? maquis::real(result) : result) << alps::end_tag("MEAN");
147  out << alps::end_tag("SCALAR_AVERAGE");
148  }
149 }
std::vector< std::string > labels
Definition: measurement.h:78
value_type result
Definition: measurement.h:79
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
Definition: measurement.h:80
bool cast_to_real
Definition: measurement.h:77
alps::numeric::real_type< T >::type real(T f)
Definition: bindings.hpp:38
std::string const & name() const
Definition: measurement.h:66

Member Data Documentation

template<class Matrix, class SymmGroup>
bool measurement< Matrix, SymmGroup >::cast_to_real
protectedinherited

Definition at line 77 of file measurement.h.

template<class Matrix, class SymmGroup>
bool measurement< Matrix, SymmGroup >::is_super_meas
protectedinherited

Definition at line 77 of file measurement.h.

template<class Matrix, class SymmGroup>
std::vector<std::string> measurement< Matrix, SymmGroup >::labels
protectedinherited

Definition at line 78 of file measurement.h.

template<class Matrix, class SymmGroup>
Index<SymmGroup> measurement< Matrix, SymmGroup >::phys_psi
protectedinherited

Definition at line 82 of file measurement.h.

template<class Matrix, class SymmGroup>
value_type measurement< Matrix, SymmGroup >::result
protectedinherited

Definition at line 79 of file measurement.h.

template<class Matrix, class SymmGroup>
std::vector<typename MPS<Matrix, SymmGroup>::scalar_type> measurement< Matrix, SymmGroup >::vector_results
protectedinherited

Definition at line 80 of file measurement.h.


The documentation for this class was generated from the following file: