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::correlations< Matrix, SymmGroup > Class Template Reference

#include <correlations.h>

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

Public Types

typedef Matrix::value_type value_type
 

Public Member Functions

 correlations (std::string const &name_, const Lattice &lat, op_vec const &identities_, op_vec const &fillings_, std::vector< std::pair< op_vec, bool > > const &ops_, bool half_only_, bool nearest_neighbors_only, positions_type const &positions_=positions_type())
 
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
 
void measure_correlation (MPS< Matrix, SymmGroup > const &mps, std::vector< std::pair< op_vec, bool > > const &ops, std::vector< size_type > const &order=std::vector< size_type >())
 

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::correlations< Matrix, SymmGroup >

Definition at line 129 of file correlations.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::correlations< Matrix, SymmGroup >::correlations ( std::string const &  name_,
const Lattice lat,
op_vec const &  identities_,
op_vec const &  fillings_,
std::vector< std::pair< op_vec, bool > > const &  ops_,
bool  half_only_,
bool  nearest_neighbors_only,
positions_type const &  positions_ = positions_type() 
)
inline

Definition at line 136 of file correlations.h.

141  : base(name_)
142  , lattice(lat)
143  , positions_first(positions_)
144  , identities(identities_)
145  , fillings(fillings_)
146  , ops(ops_)
147  , half_only(half_only_)
148  , is_nn(nearest_neighbors_only)
149  {
150  if (positions_first.size() == 0)
151  std::copy(boost::counting_iterator<int>(0), boost::counting_iterator<int>(lattice.size()-(ops.size()-1)),
152  back_inserter(positions_first));
153 
154  this->cast_to_real = is_hermitian_meas(ops);
155  }
bool is_hermitian_meas(std::vector< block_matrix< Matrix, SymmGroup > > const &ops)
UTILITIES.
Definition: measurement.h:175
bool cast_to_real
Definition: measurement.h:77
pos_t size() const
Definition: lattice.h:115

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::correlations< Matrix, SymmGroup >::do_clone ( ) const
inlineprotectedvirtual

Implements measurement< Matrix, SymmGroup >.

Definition at line 173 of file correlations.h.

174  {
175  return new correlations(*this);
176  }
correlations(std::string const &name_, const Lattice &lat, op_vec const &identities_, op_vec const &fillings_, std::vector< std::pair< op_vec, bool > > const &ops_, bool half_only_, bool nearest_neighbors_only, positions_type const &positions_=positions_type())
Definition: correlations.h:136
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::correlations< 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 157 of file correlations.h.

158  {
159  this->vector_results.clear();
160  this->labels.clear();
161 
162  if (half_only) {
163  measure_correlation(mps, ops);
164  } else {
165  detail::CorrPermutator<Matrix, SymmGroup> perm(ops, is_nn);
166  for (int i=0; i<perm.size(); ++i) {
167  measure_correlation(mps, perm[i], perm.order(i));
168  }
169  }
170  }
std::vector< std::string > labels
Definition: measurement.h:78
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
Definition: measurement.h:80
void measure_correlation(MPS< Matrix, SymmGroup > const &mps, std::vector< std::pair< op_vec, bool > > const &ops, std::vector< size_type > const &order=std::vector< size_type >())
Definition: correlations.h:178
template<class Matrix , class SymmGroup >
void measurements::correlations< Matrix, SymmGroup >::measure_correlation ( MPS< Matrix, SymmGroup > const &  mps,
std::vector< std::pair< op_vec, bool > > const &  ops,
std::vector< size_type > const &  order = std::vector<size_type>() 
)
inlineprotected

Definition at line 178 of file correlations.h.

181  {
182  typedef boost::shared_ptr<generate_mpo::CorrMakerBase<Matrix, SymmGroup> > maker_ptr;
183 
184  for (std::vector<std::size_t>::const_iterator it = positions_first.begin(); it != positions_first.end(); ++it) {
185  if (*it >= lattice.size()-(ops.size()-1))
186  throw std::runtime_error("cannot measure correlation with first operator at p="+boost::lexical_cast<std::string>(*it)+".");
187  #ifndef NDEBUG
188  maquis::cout << " site " << *it << std::endl;
189  #endif
190 
191  /// initialize correct maker
192  maker_ptr dcorr;
193  if (is_nn) dcorr.reset(new generate_mpo::CorrMakerNN<Matrix, SymmGroup>(lattice, identities, fillings, ops, *it) );
194  else dcorr.reset(new generate_mpo::CorrMaker<Matrix, SymmGroup>(lattice, identities, fillings, ops, *it) );
195 
196  /// measure
197  MPO<Matrix, SymmGroup> mpo = dcorr->create_mpo();
198  std::vector<typename MPS<Matrix, SymmGroup>::scalar_type> dct;
199  if (!this->is_super_meas)
200  dct = multi_expval(mps, mpo);
201  else {
202  typename MPS<Matrix, SymmGroup>::scalar_type nn = dm_trace(mps, this->phys_psi);
203  MPS<Matrix, SymmGroup> super_mpo = mpo_to_smps(mpo, this->phys_psi);
204  dct = multi_overlap(super_mpo, mps);
205  for (int i=0; i<dct.size(); ++i)
206  dct[i] /= nn;
207  }
208 
209  /// save results and labels
210  this->vector_results.reserve(this->vector_results.size() + dct.size());
211  this->labels.reserve(this->labels.size() + dct.size());
212 
213  std::copy(dct.begin(), dct.end(), std::back_inserter(this->vector_results));
214 
215  std::vector<std::vector<std::size_t> > num_labels = dcorr->numeric_labels();
216  std::vector<std::string> lbt = label_strings(lattice, (order.size() > 0) ? detail::resort_labels(num_labels, order, is_nn) : num_labels );
217  std::copy(lbt.begin(), lbt.end(), std::back_inserter(this->labels));
218  }
219  }
std::vector< std::string > labels
Definition: measurement.h:78
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > multi_overlap(MPS< Matrix, SymmGroup > const &mps1, MPS< Matrix, SymmGroup > const &mps2)
Definition: mps_mpo_ops.h:154
bool is_super_meas
Definition: measurement.h:77
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > multi_expval(MPS< Matrix, SymmGroup > const &mps, MPO< Matrix, SymmGroup > const &mpo)
Definition: mps_mpo_ops.h:104
std::vector< std::string > label_strings(const Lattice &lat, const std::vector< std::vector< std::size_t > > &labels)
Definition: measurement.h:190
std::vector< typename MPS< Matrix, SymmGroup >::scalar_type > vector_results
Definition: measurement.h:80
Definition: mpo.h:36
Definition: mps.h:40
MPSTensor< Matrix, SymmGroup >::scalar_type scalar_type
Definition: mps.h:51
MPS< Matrix, SymmGroup > mpo_to_smps(MPO< Matrix, SymmGroup > const &mpo, Index< SymmGroup > const &phys_i)
Definition: super_mpo.h:60
std::vector< std::vector< std::size_t > > resort_labels(const std::vector< std::vector< std::size_t > > &labels, std::vector< size_t > const &order, bool is_nn=false)
Definition: correlations.h:42
Index< SymmGroup > phys_psi
Definition: measurement.h:82
pos_t size() const
Definition: lattice.h:115
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: