mps-0.0.0
MatrixProductStatesinC++
 All Data Structures Namespaces Functions Variables Enumerations Enumerator Groups Pages
hamiltonian.cc
1 // -*- mode: c++; fill-column: 80; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 /*
3  Copyright (c) 2010 Juan Jose Garcia Ripoll
4 
5  Tensor is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published
7  by the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Library General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #include <mps/quantum.h>
21 #include <mps/hamiltonian.h>
22 
23 namespace mps {
24 
25  Hamiltonian::~Hamiltonian()
26  {
27  }
28 
29  index
30  Hamiltonian::dimension(index k) const
31  {
32  return local_term(k,0).dimension(1);
33  }
34 
35  const Indices
36  Hamiltonian::dimensions() const
37  {
38  index l = size();
39  Indices output(l);
40  for (index i = 0; i < l; i++) {
41  output.at(i) = dimension(i);
42  }
43  return output;
44  }
45 
46  const CTensor
47  Hamiltonian::interaction_left(index k, index ndx, double t) const
48  {
49  CTensor O1, O2;
50  decompose_operator(interaction(k, t), &O1, &O2);
51  return squeeze(O1(range(), range(), range(ndx)));
52  }
53 
54  const CTensor
55  Hamiltonian::interaction_right(index k, index ndx, double t) const
56  {
57  CTensor O1, O2;
58  decompose_operator(interaction(k, t), &O1, &O2);
59  return squeeze(O2(range(), range(), range(ndx)));
60  }
61 
62  index
63  Hamiltonian::interaction_depth(index k, double t) const
64  {
65  CTensor O1, O2;
66  decompose_operator(interaction(k, t), &O1, &O2);
67  return O1.dimension(3);
68  }
69 
70 } // namespace mps
virtual const CTensor interaction(index k, double t=0.0) const =0
Nearest neighbor interaction between sites 'k' and 'k+1'.
virtual const CTensor local_term(index k, double t=0.0) const =0
Local term of the Hamiltonian on site 'k'.
virtual index dimension(index k) const
Dimension of the Hilbert space on the k-th site.
Definition: hamiltonian.cc:30
void decompose_operator(const RTensor &H12, RTensor *H1, RTensor *H2)
Schmidt decomposition of a real operator.