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

#include <mpo_maker.hpp>

Public Member Functions

 MPOMaker (Lattice const &lat_, const std::vector< block_matrix< Matrix, SymmGroup > > &ident_, const std::vector< block_matrix< Matrix, SymmGroup > > &fill_)
 
void add_term (Operator_Term< Matrix, SymmGroup > const &term)
 
MPO< Matrix, SymmGroup > create_mpo ()
 
MPO< Matrix, SymmGroup > create_compressed_mpo (Index< SymmGroup > const &phys, double cutoff)
 
std::vector< std::vector
< block > > & 
get_prempo ()
 

Detailed Description

template<class Matrix, class SymmGroup>
class generate_mpo::MPOMaker< Matrix, SymmGroup >

Definition at line 46 of file mpo_maker.hpp.

Constructor & Destructor Documentation

template<class Matrix, class SymmGroup>
generate_mpo::MPOMaker< Matrix, SymmGroup >::MPOMaker ( Lattice const &  lat_,
const std::vector< block_matrix< Matrix, SymmGroup > > &  ident_,
const std::vector< block_matrix< Matrix, SymmGroup > > &  fill_ 
)
inline

Definition at line 58 of file mpo_maker.hpp.

61  : lat(lat_)
62  , length(lat.size())
63  , identities(ident_)
64  , fillings(fill_)
65  , used_dims(length)
66  , prempo(length)
67  , maximum(2)
68  , leftmost_right(length)
69  , finalized(false)
70  {
71  for (size_t p = 0; p < length; ++p)
72  {
73  if (p+1 < length)
74  prempo[p].push_back(boost::make_tuple(std::size_t(0), std::size_t(0), identities[lat.get_prop<int>("type",p)]));
75  }
76  }
T get_prop(std::string property, pos_t site) const
Definition: lattice.h:103
pos_t size() const
Definition: lattice.h:115

Member Function Documentation

template<class Matrix, class SymmGroup>
void generate_mpo::MPOMaker< Matrix, SymmGroup >::add_term ( Operator_Term< Matrix, SymmGroup > const &  term)
inline

Definition at line 78 of file mpo_maker.hpp.

79  {
80  // TODO: removed const&, because of sorting (non-const operation)
81  std::vector<std::pair<typename Lattice::pos_t, op_t> > ops = term.operators;
82 
83  std::sort(ops.begin(), ops.end(), compare<std::pair<typename Lattice::pos_t, op_t> >);
84 
85  vector<size_t> positions;
86  for (typename vector<pair<typename Lattice::pos_t, op_t> >::const_iterator
87  it = ops.begin();
88  it != ops.end(); ++it)
89  positions.push_back( it->first );
90  size_t minp = *min_element(positions.begin(), positions.end());
91  size_t maxp = *max_element(positions.begin(), positions.end());
92 
93  size_t use_b = maximum++;
94 
95  vector<bool> done(length, false);
96  for (typename vector<pair<typename Lattice::pos_t, op_t> >::const_iterator it = ops.begin();
97  it != ops.end(); ++it)
98  {
99  size_t first_use_b = (it->first == minp ? 0 : use_b);
100  size_t second_use_b = (it->first == maxp ? 1 : use_b);
101  assert( it->first < prempo.size() );
102  if (minp != maxp) { // bond term
103  prempo[it->first].push_back(boost::make_tuple(first_use_b, second_use_b, it->second));
104  used_dims[it->first].insert(use_b);
105  } else // site term
106  site_terms[it->first] += it->second;
107  done[it->first] = true;
108  }
109 
110  for (size_t p = minp; p <= maxp; ++p)
111  if (!done[p]) {
112  op_t const& current_filling = (term.with_sign) ? fillings[lat.get_prop<int>("type",p)] : identities[lat.get_prop<int>("type",p)];
113  prempo[p].push_back( boost::make_tuple(use_b, use_b, current_filling));
114  used_dims[p].insert(use_b);
115  done[p] = true;
116  }
117 
118  leftmost_right = std::min(leftmost_right, maxp);
119  }
T get_prop(std::string property, pos_t site) const
Definition: lattice.h:103
template<class Matrix, class SymmGroup>
MPO<Matrix, SymmGroup> generate_mpo::MPOMaker< Matrix, SymmGroup >::create_compressed_mpo ( Index< SymmGroup > const &  phys,
double  cutoff 
)
inline

Definition at line 133 of file mpo_maker.hpp.

134  {
135  if (!finalized) finalize();
136  MPO<Matrix, SymmGroup> r(length);
137  for (size_t p = 1; p < length - 1; ++p)
138  r[p] = as_bulk(prempo[p]);
139  r[0] = as_left(prempo[0]);
140  r[length-1] = as_right(prempo[length-1]);
141 
142  charge_sort(get_prempo(), r);
143  MPO<Matrix, SymmGroup> mpo_sorted = create_mpo();
144 
146  MPO<Matrix, SymmGroup> mpo_out(length);
147  cpor.compress(mpo_sorted, mpo_out, cutoff);
148 
149  return mpo_out;
150  }
Definition: mpo.h:36
std::vector< std::vector< block > > & get_prempo()
Definition: mpo_maker.hpp:152
MPO< Matrix, SymmGroup > create_mpo()
Definition: mpo_maker.hpp:121
template<class Matrix, class SymmGroup>
MPO<Matrix, SymmGroup> generate_mpo::MPOMaker< Matrix, SymmGroup >::create_mpo ( )
inline

Definition at line 121 of file mpo_maker.hpp.

122  {
123  if (!finalized) finalize();
124  MPO<Matrix, SymmGroup> r(length);
125  for (size_t p = 1; p < length - 1; ++p)
126  r[p] = as_bulk(prempo[p]);
127  r[0] = as_left(prempo[0]);
128  r[length-1] = as_right(prempo[length-1]);
129 
130  return r;
131  }
Definition: mpo.h:36
template<class Matrix, class SymmGroup>
std::vector<std::vector<block> >& generate_mpo::MPOMaker< Matrix, SymmGroup >::get_prempo ( )
inline

Definition at line 152 of file mpo_maker.hpp.

153  {
154  return prempo;
155  }

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