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

Go to the source code of this file.

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 >
void check_equal_mps (MPS< Matrix, SymmGroup > const &mps1, MPS< Matrix, SymmGroup > const &mps2)
 

Function Documentation

template<class Matrix , class SymmGroup >
void check_equal_mps ( MPS< Matrix, SymmGroup > const &  mps1,
MPS< Matrix, SymmGroup > const &  mps2 
)

Definition at line 348 of file mps.hpp.

349 {
350  // Length
351  if (mps1.length() != mps2.length())
352  throw std::runtime_error("Length doesn't match.");
353 
354  for (int i=0; i<mps1.length(); ++i)
355  try {
356  mps1[i].check_equal(mps2[i]);
357  } catch (std::exception & e) {
358  maquis::cerr << "Problem on site " << i << ":" << e.what() << std::endl;
359  exit(1);
360  }
361 }
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