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

#include <mpstensor.h>

Public Types

typedef std::size_t size_type
 
typedef MultiIndex< SymmGroup >
::index_id 
index_id
 
typedef MultiIndex< SymmGroup >
::set_id 
set_id
 

Public Member Functions

 TwoSiteTensor (MPSTensor< Matrix, SymmGroup > const &mps1, MPSTensor< Matrix, SymmGroup > const &mps2)
 
 TwoSiteTensor (MPSTensor< Matrix, SymmGroup > const &twin_mps)
 
Index< SymmGroup > const & site_dim () const
 
Index< SymmGroup > const & row_dim () const
 
Index< SymmGroup > const & col_dim () const
 
block_matrix< Matrix, SymmGroup > & data ()
 
block_matrix< Matrix,
SymmGroup > const & 
data () const
 
TwoSiteTensor< Matrix,
SymmGroup > & 
operator<< (MPSTensor< Matrix, SymmGroup > const &rhs)
 
void make_left_paired () const
 
void make_both_paired () const
 
void make_right_paired () const
 
MPSTensor< Matrix, SymmGroup > make_mps () const
 
boost::tuple< MPSTensor
< Matrix, SymmGroup >
, MPSTensor< Matrix, SymmGroup >
, truncation_results
split_mps_l2r (std::size_t Mmax, double cutoff) const
 
boost::tuple< MPSTensor
< Matrix, SymmGroup >
, MPSTensor< Matrix, SymmGroup >
, truncation_results
split_mps_r2l (std::size_t Mmax, double cutoff) const
 
void swap_with (TwoSiteTensor &b)
 
template<class Archive >
void load (Archive &ar)
 
template<class Archive >
void save (Archive &ar) const
 

Friends

template<class Matrix_ , class SymmGroup_ >
std::ostream & operator<< (std::ostream &, TwoSiteTensor< Matrix_, SymmGroup_ > const &)
 
void swap (TwoSiteTensor &a, TwoSiteTensor &b)
 

Detailed Description

template<class Matrix, class SymmGroup>
class TwoSiteTensor< Matrix, SymmGroup >

Definition at line 46 of file mpstensor.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef MultiIndex<SymmGroup>::index_id TwoSiteTensor< Matrix, SymmGroup >::index_id

Definition at line 48 of file twositetensor.h.

template<class Matrix, class SymmGroup>
typedef MultiIndex<SymmGroup>::set_id TwoSiteTensor< Matrix, SymmGroup >::set_id

Definition at line 49 of file twositetensor.h.

template<class Matrix, class SymmGroup>
typedef std::size_t TwoSiteTensor< Matrix, SymmGroup >::size_type

Definition at line 47 of file twositetensor.h.

Constructor & Destructor Documentation

template<class Matrix , class SymmGroup >
TwoSiteTensor< Matrix, SymmGroup >::TwoSiteTensor ( MPSTensor< Matrix, SymmGroup > const &  mps1,
MPSTensor< Matrix, SymmGroup > const &  mps2 
)

Definition at line 43 of file twositetensor.hpp.

45 : phys_i( mps1.site_dim()*mps2.site_dim() )
46 , phys_i_left( mps1.site_dim() )
47 , phys_i_right( mps2.site_dim() )
48 , left_i( mps1.row_dim() )
49 , right_i( mps2.col_dim() )
50 , cur_storage(TSBothPaired)
51 , cur_normalization(Unorm)
52 {
53  mps1.make_left_paired();
54  mps2.make_right_paired();
55  gemm(mps1.data(), mps2.data(), data_);
56 
57 }
void make_left_paired() const
Definition: mpstensor.hpp:173
Index< SymmGroup > const & col_dim() const
Definition: mpstensor.hpp:161
void make_right_paired() const
Definition: mpstensor.hpp:188
Index< SymmGroup > const & row_dim() const
Definition: mpstensor.hpp:155
Index< SymmGroup > const & site_dim() const
Definition: mpstensor.hpp:149
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
block_matrix< Matrix, SymmGroup > & data()
Definition: mpstensor.hpp:423
template<class Matrix, class SymmGroup>
TwoSiteTensor< Matrix, SymmGroup >::TwoSiteTensor ( MPSTensor< Matrix, SymmGroup > const &  twin_mps)

Member Function Documentation

template<class Matrix , class SymmGroup >
Index< SymmGroup > const & TwoSiteTensor< Matrix, SymmGroup >::col_dim ( ) const

Definition at line 73 of file twositetensor.hpp.

74 {
75  return right_i;
76 }
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > & TwoSiteTensor< Matrix, SymmGroup >::data ( )

Definition at line 198 of file twositetensor.hpp.

199 {
200  return data_;
201 }
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > const & TwoSiteTensor< Matrix, SymmGroup >::data ( ) const

Definition at line 205 of file twositetensor.hpp.

206 {
207  return data_;
208 }
template<class Matrix, class SymmGroup>
template<class Archive >
void TwoSiteTensor< Matrix, SymmGroup >::load ( Archive &  ar)
template<class Matrix , class SymmGroup >
void TwoSiteTensor< Matrix, SymmGroup >::make_both_paired ( ) const

Definition at line 100 of file twositetensor.hpp.

101 {
102  if (cur_storage == TSBothPaired)
103  return;
104 
106  if (cur_storage == TSRightPaired) {
107  ts_reshape::reshape_right_to_both<Matrix, SymmGroup>(phys_i_left, phys_i_right, left_i, right_i, data_, tmp);
108  }
109  else {
110  ts_reshape::reshape_left_to_both<Matrix, SymmGroup>(phys_i_left, phys_i_right, left_i, right_i, data_, tmp);
111  }
112 
113  swap(data_, tmp);
114  cur_storage = TSBothPaired;
115 }
friend void swap(TwoSiteTensor &a, TwoSiteTensor &b)
Definition: twositetensor.h:82
template<class Matrix , class SymmGroup >
void TwoSiteTensor< Matrix, SymmGroup >::make_left_paired ( ) const

Definition at line 79 of file twositetensor.hpp.

80 {
81  if (cur_storage == TSLeftPaired)
82  return;
83 
85  if (cur_storage == TSBothPaired) {
86  ts_reshape::reshape_both_to_left<Matrix, SymmGroup>(phys_i_left, phys_i_right, left_i, right_i, data_, tmp);
87  } else {
88  // direct left to right reshape should not be needed
90  ts_reshape::reshape_both_to_left<Matrix, SymmGroup>(phys_i_left, phys_i_right, left_i, right_i, data_, tmp);
91  }
92 
93  swap(data_, tmp);
94  cur_storage = TSLeftPaired;
95 
96  // assert( right_i == data_.right_basis() );
97 }
friend void swap(TwoSiteTensor &a, TwoSiteTensor &b)
Definition: twositetensor.h:82
void make_both_paired() const
template<class Matrix , class SymmGroup >
MPSTensor< Matrix, SymmGroup > TwoSiteTensor< Matrix, SymmGroup >::make_mps ( ) const

Definition at line 139 of file twositetensor.hpp.

140 {
142  return MPSTensor<Matrix, SymmGroup>(phys_i, left_i, right_i, data_, LeftPaired);
143 }
void make_left_paired() const
template<class Matrix , class SymmGroup >
void TwoSiteTensor< Matrix, SymmGroup >::make_right_paired ( ) const

Definition at line 118 of file twositetensor.hpp.

119 {
120  if (cur_storage == TSRightPaired)
121  return;
122 
124  if (cur_storage == TSBothPaired)
125  ts_reshape::reshape_both_to_right<Matrix, SymmGroup>(phys_i_left, phys_i_right, left_i, right_i, data_, tmp);
126  else {
127  // direct left to right reshape should not be needed
129  ts_reshape::reshape_both_to_right<Matrix, SymmGroup>(phys_i_left, phys_i_right, left_i, right_i, data_, tmp);
130  }
131 
132  swap(data_, tmp);
133  cur_storage = TSRightPaired;
134 
135  // assert( left_i == data_.left_basis() );
136 }
friend void swap(TwoSiteTensor &a, TwoSiteTensor &b)
Definition: twositetensor.h:82
void make_both_paired() const
template<class Matrix , class SymmGroup >
TwoSiteTensor< Matrix, SymmGroup > & TwoSiteTensor< Matrix, SymmGroup >::operator<< ( MPSTensor< Matrix, SymmGroup > const &  rhs)

Definition at line 224 of file twositetensor.hpp.

225 {
226  this->make_left_paired();
227  rhs.make_left_paired();
228 
229  // Precondition: rhs.data() and this->data() have same shape if both are left_paired
230  // assert( rhs.row_dim() == this->row_dim() &&
231  // rhs.col_dim() == this->col_dim() &&
232  // rhs.site_dim() == this->site_dim() );
233  // assert( rhs.data().left_basis() == this->data().left_basis() &&
234  // rhs.data().right_basis() == this->data().right_basis() );
235 
236  left_i = rhs.row_dim();
237  right_i = rhs.col_dim();
238  this->data() = rhs.data();
239 
240  return *this;
241 
242 }
void make_left_paired() const
Definition: mpstensor.hpp:173
Index< SymmGroup > const & col_dim() const
Definition: mpstensor.hpp:161
Index< SymmGroup > const & row_dim() const
Definition: mpstensor.hpp:155
block_matrix< Matrix, SymmGroup > & data()
void make_left_paired() const
block_matrix< Matrix, SymmGroup > & data()
Definition: mpstensor.hpp:423
template<class Matrix , class SymmGroup >
Index< SymmGroup > const & TwoSiteTensor< Matrix, SymmGroup >::row_dim ( ) const

Definition at line 67 of file twositetensor.hpp.

68 {
69  return left_i;
70 }
template<class Matrix, class SymmGroup>
template<class Archive >
void TwoSiteTensor< Matrix, SymmGroup >::save ( Archive &  ar) const
template<class Matrix , class SymmGroup >
Index< SymmGroup > const & TwoSiteTensor< Matrix, SymmGroup >::site_dim ( ) const

Definition at line 61 of file twositetensor.hpp.

62 {
63  return phys_i;
64 }
template<class Matrix , class SymmGroup >
boost::tuple< MPSTensor< Matrix, SymmGroup >, MPSTensor< Matrix, SymmGroup >, truncation_results > TwoSiteTensor< Matrix, SymmGroup >::split_mps_l2r ( std::size_t  Mmax,
double  cutoff 
) const

Definition at line 147 of file twositetensor.hpp.

148 {
150 
151  typedef typename alps::numeric::associated_real_diagonal_matrix<Matrix>::type dmt;
154 
155  truncation_results trunc = svd_truncate(data_, u, v, s, cutoff, Mmax, true);
156 
157  MPSTensor<Matrix, SymmGroup> mps_tensor1(phys_i_left, left_i, u.right_basis(), u, LeftPaired);
158  assert( mps_tensor1.reasonable() );
159  gemm(s, v, u);
160  MPSTensor<Matrix, SymmGroup> mps_tensor2(phys_i_right, u.left_basis(), right_i, u, RightPaired);
161  assert( mps_tensor2.reasonable() );
162 
163  return boost::make_tuple(mps_tensor1, mps_tensor2, trunc);
164 }
truncation_results svd_truncate(block_matrix< Matrix, SymmGroup > const &M, block_matrix< Matrix, SymmGroup > &U, block_matrix< Matrix, SymmGroup > &V, block_matrix< DiagMatrix, SymmGroup > &S, double rel_tol, std::size_t Mmax, bool verbose=true)
Index< SymmGroup > const & right_basis() const
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
void make_both_paired() const
Index< SymmGroup > const & left_basis() const
template<class Matrix , class SymmGroup >
boost::tuple< MPSTensor< Matrix, SymmGroup >, MPSTensor< Matrix, SymmGroup >, truncation_results > TwoSiteTensor< Matrix, SymmGroup >::split_mps_r2l ( std::size_t  Mmax,
double  cutoff 
) const

Definition at line 168 of file twositetensor.hpp.

169 {
171 
172  typedef typename alps::numeric::associated_real_diagonal_matrix<Matrix>::type dmt;
175 
176  truncation_results trunc = svd_truncate(data_, u, v, s, cutoff, Mmax, true);
177 
178  MPSTensor<Matrix, SymmGroup> mps_tensor2(phys_i_right, v.left_basis(), right_i, v, RightPaired);
179 
180  gemm(u, s, v);
181  MPSTensor<Matrix, SymmGroup> mps_tensor1(phys_i_left, left_i, u.right_basis(), v, LeftPaired);
182 
183  return boost::make_tuple(mps_tensor1, mps_tensor2, trunc);
184 }
truncation_results svd_truncate(block_matrix< Matrix, SymmGroup > const &M, block_matrix< Matrix, SymmGroup > &U, block_matrix< Matrix, SymmGroup > &V, block_matrix< DiagMatrix, SymmGroup > &S, double rel_tol, std::size_t Mmax, bool verbose=true)
Index< SymmGroup > const & right_basis() const
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
void make_both_paired() const
Index< SymmGroup > const & left_basis() const
template<class Matrix , class SymmGroup >
void TwoSiteTensor< Matrix, SymmGroup >::swap_with ( TwoSiteTensor< Matrix, SymmGroup > &  b)

Definition at line 211 of file twositetensor.hpp.

212 {
213  swap(this->phys_i, b.phys_i);
214  swap(this->phys_i_left, b.phys_i_left);
215  swap(this->phys_i_right, b.phys_i_right);
216  swap(this->left_i, b.left_i);
217  swap(this->right_i, b.right_i);
218  swap(this->data_, b.data_);
219  swap(this->cur_storage, b.cur_storage);
220  swap(this->cur_normalization, b.cur_normalization);
221 }
friend void swap(TwoSiteTensor &a, TwoSiteTensor &b)
Definition: twositetensor.h:82

Friends And Related Function Documentation

template<class Matrix, class SymmGroup>
template<class Matrix_ , class SymmGroup_ >
std::ostream& operator<< ( std::ostream &  ,
TwoSiteTensor< Matrix_, SymmGroup_ > const &   
)
friend
template<class Matrix, class SymmGroup>
void swap ( TwoSiteTensor< Matrix, SymmGroup > &  a,
TwoSiteTensor< Matrix, SymmGroup > &  b 
)
friend

Definition at line 82 of file twositetensor.h.

83  {
84  a.swap_with(b);
85  }
void swap_with(TwoSiteTensor &b)

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