ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
mps_sectors.h File Reference
#include "dmrg/block_matrix/indexing.h"

Go to the source code of this file.

Functions

template<class T >
tri_min (T a, T b, T c)
 
template<class SymmGroup >
std::vector< Index< SymmGroup > > allowed_sectors (std::vector< int > const &site_type, std::vector< Index< SymmGroup > > const &phys_dims, typename SymmGroup::charge right_end, std::size_t Mmax)
 

Function Documentation

template<class SymmGroup >
std::vector<Index<SymmGroup> > allowed_sectors ( std::vector< int > const &  site_type,
std::vector< Index< SymmGroup > > const &  phys_dims,
typename SymmGroup::charge  right_end,
std::size_t  Mmax 
)
inline

Definition at line 42 of file mps_sectors.h.

46 {
47  bool finitegroup = SymmGroup::finite;
48 
49  std::size_t L = site_type.size();
50 
51  typedef typename SymmGroup::subcharge subcharge;
52 
53  std::vector<typename SymmGroup::charge> maximum_charges(phys_dims.size()), minimum_charges(phys_dims.size());
54  for (int type=0; type<phys_dims.size(); ++type) {
55  Index<SymmGroup> physc = phys_dims[type];
56  physc.sort();
57  maximum_charges[type] = physc.begin()->first;
58  minimum_charges[type] = physc.rbegin()->first;
59  if (minimum_charges[type] > maximum_charges[type]) std::swap(maximum_charges[type], minimum_charges[type]);
60  }
61 
62  typename SymmGroup::charge maximum_total_charge=SymmGroup::IdentityCharge, minimum_total_charge=SymmGroup::IdentityCharge;
63  for (int i = 1; i < L; ++i) {
64  maximum_total_charge = SymmGroup::fuse(maximum_total_charge, maximum_charges[site_type[i-1]]);
65  minimum_total_charge = SymmGroup::fuse(minimum_total_charge, minimum_charges[site_type[i-1]]);
66  }
67 
68  Index<SymmGroup> l_triv, r_triv;
69  l_triv.insert( std::make_pair(SymmGroup::IdentityCharge, 1) );
70  r_triv.insert( std::make_pair(right_end, 1) );
71 
72  std::vector<Index<SymmGroup> > left_allowed(L+1), right_allowed(L+1), allowed(L+1);
73  left_allowed[0] = l_triv;
74  right_allowed[L] = r_triv;
75 
76  typename SymmGroup::charge cmaxi=maximum_total_charge, cmini=minimum_total_charge;
77  for (int i = 1; i < L+1; ++i) {
78  left_allowed[i] = phys_dims[site_type[i-1]] * left_allowed[i-1];
79  typename Index<SymmGroup>::iterator it = left_allowed[i].begin();
80  while ( it != left_allowed[i].end() )
81  {
82  if (!finitegroup && SymmGroup::fuse(it->first, cmaxi) < right_end)
83  it = left_allowed[i].erase(it);
84  else if (!finitegroup && SymmGroup::fuse(it->first, cmini) > right_end)
85  it = left_allowed[i].erase(it);
86  else {
87  it->second = std::min(Mmax, it->second);
88  ++it;
89  }
90  }
91  cmaxi = SymmGroup::fuse(cmaxi, -maximum_charges[site_type[i-1]]);
92  cmini = SymmGroup::fuse(cmini, -minimum_charges[site_type[i-1]]);
93  }
94 
95  cmaxi=maximum_total_charge; cmini=minimum_total_charge;
96  for (int i = L-1; i >= 0; --i) {
97  right_allowed[i] = adjoin(phys_dims[site_type[i]]) * right_allowed[i+1];
98 
99  typename Index<SymmGroup>::iterator it = right_allowed[i].begin();
100  while ( it != right_allowed[i].end() )
101  {
102  if (!finitegroup && SymmGroup::fuse(it->first, -cmaxi) > SymmGroup::IdentityCharge)
103  it = right_allowed[i].erase(it);
104  else if (!finitegroup && SymmGroup::fuse(it->first, -cmini) < SymmGroup::IdentityCharge)
105  it = right_allowed[i].erase(it);
106  else {
107  it->second = std::min(Mmax, it->second);
108  ++it;
109  }
110  }
111  cmaxi = SymmGroup::fuse(cmaxi, -maximum_charges[site_type[i]]);
112  cmini = SymmGroup::fuse(cmini, -minimum_charges[site_type[i]]);
113 
114  }
115 
116  for (int i = 0; i < L+1; ++i) {
117  allowed[i] = common_subset(left_allowed[i], right_allowed[i]);
118  for (typename Index<SymmGroup>::iterator it = allowed[i].begin();
119  it != allowed[i].end(); ++it)
120  it->second = tri_min(Mmax,
121  left_allowed[i].size_of_block(it->first),
122  right_allowed[i].size_of_block(it->first));
123  }
124 
125  return allowed;
126 }
void sort()
T tri_min(T a, T b, T c)
Definition: mps_sectors.h:35
iterator begin()
void swap(MPSTensor< Matrix, SymmGroup > &x, MPSTensor< Matrix, SymmGroup > &y)
block_matrix< Matrix, SymmGroup > adjoin(block_matrix< Matrix, SymmGroup > const &m)
reverse_iterator rbegin()
iterator erase(iterator p)
iterator end()
std::size_t insert(std::pair< charge, std::size_t > const &x)
Index< SymmGroup > common_subset(Index< SymmGroup > &a, Index< SymmGroup > &b)
base_t::iterator iterator
T fuse(const A &ind, T d)
Fuse indices n[i] into one p = n[i] d^i.
template<class T >
T tri_min ( a,
b,
c 
)

Definition at line 35 of file mps_sectors.h.

36 {
37  return std::min(std::min(a, b),
38  std::min(a, c));
39 }