ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
state_mps.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * ALPS MPS DMRG Project
4  *
5  * Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6  * 2012-2013 by Michele Dolfi <dolfim@phys.ethz.ch>
7  *
8  * This software is part of the ALPS Applications, published under the ALPS
9  * Application License; you can use, redistribute it and/or modify it under
10  * the terms of the license, either version 1 or (at your option) any later
11  * version.
12  *
13  * You should have received a copy of the ALPS Application License along with
14  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
15  * available from http://alps.comp-phys.org/.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  *****************************************************************************/
26 
27 #ifndef MAQUIS_DMRG_STATE_MPS_H
28 #define MAQUIS_DMRG_STATE_MPS_H
29 
30 #include "dmrg/mp_tensors/mps.h"
31 
32 #include <boost/tuple/tuple.hpp>
33 
34 template <class Matrix, class SymmGroup>
35 MPS<Matrix, SymmGroup> state_mps(std::vector<boost::tuple<typename SymmGroup::charge, size_t> > const & state,
36  std::vector<Index<SymmGroup> > const& phys_dims, std::vector<int> const& site_type)
37 {
38  typedef typename SymmGroup::charge charge;
39  typedef boost::tuple<charge, size_t> local_state;
40 
41  MPS<Matrix, SymmGroup> mps(state.size());
42 
43  Index<SymmGroup> curr_i;
44  curr_i.insert(std::make_pair(SymmGroup::IdentityCharge, 1));
45  size_t curr_b = 0;
46  for (int i=0; i<state.size(); ++i)
47  {
48  charge newc = SymmGroup::fuse(curr_i[0].first, boost::get<0>(state[i]));
49  size_t news = 1;
50  Index<SymmGroup> new_i;
51  new_i.insert(std::make_pair(newc, news));
52  ProductBasis<SymmGroup> left(phys_dims[site_type[i]], curr_i);
53  mps[i] = MPSTensor<Matrix, SymmGroup>(phys_dims[site_type[i]], curr_i, new_i, false, 0);
54  size_t b_in = left(boost::get<0>(state[i]), curr_i[0].first) + boost::get<1>(state[i]) * curr_i[0].second + curr_b;
55  size_t b_out = 0;
56 
57  mps[i].make_left_paired();
58  block_matrix<Matrix, SymmGroup> & block = mps[i].data();
59  Matrix & m = block(SymmGroup::fuse(curr_i[0].first, boost::get<0>(state[i])), new_i[0].first);
60  m(b_in, b_out) = 1.;
61 
62  curr_i = new_i;
63  curr_b = b_out;
64  }
65  return mps;
66 }
67 
68 
69 #endif
MPS< Matrix, SymmGroup > state_mps(std::vector< boost::tuple< typename SymmGroup::charge, size_t > > const &state, std::vector< Index< SymmGroup > > const &phys_dims, std::vector< int > const &site_type)
Definition: state_mps.h:35
void make_left_paired() const
Definition: mpstensor.hpp:173
declaration of the MPS class (vector of MPSTensor)
Definition: mps.h:40
std::size_t insert(std::pair< charge, std::size_t > const &x)
T fuse(const A &ind, T d)
Fuse indices n[i] into one p = n[i] d^i.