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

#include <mps.h>

Public Types

typedef std::size_t size_t
 
typedef data_t::size_type size_type
 
typedef data_t::value_type value_type
 
typedef data_t::iterator iterator
 
typedef data_t::const_iterator const_iterator
 
typedef MPSTensor< Matrix,
SymmGroup >::scalar_type 
scalar_type
 

Public Member Functions

 MPS ()
 
 MPS (size_t L)
 
 MPS (size_t L, mps_initializer< Matrix, SymmGroup > &init)
 
size_t size () const
 
size_t length () const
 
Index< SymmGroup > const & site_dim (size_t i) const
 
Index< SymmGroup > const & row_dim (size_t i) const
 
Index< SymmGroup > const & col_dim (size_t i) const
 
value_type const & operator[] (size_t i) const
 
value_typeoperator[] (size_t i)
 
void resize (size_t L)
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator const_begin () const
 
const_iterator const_end () const
 
iterator begin ()
 
iterator end ()
 
size_t canonization (bool=false) const
 
void canonize (size_t center, DecompMethod method=DefaultSolver())
 
void normalize_left ()
 
void normalize_right ()
 
void move_normalization_l2r (size_t p1, size_t p2, DecompMethod method=DefaultSolver())
 
void move_normalization_r2l (size_t p1, size_t p2, DecompMethod method=DefaultSolver())
 
std::string description () const
 
template<class OtherMatrix >
truncation_results grow_l2r_sweep (MPOTensor< Matrix, SymmGroup > const &mpo, Boundary< OtherMatrix, SymmGroup > const &left, Boundary< OtherMatrix, SymmGroup > const &right, std::size_t l, double alpha, double cutoff, std::size_t Mmax)
 
template<class OtherMatrix >
truncation_results grow_r2l_sweep (MPOTensor< Matrix, SymmGroup > const &mpo, Boundary< OtherMatrix, SymmGroup > const &left, Boundary< OtherMatrix, SymmGroup > const &right, std::size_t l, double alpha, double cutoff, std::size_t Mmax)
 
Boundary< Matrix, SymmGroup > left_boundary () const
 
Boundary< Matrix, SymmGroup > right_boundary () const
 
void apply (block_matrix< Matrix, SymmGroup > const &, size_type)
 
void apply (block_matrix< Matrix, SymmGroup > const &, block_matrix< Matrix, SymmGroup > const &, size_type)
 

Friends

void swap (MPS &a, MPS &b)
 

Detailed Description

template<class Matrix, class SymmGroup>
class MPS< Matrix, SymmGroup >

Definition at line 40 of file mps.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef data_t::const_iterator MPS< Matrix, SymmGroup >::const_iterator

Definition at line 50 of file mps.h.

template<class Matrix, class SymmGroup>
typedef data_t::iterator MPS< Matrix, SymmGroup >::iterator

Definition at line 49 of file mps.h.

template<class Matrix, class SymmGroup>
typedef MPSTensor<Matrix, SymmGroup>::scalar_type MPS< Matrix, SymmGroup >::scalar_type

Definition at line 51 of file mps.h.

template<class Matrix, class SymmGroup>
typedef std::size_t MPS< Matrix, SymmGroup >::size_t

Definition at line 44 of file mps.h.

template<class Matrix, class SymmGroup>
typedef data_t::size_type MPS< Matrix, SymmGroup >::size_type

Definition at line 47 of file mps.h.

template<class Matrix, class SymmGroup>
typedef data_t::value_type MPS< Matrix, SymmGroup >::value_type

Definition at line 48 of file mps.h.

Constructor & Destructor Documentation

template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup >::MPS ( )

Definition at line 50 of file mps.hpp.

51 : canonized_i(std::numeric_limits<size_t>::max())
52 { }
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup >::MPS ( size_t  L)

Definition at line 55 of file mps.hpp.

56 : data_(L)
57 , canonized_i(std::numeric_limits<size_t>::max())
58 { }
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup >::MPS ( size_t  L,
mps_initializer< Matrix, SymmGroup > &  init 
)

Definition at line 61 of file mps.hpp.

62 : data_(L)
63 , canonized_i(std::numeric_limits<size_t>::max())
64 {
65  init(*this);
66 
67  // MD: this is actually important
68  // it turned out, this is also quite dangerous: if a block is 1x2,
69  // normalize_left will resize it to 1x1
70  // init() should take care of it, in case needed. Otherwise some
71  // adhoc states will be broken (e.g. identity MPS)
72  // for (int i = 0; i < L; ++i)
73  // (*this)[i].normalize_left(DefaultSolver());
74 
75  this->normalize_left();
76 }
void normalize_left()
Definition: mps.hpp:124

Member Function Documentation

template<class Matrix, class SymmGroup>
void MPS< Matrix, SymmGroup >::apply ( block_matrix< Matrix, SymmGroup > const &  ,
size_type   
)
template<class Matrix, class SymmGroup>
void MPS< Matrix, SymmGroup >::apply ( block_matrix< Matrix, SymmGroup > const &  ,
block_matrix< Matrix, SymmGroup > const &  ,
size_type   
)
template<class Matrix, class SymmGroup>
const_iterator MPS< Matrix, SymmGroup >::begin ( ) const
inline

Definition at line 68 of file mps.h.

68 {return data_.begin();}
template<class Matrix, class SymmGroup>
iterator MPS< Matrix, SymmGroup >::begin ( )
inline

Definition at line 72 of file mps.h.

72 {return data_.begin();}
template<class Matrix , class SymmGroup >
size_t MPS< Matrix, SymmGroup >::canonization ( bool  search = false) const

Definition at line 99 of file mps.hpp.

100 {
101  if (!search)
102  return canonized_i;
103 
104  size_t center = ((*this)[0].isleftnormalized()) ? 1 : 0;
105  for (size_t i=1; i<length(); ++i) {
106  if (!(*this)[i].isnormalized() && center != i) {
107  canonized_i = std::numeric_limits<size_t>::max();
108  return canonized_i;
109  } else if ((*this)[i].isleftnormalized() && center == i)
110  center = i+1;
111  else if ((*this)[i].isleftnormalized()) {
112  canonized_i = std::numeric_limits<size_t>::max();
113  return canonized_i;
114  }
115  }
116  if (center == length())
117  center = length()-1;
118 
119  canonized_i = center;
120  return canonized_i;
121 }
size_t length() const
Definition: mps.h:58
template<class Matrix , class SymmGroup >
void MPS< Matrix, SymmGroup >::canonize ( std::size_t  center,
DecompMethod  method = DefaultSolver() 
)

Definition at line 147 of file mps.hpp.

148 {
149  if (canonized_i == center)
150  return;
151 
152  if (canonized_i < center)
153  move_normalization_l2r(canonized_i, center, method);
154  else if (canonized_i < length())
155  move_normalization_r2l(canonized_i, center, method);
156  else {
157  move_normalization_l2r(0, center, method);
158  move_normalization_r2l(length()-1, center, method);
159  }
160  canonized_i = center;
161 }
void move_normalization_l2r(size_t p1, size_t p2, DecompMethod method=DefaultSolver())
Definition: mps.hpp:167
void move_normalization_r2l(size_t p1, size_t p2, DecompMethod method=DefaultSolver())
Definition: mps.hpp:190
size_t length() const
Definition: mps.h:58
template<class Matrix, class SymmGroup>
Index<SymmGroup> const& MPS< Matrix, SymmGroup >::col_dim ( size_t  i) const
inline

Definition at line 61 of file mps.h.

61 { return data_[i].col_dim(); }
template<class Matrix, class SymmGroup>
const_iterator MPS< Matrix, SymmGroup >::const_begin ( ) const
inline

Definition at line 70 of file mps.h.

70 {return data_.begin();}
template<class Matrix, class SymmGroup>
const_iterator MPS< Matrix, SymmGroup >::const_end ( ) const
inline

Definition at line 71 of file mps.h.

71 {return data_.end();}
template<class Matrix , class SymmGroup >
std::string MPS< Matrix, SymmGroup >::description ( ) const

Definition at line 35 of file mps.hpp.

36 {
37  std::ostringstream oss;
38  for (int i = 0; i < length(); ++i)
39  {
40  oss << "MPS site " << i << std::endl;
41  oss << (*this)[i].row_dim() << std::endl;
42  oss << "Sum: " << (*this)[i].row_dim().sum_of_sizes() << std::endl;
43  oss << (*this)[i].col_dim() << std::endl;
44  oss << "Sum: " << (*this)[i].col_dim().sum_of_sizes() << std::endl;
45  }
46  return oss.str();
47 }
size_t length() const
Definition: mps.h:58
template<class Matrix, class SymmGroup>
const_iterator MPS< Matrix, SymmGroup >::end ( ) const
inline

Definition at line 69 of file mps.h.

69 {return data_.end();}
template<class Matrix, class SymmGroup>
iterator MPS< Matrix, SymmGroup >::end ( )
inline

Definition at line 73 of file mps.h.

73 {return data_.end();}
template<class Matrix , class SymmGroup >
template<class OtherMatrix >
truncation_results MPS< Matrix, SymmGroup >::grow_l2r_sweep ( MPOTensor< Matrix, SymmGroup > const &  mpo,
Boundary< OtherMatrix, SymmGroup > const &  left,
Boundary< OtherMatrix, SymmGroup > const &  right,
std::size_t  l,
double  alpha,
double  cutoff,
std::size_t  Mmax 
)

Definition at line 212 of file mps.hpp.

217 { // canonized_i invalided through (*this)[]
219  truncation_results trunc;
220 
221  boost::tie(new_mps, trunc) =
222  contraction::predict_new_state_l2r_sweep((*this)[l], mpo, left, right, alpha, cutoff, Mmax);
223 
224  (*this)[l+1] = contraction::predict_lanczos_l2r_sweep((*this)[l+1],
225  (*this)[l], new_mps);
226  (*this)[l] = new_mps;
227  return trunc;
228 }
static MPSTensor< Matrix, SymmGroup > predict_lanczos_l2r_sweep(MPSTensor< Matrix, SymmGroup > B, MPSTensor< Matrix, SymmGroup > const &psi, MPSTensor< Matrix, SymmGroup > const &A)
Definition: contractions.h:548
static std::pair< MPSTensor< Matrix, SymmGroup >, truncation_results > predict_new_state_l2r_sweep(MPSTensor< Matrix, SymmGroup > const &mps, MPOTensor< Matrix, SymmGroup > const &mpo, Boundary< OtherMatrix, SymmGroup > const &left, Boundary< OtherMatrix, SymmGroup > const &right, double alpha, double cutoff, std::size_t Mmax)
Definition: contractions.h:507
template<class Matrix , class SymmGroup >
template<class OtherMatrix >
truncation_results MPS< Matrix, SymmGroup >::grow_r2l_sweep ( MPOTensor< Matrix, SymmGroup > const &  mpo,
Boundary< OtherMatrix, SymmGroup > const &  left,
Boundary< OtherMatrix, SymmGroup > const &  right,
std::size_t  l,
double  alpha,
double  cutoff,
std::size_t  Mmax 
)

Definition at line 233 of file mps.hpp.

238 { // canonized_i invalided through (*this)[]
240  truncation_results trunc;
241 
242  boost::tie(new_mps, trunc) =
243  contraction::predict_new_state_r2l_sweep((*this)[l], mpo, left, right, alpha, cutoff, Mmax);
244 
245  (*this)[l-1] = contraction::predict_lanczos_r2l_sweep((*this)[l-1],
246  (*this)[l], new_mps);
247  (*this)[l] = new_mps;
248  return trunc;
249 }
static std::pair< MPSTensor< Matrix, SymmGroup >, truncation_results > predict_new_state_r2l_sweep(MPSTensor< Matrix, SymmGroup > const &mps, MPOTensor< Matrix, SymmGroup > const &mpo, Boundary< OtherMatrix, SymmGroup > const &left, Boundary< OtherMatrix, SymmGroup > const &right, double alpha, double cutoff, std::size_t Mmax)
Definition: contractions.h:564
static MPSTensor< Matrix, SymmGroup > predict_lanczos_r2l_sweep(MPSTensor< Matrix, SymmGroup > B, MPSTensor< Matrix, SymmGroup > const &psi, MPSTensor< Matrix, SymmGroup > const &A)
Definition: contractions.h:605
template<class Matrix , class SymmGroup >
Boundary< Matrix, SymmGroup > MPS< Matrix, SymmGroup >::left_boundary ( ) const

Definition at line 253 of file mps.hpp.

254 {
255  Index<SymmGroup> i = (*this)[0].row_dim();
256  Boundary<Matrix, SymmGroup> ret(i, i, 1);
257 
258  for(std::size_t k(0); k < ret[0].n_blocks(); ++k)
260 
261  return ret;
262 }
void left_right_boundary_init(alps::numeric::matrix< T, A > &M)
template<class Matrix, class SymmGroup>
size_t MPS< Matrix, SymmGroup >::length ( ) const
inline

Definition at line 58 of file mps.h.

58 { return size(); }
size_t size() const
Definition: mps.h:57
template<class Matrix , class SymmGroup >
void MPS< Matrix, SymmGroup >::move_normalization_l2r ( size_t  p1,
size_t  p2,
DecompMethod  method = DefaultSolver() 
)

Definition at line 167 of file mps.hpp.

168 {
169  size_t tmp_i = canonized_i;
170  for (int i = p1; i < std::min(p2, length()); ++i)
171  {
172  if ((*this)[i].isleftnormalized())
173  continue;
174  block_matrix<Matrix, SymmGroup> t = (*this)[i].normalize_left(method);
175  if (i < length()-1) {
176  (*this)[i+1].multiply_from_left(t);
177  (*this)[i+1].divide_by_scalar((*this)[i+1].scalar_norm());
178  }
179  }
180  if (tmp_i == p1)
181  canonized_i = p2;
182  else
183  canonized_i = std::numeric_limits<size_t>::max();
184 }
size_t length() const
Definition: mps.h:58
template<class Matrix , class SymmGroup >
void MPS< Matrix, SymmGroup >::move_normalization_r2l ( size_t  p1,
size_t  p2,
DecompMethod  method = DefaultSolver() 
)

Definition at line 190 of file mps.hpp.

191 {
192  size_t tmp_i = canonized_i;
193  for (int i = p1; i > static_cast<int>(std::max(p2, size_t(0))); --i)
194  {
195  if ((*this)[i].isrightnormalized())
196  continue;
197  block_matrix<Matrix, SymmGroup> t = (*this)[i].normalize_right(method);
198  if (i > 0) {
199  (*this)[i-1].multiply_from_right(t);
200  (*this)[i-1].divide_by_scalar((*this)[i-1].scalar_norm());
201  }
202  }
203  if (tmp_i == p1)
204  canonized_i = p2;
205  else
206  canonized_i = std::numeric_limits<size_t>::max();
207 }
template<class Matrix , class SymmGroup >
void MPS< Matrix, SymmGroup >::normalize_left ( )

Definition at line 124 of file mps.hpp.

125 {
126  canonize(length()-1);
127  // now state is: A A A A A A M
128  block_matrix<Matrix, SymmGroup> t = (*this)[length()-1].normalize_left(DefaultSolver());
129  // now state is: A A A A A A A
130  canonized_i = length()-1;
131 }
size_t length() const
Definition: mps.h:58
void canonize(size_t center, DecompMethod method=DefaultSolver())
Definition: mps.hpp:147
template<class Matrix , class SymmGroup >
void MPS< Matrix, SymmGroup >::normalize_right ( )

Definition at line 134 of file mps.hpp.

135 {
136  canonize(0);
137  // now state is: M B B B B B B
138  block_matrix<Matrix, SymmGroup> t = (*this)[0].normalize_right(DefaultSolver());
139  // now state is: B B B B B B B
140  canonized_i = 0;
141 }
void canonize(size_t center, DecompMethod method=DefaultSolver())
Definition: mps.hpp:147
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup >::value_type const & MPS< Matrix, SymmGroup >::operator[] ( size_t  i) const

Definition at line 79 of file mps.hpp.

80 { return data_[i]; }
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup >::value_type & MPS< Matrix, SymmGroup >::operator[] ( size_t  i)

Definition at line 83 of file mps.hpp.

84 {
85  if (i != canonized_i)
86  canonized_i=std::numeric_limits<size_t>::max();
87  return data_[i];
88 }
template<class Matrix , class SymmGroup >
void MPS< Matrix, SymmGroup >::resize ( size_t  L)

Definition at line 91 of file mps.hpp.

92 {
93  // if canonized_i < L and L < current L, we could conserve canonized_i
94  canonized_i=std::numeric_limits<size_t>::max();
95  data_.resize(L);
96 }
template<class Matrix , class SymmGroup >
Boundary< Matrix, SymmGroup > MPS< Matrix, SymmGroup >::right_boundary ( ) const

Definition at line 266 of file mps.hpp.

267 {
268  Index<SymmGroup> i = (*this)[length()-1].col_dim();
269  Boundary<Matrix, SymmGroup> ret(i, i, 1);
270 
271 // Original
272 // for(typename Index<SymmGroup>::basis_iterator it = i.basis_begin(); !it.end(); ++it)
273 // ret(0,*it,*it) = 1;
274 
275  for(std::size_t k(0); k < ret[0].n_blocks(); ++k)
277 
278  return ret;
279 }
void left_right_boundary_init(alps::numeric::matrix< T, A > &M)
size_t length() const
Definition: mps.h:58
template<class Matrix, class SymmGroup>
Index<SymmGroup> const& MPS< Matrix, SymmGroup >::row_dim ( size_t  i) const
inline

Definition at line 60 of file mps.h.

60 { return data_[i].row_dim(); }
template<class Matrix, class SymmGroup>
Index<SymmGroup> const& MPS< Matrix, SymmGroup >::site_dim ( size_t  i) const
inline

Definition at line 59 of file mps.h.

59 { return data_[i].site_dim(); }
template<class Matrix, class SymmGroup>
size_t MPS< Matrix, SymmGroup >::size ( ) const
inline

Definition at line 57 of file mps.h.

57 { return data_.size(); }

Friends And Related Function Documentation

template<class Matrix, class SymmGroup>
void swap ( MPS< Matrix, SymmGroup > &  a,
MPS< Matrix, SymmGroup > &  b 
)
friend

Definition at line 105 of file mps.h.

106  {
107  using std::swap;
108  swap(a.data_, b.data_);
109  swap(a.canonized_i, b.canonized_i);
110  }
void swap(MPSTensor< Matrix, SymmGroup > &x, MPSTensor< Matrix, SymmGroup > &y)
friend void swap(MPS &a, MPS &b)
Definition: mps.h:105

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