ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
placement.h File Reference

Go to the source code of this file.

Functions

void make_consistent (std::vector< int > &p_new, int b2, std::vector< int > &e_new, const std::vector< int > &p_old, int b1, std::vector< int > &e_old)
 
void make_complete (std::vector< int > &placement)
 
template<class Matrix , class SymmGroup >
std::vector< int > get_left_placement (const MPOTensor< Matrix, SymmGroup > &mpo, const std::vector< int > &placement_l_old, const std::vector< int > &placement_r)
 
template<class Matrix , class SymmGroup >
std::vector< int > get_right_placement (const MPOTensor< Matrix, SymmGroup > &mpo, const std::vector< int > &placement_l, const std::vector< int > &placement_r_old)
 
template<class Matrix , class SymmGroup >
std::vector< std::vector< int > > construct_placements (const MPO< Matrix, SymmGroup > &mpo)
 

Function Documentation

template<class Matrix , class SymmGroup >
std::vector<std::vector<int> > construct_placements ( const MPO< Matrix, SymmGroup > &  mpo)

Definition at line 101 of file placement.h.

101  {
102  std::vector<std::vector<int> > placements(mpo.length()+1);
103  std::vector<std::pair<std::vector<int>, std::vector<int> > > exceptions(mpo.length()+1);
104  placements[0].push_back(0); // left_[0] has only 1 element
105  for(int s = 0; s < mpo.length(); s++){
106  placements[s+1].resize(mpo[s].col_dim(), -1);
107 
108  for(int b1 = 0; b1 < placements[s].size(); b1++)
109  for(int b2 = 0; b2 < placements[s+1].size(); b2++){
110  if(mpo[s].has(b1,b2)){
111  make_consistent(placements[s+1], b2, exceptions[s+1].second, placements[s], b1, exceptions[s].first);
112  }
113  }
114  make_complete(placements[s+1]);
115  mpo[s].placement_l = placements[s];
116  mpo[s].placement_r = placements[s+1];
117  }
118  return placements;
119 }
void make_complete(std::vector< int > &placement)
Definition: placement.h:55
void make_consistent(std::vector< int > &p_new, int b2, std::vector< int > &e_new, const std::vector< int > &p_old, int b1, std::vector< int > &e_old)
Definition: placement.h:30
template<class Matrix , class SymmGroup >
std::vector<int> get_left_placement ( const MPOTensor< Matrix, SymmGroup > &  mpo,
const std::vector< int > &  placement_l_old,
const std::vector< int > &  placement_r 
)

Definition at line 69 of file placement.h.

69  {
70  std::vector<int> ts_exceptions_l, ts_exceptions_r;
71  std::vector<int> placement_l(placement_l_old.size(), -1);
72 
73  for(int b1 = 0; b1 < placement_l_old.size(); b1++)
74  for(int b2 = 0; b2 < placement_r.size(); b2++){
75  if(mpo.has(b1,b2)){
76  make_consistent(placement_l, b1, ts_exceptions_l,
77  placement_r, b2, ts_exceptions_r);
78  }
79  }
80  make_complete(placement_l);
81  return placement_l;
82 }
void make_complete(std::vector< int > &placement)
Definition: placement.h:55
void make_consistent(std::vector< int > &p_new, int b2, std::vector< int > &e_new, const std::vector< int > &p_old, int b1, std::vector< int > &e_old)
Definition: placement.h:30
bool has(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:95
template<class Matrix , class SymmGroup >
std::vector<int> get_right_placement ( const MPOTensor< Matrix, SymmGroup > &  mpo,
const std::vector< int > &  placement_l,
const std::vector< int > &  placement_r_old 
)

Definition at line 85 of file placement.h.

85  {
86  std::vector<int> ts_exceptions_l, ts_exceptions_r;
87  std::vector<int> placement_r(placement_r_old.size(), -1);
88 
89  for(int b1 = 0; b1 < placement_l.size(); b1++)
90  for(int b2 = 0; b2 < placement_r_old.size(); b2++){
91  if(mpo.has(b1,b2)){
92  make_consistent(placement_r, b2, ts_exceptions_r,
93  placement_l, b1, ts_exceptions_l);
94  }
95  }
96  make_complete(placement_r);
97  return placement_r;
98 }
void make_complete(std::vector< int > &placement)
Definition: placement.h:55
void make_consistent(std::vector< int > &p_new, int b2, std::vector< int > &e_new, const std::vector< int > &p_old, int b1, std::vector< int > &e_old)
Definition: placement.h:30
bool has(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:95
void make_complete ( std::vector< int > &  placement)
inline

Definition at line 55 of file placement.h.

55  {
56  for(int i = 0; i < placement.size(); i++)
57  if(placement[i] == -1){
58  for(int k = 0; k < placement.size(); k++){
59  bool found = false;
60  for(int kk = 0; kk < placement.size(); kk++) if(k == placement[kk]){ found = true; break; }
61  if(found) continue;
62  placement[i] = k;
63  break;
64  }
65  }
66 }
void make_consistent ( std::vector< int > &  p_new,
int  b2,
std::vector< int > &  e_new,
const std::vector< int > &  p_old,
int  b1,
std::vector< int > &  e_old 
)
inline

Definition at line 30 of file placement.h.

32 {
33  // exceptions check
34  for(int i = 0; i < e_old.size(); i++) if(b1 == e_old[i]) return;
35  for(int i = 0; i < e_new.size(); i++) if(b2 == e_new[i]) return;
36  // common check
37  for(int i = 0; i < p_new.size(); i++){
38  if(p_new[i] == p_old[b1]){
39  e_old.push_back(b1);
40  for(int ii = i; ii < p_new.size(); ii++)
41  if(p_new[ii] == p_old[b1]) p_new[ii] = -1;
42  return;
43  }
44  }
45  // overlap check
46  if(p_new[b2] != -1){
47  e_new.push_back(b2);
48  p_new[b2] = -1;
49  return;
50  }
51 
52  p_new[b2] = p_old[b1];
53 }