ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions
mps.h File Reference
#include "dmrg/mp_tensors/mpstensor.h"
#include "dmrg/mp_tensors/mpotensor.h"
#include "dmrg/mp_tensors/boundary.h"
#include <limits>
#include "dmrg/mp_tensors/mps.hpp"

Go to the source code of this file.

Classes

struct  mps_initializer< Matrix, SymmGroup >
 
class  MPS< Matrix, SymmGroup >
 
struct  mps_initializer< Matrix, SymmGroup >
 

Functions

template<class Matrix , class SymmGroup >
void load (std::string const &dirname, MPS< Matrix, SymmGroup > &mps)
 
template<class Matrix , class SymmGroup >
void save (std::string const &dirname, MPS< Matrix, SymmGroup > const &mps)
 
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup > join (MPS< Matrix, SymmGroup > const &a, MPS< Matrix, SymmGroup > const &b, double alpha=1., double beta=1.)
 

Function Documentation

template<class Matrix , class SymmGroup >
MPS<Matrix, SymmGroup> join ( MPS< Matrix, SymmGroup > const &  a,
MPS< Matrix, SymmGroup > const &  b,
double  alpha = 1.,
double  beta = 1. 
)

Definition at line 131 of file mps.h.

134 {
135  assert( a.length() == b.length() );
136 
137  MPSTensor<Matrix, SymmGroup> aright=a[a.length()-1], bright=b[a.length()-1];
138  aright.multiply_by_scalar(alpha);
139  bright.multiply_by_scalar(beta);
140 
142  ret[0] = join(a[0],b[0],l_boundary_f);
143  ret[a.length()-1] = join(aright,bright,r_boundary_f);
144  for (std::size_t p = 1; p < a.length()-1; ++p)
145  ret[p] = join(a[p], b[p]);
146  return ret;
147 }
Definition: mps.h:40
MPS< Matrix, SymmGroup > join(MPS< Matrix, SymmGroup > const &a, MPS< Matrix, SymmGroup > const &b, double alpha=1., double beta=1.)
Definition: mps.h:131
size_t length() const
Definition: mps.h:58
template<class Matrix , class SymmGroup >
void load ( std::string const &  dirname,
MPS< Matrix, SymmGroup > &  mps 
)

Definition at line 315 of file mps.hpp.

316 {
317  /// get size of MPS
318  std::size_t L = 0;
319  while (boost::filesystem::exists( dirname + "/mps" + boost::lexical_cast<std::string>(++L) + ".h5" ));
320 
321  /// load tensors
322  MPS<Matrix, SymmGroup> tmp(L);
323  size_t loop_max = tmp.length();
324  semi_parallel_for(/*removed...*/, std::size_t k = 0; k < loop_max; ++k){
325  std::string fname = dirname+"/mps"+boost::lexical_cast<std::string>((size_t)k)+".h5";
326  storage::archive ar(fname);
327  ar["/tensor"] >> tmp[k];
328  }
329  swap(mps, tmp);
330 }
void swap(MPSTensor< Matrix, SymmGroup > &x, MPSTensor< Matrix, SymmGroup > &y)
#define semi_parallel_for(constraint,...)
Definition: mps.h:40
template<class Matrix , class SymmGroup >
void save ( std::string const &  dirname,
MPS< Matrix, SymmGroup > const &  mps 
)

Definition at line 333 of file mps.hpp.

334 {
335  size_t loop_max = mps.length();
336  parallel_for(/*removed...*/, std::size_t k = 0; k < loop_max; ++k){
337  const std::string fname = dirname+"/mps"+boost::lexical_cast<std::string>((size_t)k)+".h5.new";
338  storage::archive ar(fname, "w");
339  ar["/tensor"] << mps[k];
340  }
341  parallel_for(/*removed...*/, std::size_t k = 0; k < loop_max; ++k){
342  const std::string fname = dirname+"/mps"+boost::lexical_cast<std::string>((size_t)k)+".h5";
343  boost::filesystem::rename(fname+".new", fname);
344  }
345 }
#define parallel_for(constraint,...)
size_t length() const
Definition: mps.h:58