ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
MPOTensor< Matrix, SymmGroup > Class Template Reference

#include <mpotensor.h>

Public Types

typedef std::size_t index_type
 
typedef Matrix::value_type value_type
 
typedef
maquis::traits::scalar_type
< Matrix >::type 
scalar_type
 
typedef OPTable< Matrix,
SymmGroup >::tag_type 
tag_type
 
typedef OPTable< Matrix,
SymmGroup >::op_t 
op_t
 
typedef boost::shared_ptr
< OPTable< Matrix, SymmGroup > > 
op_table_ptr
 
typedef
MPOTensor_detail::row_proxy
< typename
RowIndex::value_type::const_iterator > 
row_proxy
 
typedef
boost::numeric::ublas::matrix_column
< const CSCMatrix > 
col_proxy
 

Public Member Functions

 MPOTensor (index_type=1, index_type=1, prempo_t const &=prempo_t(), op_table_ptr=op_table_ptr())
 
index_type row_dim () const
 
index_type col_dim () const
 
void set (index_type li, index_type ri, op_t const &op, value_type scale_=1.0)
 
MPOTensor_detail::const_term_descriptor
< Matrix, SymmGroup > 
at (index_type left_index, index_type right_index) const
 
MPOTensor_detail::term_descriptor
< Matrix, SymmGroup > 
at (index_type left_index, index_type right_index)
 
row_proxy row (index_type row_i) const
 
col_proxy column (index_type col_i) const
 
tag_type tag_number (index_type left_index, index_type right_index) const
 
op_table_ptr get_operator_table () const
 
void multiply_by_scalar (const scalar_type &)
 
void divide_by_scalar (const scalar_type &)
 
bool has (index_type left_index, index_type right_index) const
 

Public Attributes

std::vector< int > placement_l
 
std::vector< int > placement_r
 

Friends

class column_iterator< Matrix, SymmGroup >
 
class compressor< Matrix, SymmGroup >
 
class MPOIndexer< Matrix, SymmGroup >
 

Detailed Description

template<class Matrix, class SymmGroup>
class MPOTensor< Matrix, SymmGroup >

Definition at line 49 of file mpotensor.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef boost::numeric::ublas::matrix_column<const CSCMatrix> MPOTensor< Matrix, SymmGroup >::col_proxy

Definition at line 72 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef std::size_t MPOTensor< Matrix, SymmGroup >::index_type

Definition at line 52 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef OPTable<Matrix, SymmGroup>::op_t MPOTensor< Matrix, SymmGroup >::op_t

Definition at line 57 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef boost::shared_ptr<OPTable<Matrix, SymmGroup> > MPOTensor< Matrix, SymmGroup >::op_table_ptr

Definition at line 58 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef MPOTensor_detail::row_proxy<typename RowIndex::value_type::const_iterator> MPOTensor< Matrix, SymmGroup >::row_proxy

Definition at line 71 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef maquis::traits::scalar_type<Matrix>::type MPOTensor< Matrix, SymmGroup >::scalar_type

Definition at line 54 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef OPTable<Matrix, SymmGroup>::tag_type MPOTensor< Matrix, SymmGroup >::tag_type

Definition at line 56 of file mpotensor.h.

template<class Matrix, class SymmGroup>
typedef Matrix::value_type MPOTensor< Matrix, SymmGroup >::value_type

Definition at line 53 of file mpotensor.h.

Constructor & Destructor Documentation

template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::MPOTensor ( index_type  ld = 1,
index_type  rd = 1,
prempo_t const &  tags = prempo_t(),
op_table_ptr  tbl_ = op_table_ptr() 
)

Definition at line 31 of file mpotensor.hpp.

35 : left_i(ld)
36 , right_i(rd)
37 , col_tags(ld, rd)
38 , operator_table(tbl_)
39 {
40  using namespace boost::tuples;
41  typedef boost::tuple<index_type, index_type, tag_type, value_type> prempo_descriptor;
42  typedef std::vector<prempo_descriptor> converted_prempo_t;
43 
44  row_index.resize(ld);
45 
46  if (tags.size() > 0 && operator_table.get() != NULL) {
47  converted_prempo_t tmp_tags;
48 
49  // copy (due to const &) and convert to index_type
50  for (typename prempo_t::const_iterator it = tags.begin(); it != tags.end(); ++it) {
51  index_type row_i = (left_i == 1) ? 0 : index_type(get<0>(*it));
52  index_type col_i = (right_i == 1) ? 0 : index_type(get<1>(*it));
53  tmp_tags.push_back( prempo_descriptor(row_i, col_i, get<2>(*it), get<3>(*it)) );
54  }
55 
56 
57  std::sort(tmp_tags.begin(), tmp_tags.end(), MPOTensor_detail::col_cmp<prempo_descriptor>());
58 
59  for (typename converted_prempo_t::const_iterator it = tmp_tags.begin(); it != tmp_tags.end(); ++it) {
60  col_tags(get<0>(*it), get<1>(*it)) = std::make_pair(get<2>(*it), get<3>(*it));
61  row_index[get<0>(*it)].insert(get<1>(*it));
62  }
63  }
64  else {
65  // Initialize a private operator table
66  operator_table = op_table_ptr(new OPTable<Matrix, SymmGroup>());
67  }
68 }
std::size_t index_type
Definition: mpotensor.h:52
boost::shared_ptr< OPTable< Matrix, SymmGroup > > op_table_ptr
Definition: mpotensor.h:58

Member Function Documentation

template<class Matrix , class SymmGroup >
MPOTensor_detail::const_term_descriptor< Matrix, SymmGroup > MPOTensor< Matrix, SymmGroup >::at ( index_type  left_index,
index_type  right_index 
) const

Definition at line 120 of file mpotensor.hpp.

120  {
121  assert(this->has(left_index, right_index));
122  typename CSCMatrix::value_type const & p = col_tags(left_index, right_index);
123  return MPOTensor_detail::make_const_term_descriptor((*operator_table)[p.first], p.second);
124 }
const_term_descriptor< Matrix, SymmGroup > make_const_term_descriptor(block_matrix< Matrix, SymmGroup > const &op_, Scale s_)
bool has(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:95
template<class Matrix , class SymmGroup >
MPOTensor_detail::term_descriptor< Matrix, SymmGroup > MPOTensor< Matrix, SymmGroup >::at ( index_type  left_index,
index_type  right_index 
)

Definition at line 131 of file mpotensor.hpp.

131  {
132  if (!this->has(left_index, right_index))
133  this->set(left_index, right_index, op_t(), 1.);
134  typename CSCMatrix::value_type & p = col_tags(left_index, right_index).ref();
135  return MPOTensor_detail::term_descriptor<Matrix, SymmGroup>((*operator_table)[p.first], p.second);
136 }
void set(index_type li, index_type ri, op_t const &op, value_type scale_=1.0)
Definition: mpotensor.hpp:106
bool has(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:95
OPTable< Matrix, SymmGroup >::op_t op_t
Definition: mpotensor.h:57
template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::index_type MPOTensor< Matrix, SymmGroup >::col_dim ( ) const

Definition at line 185 of file mpotensor.hpp.

186 {
187  return right_i;
188 }
template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::col_proxy MPOTensor< Matrix, SymmGroup >::column ( index_type  col_i) const

Definition at line 145 of file mpotensor.hpp.

146 {
147  return col_proxy(col_tags, col_i);
148 }
boost::numeric::ublas::matrix_column< const CSCMatrix > col_proxy
Definition: mpotensor.h:72
template<class Matrix , class SymmGroup >
void MPOTensor< Matrix, SymmGroup >::divide_by_scalar ( const scalar_type v)

Definition at line 165 of file mpotensor.hpp.

166 {
167  for (typename CSCMatrix::iterator2 it2 = col_tags.begin2(); it2 != col_tags.end2(); ++it2)
168  for (typename CSCMatrix::iterator1 it1 = it2.begin(); it1 != it2.end(); ++it1)
169  it1->second /= v;
170 }
template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::op_table_ptr MPOTensor< Matrix, SymmGroup >::get_operator_table ( ) const

Definition at line 173 of file mpotensor.hpp.

174 {
175  return operator_table;
176 }
template<class Matrix , class SymmGroup >
bool MPOTensor< Matrix, SymmGroup >::has ( index_type  left_index,
index_type  right_index 
) const

Definition at line 95 of file mpotensor.hpp.

97 {
98  assert(left_index < left_i && right_index < right_i);
99  return col_tags.find_element(left_index, right_index) != NULL;
100 }
template<class Matrix , class SymmGroup >
void MPOTensor< Matrix, SymmGroup >::multiply_by_scalar ( const scalar_type v)

Definition at line 157 of file mpotensor.hpp.

158 {
159  for (typename CSCMatrix::iterator2 it2 = col_tags.begin2(); it2 != col_tags.end2(); ++it2)
160  for (typename CSCMatrix::iterator1 it1 = it2.begin(); it1 != it2.end(); ++it1)
161  it1->second *= v;
162 }
template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::row_proxy MPOTensor< Matrix, SymmGroup >::row ( index_type  row_i) const

Definition at line 139 of file mpotensor.hpp.

140 {
141  return row_proxy(row_index[row_i].begin(), row_index[row_i].end());
142 }
MPOTensor_detail::row_proxy< typename RowIndex::value_type::const_iterator > row_proxy
Definition: mpotensor.h:71
template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::index_type MPOTensor< Matrix, SymmGroup >::row_dim ( ) const

Definition at line 179 of file mpotensor.hpp.

180 {
181  return left_i;
182 }
template<class Matrix , class SymmGroup >
void MPOTensor< Matrix, SymmGroup >::set ( index_type  li,
index_type  ri,
op_t const &  op,
value_type  scale_ = 1.0 
)

Definition at line 106 of file mpotensor.hpp.

106  {
107  if (this->has(li, ri)) {
108  col_tags.find_element(li, ri)->second = scale_;
109  (*operator_table)[col_tags.find_element(li, ri)->first] = op;
110  }
111  else {
112  tag_type new_tag = operator_table->register_op(op);
113  col_tags(li, ri) = internal_value_type(new_tag, scale_);
114  row_index[li].insert(ri);
115  }
116 }
OPTable< Matrix, SymmGroup >::tag_type tag_type
Definition: mpotensor.h:56
bool has(index_type left_index, index_type right_index) const
Definition: mpotensor.hpp:95
template<class Matrix , class SymmGroup >
MPOTensor< Matrix, SymmGroup >::tag_type MPOTensor< Matrix, SymmGroup >::tag_number ( index_type  left_index,
index_type  right_index 
) const

Definition at line 152 of file mpotensor.hpp.

152  {
153  return col_tags(left_index, right_index).first;
154 }

Friends And Related Function Documentation

template<class Matrix, class SymmGroup>
friend class column_iterator< Matrix, SymmGroup >
friend

Definition at line 111 of file mpotensor.h.

template<class Matrix, class SymmGroup>
friend class compressor< Matrix, SymmGroup >
friend

Definition at line 112 of file mpotensor.h.

template<class Matrix, class SymmGroup>
friend class MPOIndexer< Matrix, SymmGroup >
friend

Definition at line 113 of file mpotensor.h.

Member Data Documentation

template<class Matrix, class SymmGroup>
std::vector<int> MPOTensor< Matrix, SymmGroup >::placement_l
mutable

Definition at line 116 of file mpotensor.h.

template<class Matrix, class SymmGroup>
std::vector<int> MPOTensor< Matrix, SymmGroup >::placement_r
mutable

Definition at line 117 of file mpotensor.h.


The documentation for this class was generated from the following files: