ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mpotensor.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  * 2013-2013 by Bela Bauer <bauerb@phys.ethz.ch>
7  * Sebastian Keller <sebkelle@phys.ethz.ch>
8  *
9  * This software is part of the ALPS Applications, published under the ALPS
10  * Application License; you can use, redistribute it and/or modify it under
11  * the terms of the license, either version 1 or (at your option) any later
12  * version.
13  *
14  * You should have received a copy of the ALPS Application License along with
15  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
16  * available from http://alps.comp-phys.org/.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
21  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
22  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  *****************************************************************************/
27 
28 #ifndef MPOTENSOR_H
29 #define MPOTENSOR_H
30 
31 #include <iostream>
32 #include <set>
33 #include <iterator>
34 #include <boost/numeric/ublas/matrix_sparse.hpp>
35 #include <boost/numeric/ublas/matrix_proxy.hpp>
36 
39 #include "utils/function_objects.h"
40 #include "dmrg/models/op_handler.h"
42 
43 
44 template <class Matrix, class SymmGroup> class column_iterator;
45 template <class Matrix, class SymmGroup> class compressor;
46 template <class Matrix, class SymmGroup> class MPOIndexer;
47 
48 template<class Matrix, class SymmGroup>
49 class MPOTensor
50 {
51 public:
52  typedef std::size_t index_type;
53  typedef typename Matrix::value_type value_type;
55 
58  typedef boost::shared_ptr<OPTable<Matrix, SymmGroup> > op_table_ptr;
59 
60 private:
61  typedef std::pair<tag_type, value_type> internal_value_type;
62 
63  typedef boost::numeric::ublas::compressed_matrix< internal_value_type,
64  boost::numeric::ublas::column_major
65  , 0, boost::numeric::ublas::unbounded_array<index_type>
66  > CSCMatrix;
67 
68  typedef std::vector<std::set<index_type> > RowIndex;
69 
70 public:
72  typedef boost::numeric::ublas::matrix_column<const CSCMatrix> col_proxy;
73 
74 private:
75  typedef std::vector<boost::tuple<std::size_t, std::size_t, tag_type, value_type> > prempo_t;
76 
77 public:
78  MPOTensor(index_type = 1, index_type = 1, prempo_t const & = prempo_t(), op_table_ptr = op_table_ptr());
79 
80  index_type row_dim() const;
81  index_type col_dim() const;
82 
83  // tagged operator ()
84  // warning: this method allows to (indirectly) change the op in the table, all tags pointing to it will
85  // get a modified matrix!
86  // better design needed
87  void set(index_type li, index_type ri, op_t const & op, value_type scale_ = 1.0);
88 
89  // tagged operator() const
91  at(index_type left_index, index_type right_index) const;
92 
93  // warning: this method allows to (indirectly) change the op in the table, all tags pointing to it will
94  // get a modified matrix!
95  // better design needed
97  at(index_type left_index, index_type right_index);
98 
99  row_proxy row(index_type row_i) const;
100  col_proxy column(index_type col_i) const;
101 
102  tag_type tag_number(index_type left_index, index_type right_index) const;
104 
105  void multiply_by_scalar(const scalar_type&);
106  void divide_by_scalar(const scalar_type&);
107 
108  bool has(index_type left_index, index_type right_index) const;
109 
110  // These will be removed soon
111  friend class column_iterator<Matrix, SymmGroup>;
112  friend class compressor<Matrix, SymmGroup>;
113  friend class MPOIndexer<Matrix, SymmGroup>;
114 
115 
116  mutable std::vector<int> placement_l;
117  mutable std::vector<int> placement_r;
118 private:
119  index_type left_i, right_i;
120 
121  CSCMatrix col_tags;
122  RowIndex row_index;
123  op_table_ptr operator_table;
124 };
125 
126 // TODO: add swap
127 
129 
130 
131 #endif
maquis::traits::scalar_type< Matrix >::type scalar_type
Definition: mpotensor.h:54
void set(index_type li, index_type ri, op_t const &op, value_type scale_=1.0)
Definition: mpotensor.hpp:106
std::vector< int > placement_l
Definition: mpotensor.h:116
T::value_type type
Definition: traits.hpp:8
void divide_by_scalar(const scalar_type &)
Definition: mpotensor.hpp:165
index_type row_dim() const
Definition: mpotensor.hpp:179
tag_detail::tag_type tag_type
Definition: op_handler.h:46
op_table_ptr get_operator_table() const
Definition: mpotensor.hpp:173
declaration of block_matrix class
OPTable< Matrix, SymmGroup >::tag_type tag_type
Definition: mpotensor.h:56
tag_type tag_number(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:152
row_proxy row(index_type row_i) const
Definition: mpotensor.hpp:139
MPOTensor_detail::row_proxy< typename RowIndex::value_type::const_iterator > row_proxy
Definition: mpotensor.h:71
include one of the Index class definitions
MPOTensor_detail::const_term_descriptor< Matrix, SymmGroup > at(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:120
std::size_t index_type
Definition: mpotensor.h:52
bool has(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:95
std::vector< int > placement_r
Definition: mpotensor.h:117
MPOTensor(index_type=1, index_type=1, prempo_t const &=prempo_t(), op_table_ptr=op_table_ptr())
Definition: mpotensor.hpp:31
col_proxy column(index_type col_i) const
Definition: mpotensor.hpp:145
boost::shared_ptr< OPTable< Matrix, SymmGroup > > op_table_ptr
Definition: mpotensor.h:58
definition of MPOTensor object
boost::numeric::ublas::matrix_column< const CSCMatrix > col_proxy
Definition: mpotensor.h:72
void multiply_by_scalar(const scalar_type &)
Definition: mpotensor.hpp:157
index_type col_dim() const
Definition: mpotensor.hpp:185
OPTable< Matrix, SymmGroup >::op_t op_t
Definition: mpotensor.h:57
declaration of OPTable, TagHandler and KronHandler
Matrix::value_type value_type
Definition: mpotensor.h:53