ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
custom.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * ALPS MPS DMRG Project
4  *
5  * Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6  * 2011-2011 by Bela Bauer <bauerb@phys.ethz.ch>
7  * 2011-2013 Michele Dolfi <dolfim@phys.ethz.ch>
8  *
9  * This software is part of the ALPS Applications, published under the ALPS
10  * Application License; you can use, redistribute it and/or modify it under
11  * the terms of the license, either version 1 or (at your option) any later
12  * version.
13  *
14  * You should have received a copy of the ALPS Application License along with
15  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
16  * available from http://alps.comp-phys.org/.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
21  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
22  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  *****************************************************************************/
27 
28 #ifndef MEASUREMENTS_CUSTOM_H
29 #define MEASUREMENTS_CUSTOM_H
30 
33 
34 namespace measurements {
35 
36  template <class Matrix, class SymmGroup>
37  class custom : public measurement<Matrix, SymmGroup> {
39  public:
40  custom(std::string const& name_,
41  const Lattice & lat,
42  std::vector<block_matrix<Matrix, SymmGroup> > const & identities,
43  std::vector<block_matrix<Matrix, SymmGroup> > const & fillings,
44  std::vector< std::vector< std::pair<int, block_matrix<Matrix, SymmGroup> > > > const & ops)
45  : base(name_)
46  {
47  generate_mpo::MPOMaker<Matrix, SymmGroup> mpom(lat, identities, fillings);
48 
49  for (int k = 0; k < ops.size(); ++k) {
51  term.operators = ops[k];
52  term.with_sign = true;
53  mpom.add_term(term);
54  }
55 
56  mpo = mpom.create_mpo();
57 
58  this->cast_to_real = false;
59  }
60 
61  void evaluate(MPS<Matrix, SymmGroup> const& mps, boost::optional<reduced_mps<Matrix, SymmGroup> const&> rmps = boost::none)
62  {
63  this->result = expval(mps, mpo);
64  }
65 
66  protected:
68  {
69  return new custom(*this);
70  }
71 
72  private:
74  };
75 
76 }
77 
78 #endif
double expval(MPS< Matrix, SymmGroup > const &mps, MPO< Matrix, SymmGroup > const &mpo, int d)
Definition: mps_mpo_ops.h:72
value_type result
Definition: measurement.h:79
Definition: mpo.h:36
definition of Measurement base class
custom(std::string const &name_, const Lattice &lat, std::vector< block_matrix< Matrix, SymmGroup > > const &identities, std::vector< block_matrix< Matrix, SymmGroup > > const &fillings, std::vector< std::vector< std::pair< int, block_matrix< Matrix, SymmGroup > > > > const &ops)
Definition: custom.h:40
Definition: mps.h:40
measurement< Matrix, SymmGroup > * do_clone() const
Definition: custom.h:67
std::vector< op_pair_t > operators
Definition: utils.hpp:118
functions to operate on MPS and MPO (compute expectation values, etc.)
void add_term(Operator_Term< Matrix, SymmGroup > const &term)
Definition: mpo_maker.hpp:78
MPO< Matrix, SymmGroup > create_mpo()
Definition: mpo_maker.hpp:121
bool cast_to_real
Definition: measurement.h:77
pimpl resolved Lattice
Definition: lattice.h:84
void evaluate(MPS< Matrix, SymmGroup > const &mps, boost::optional< reduced_mps< Matrix, SymmGroup > const & > rmps=boost::none)
Definition: custom.h:61