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
block_matrix< Matrix, SymmGroup > Class Template Reference

#include <block_matrix.h>

Public Types

typedef Matrix::size_type size_type
 
typedef Matrix::value_type value_type
 
typedef
maquis::traits::scalar_type
< Matrix >::type 
scalar_type
 
typedef
maquis::traits::real_type
< Matrix >::type 
real_type
 

Public Member Functions

 block_matrix ()
 
 block_matrix (Index< SymmGroup > rows, Index< SymmGroup > cols)
 
 block_matrix (block_matrix const &)
 
template<class OtherMatrix >
 block_matrix (block_matrix< OtherMatrix, SymmGroup > const &)
 
block_matrixoperator= (block_matrix rhs)
 
template<class OtherMatrix >
block_matrixoperator= (const block_matrix< OtherMatrix, SymmGroup > &rhs)
 
Index< SymmGroup > const & left_basis () const
 
Index< SymmGroup > const & right_basis () const
 
void shift_basis (charge diff)
 
std::string description () const
 
std::size_t num_elements () const
 
Matrix & operator[] (size_type c)
 
Matrix const & operator[] (size_type c) const
 
value_typeoperator() (std::pair< charge, size_type > const &r, std::pair< charge, size_type > const &c)
 
value_type const & operator() (std::pair< charge, size_type > const &r, std::pair< charge, size_type > const &c) const
 
block_matrixoperator+= (block_matrix const &rhs)
 
block_matrixoperator-= (block_matrix const &rhs)
 
block_matrix const & operator*= (const scalar_type &v)
 
block_matrix const & operator/= (const scalar_type &v)
 
size_type n_blocks () const
 
size_type find_block (charge r, charge c) const
 
bool has_block (charge r, charge c) const
 
bool has_block (std::pair< charge, size_type > const &r, std::pair< charge, size_type > const &c) const
 
size_type insert_block (Matrix const &, charge, charge)
 
size_type insert_block (Matrix *, charge, charge)
 
void remove_block (charge r, charge c)
 
void remove_block (std::size_t which)
 
scalar_type trace () const
 
real_type norm () const
 
void transpose_inplace ()
 
void conjugate_inplace ()
 
void adjoint_inplace ()
 
void clear ()
 
template<class Generator >
void generate (Generator g)
 
void match_and_add_block (Matrix const &, charge, charge)
 
void reserve (charge, charge, std::size_t, std::size_t)
 
void reserve_pos (charge, charge, std::size_t, std::size_t)
 
void allocate_blocks ()
 
void resize_block (charge r, charge c, size_type new_r, size_type new_c, bool pretend=false)
 
Matrix const & operator() (charge r, charge c) const
 
Matrix & operator() (charge r, charge c)
 
template<class Archive >
void load (Archive &ar)
 
template<class Archive >
void save (Archive &ar) const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
bool reasonable () const
 
template<class OtherMatrix >
block_matrix< Matrix, SymmGroup > & operator= (const block_matrix< OtherMatrix, SymmGroup > &rhs)
 

Friends

class block_matrix< typename storage::constrained< Matrix >::type, SymmGroup >
 
void swap (block_matrix &x, block_matrix &y)
 

Detailed Description

template<class Matrix, class SymmGroup>
class block_matrix< Matrix, SymmGroup >

Definition at line 44 of file block_matrix.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef maquis::traits::real_type<Matrix>::type block_matrix< Matrix, SymmGroup >::real_type

Definition at line 53 of file block_matrix.h.

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

Definition at line 52 of file block_matrix.h.

template<class Matrix, class SymmGroup>
typedef Matrix::size_type block_matrix< Matrix, SymmGroup >::size_type

Definition at line 50 of file block_matrix.h.

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

Definition at line 51 of file block_matrix.h.

Constructor & Destructor Documentation

template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup >::block_matrix ( )

Definition at line 38 of file block_matrix.hpp.

39 {
40 }
template<class Matrix , class SymmGroup>
block_matrix< Matrix, SymmGroup >::block_matrix ( Index< SymmGroup >  rows,
Index< SymmGroup >  cols 
)

Definition at line 43 of file block_matrix.hpp.

45 : rows_(rows)
46 , cols_(cols)
47 {
48  assert(rows_.size() == cols_.size());
49  for (size_type k = 0; k < rows_.size(); ++k)
50  data_.push_back(new Matrix(rows_[k].second, cols_[k].second));
51 }
Matrix::size_type size_type
Definition: block_matrix.h:50
template<class Matrix , class SymmGroup>
block_matrix< Matrix, SymmGroup >::block_matrix ( block_matrix< Matrix, SymmGroup > const &  rhs)

Definition at line 54 of file block_matrix.hpp.

55 : rows_(rhs.left_basis())
56 , cols_(rhs.right_basis())
57 , data_(rhs.data_)
58 { }
template<class Matrix , class SymmGroup>
template<class OtherMatrix >
block_matrix< Matrix, SymmGroup >::block_matrix ( block_matrix< OtherMatrix, SymmGroup > const &  rhs)

Definition at line 62 of file block_matrix.hpp.

63 : rows_(rhs.left_basis())
64 , cols_(rhs.right_basis())
65 {
66  data_.reserve(rhs.n_blocks());
67  for (size_type k = 0; k < rhs.n_blocks(); ++k)
68  data_.push_back(new Matrix(rhs[k]));
69 }
size_type n_blocks() const
Index< SymmGroup > const & right_basis() const
Index< SymmGroup > const & left_basis() const
Matrix::size_type size_type
Definition: block_matrix.h:50

Member Function Documentation

template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::adjoint_inplace ( )

Definition at line 302 of file block_matrix.hpp.

303 {
304  std::for_each(data_.begin(), data_.end(), utils::functor_adjoint_inplace());
305  std::swap(rows_, cols_);
306 }
void swap(MPSTensor< Matrix, SymmGroup > &x, MPSTensor< Matrix, SymmGroup > &y)
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::allocate_blocks ( )

Definition at line 481 of file block_matrix.hpp.

482 {
483  for (std::size_t k = 0; k < n_blocks(); ++k)
484  resize(data_[k], rows_[k].second, cols_[k].second);
485 }
size_type n_blocks() const
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::clear ( )

Definition at line 323 of file block_matrix.hpp.

324 {
325  data_.clear();
326  rows_ = Index<SymmGroup>();
327  cols_ = Index<SymmGroup>();
328 }
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::conjugate_inplace ( )

Definition at line 296 of file block_matrix.hpp.

297 {
298  std::for_each(data_.begin(), data_.end(), utils::functor_conj_inplace());
299 }
template<class Matrix , class SymmGroup >
std::string block_matrix< Matrix, SymmGroup >::description ( ) const

Definition at line 177 of file block_matrix.hpp.

178 {
179  std::ostringstream oss;
180  oss << rows_ << cols_;
181  return oss.str();
182 }
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup >::size_type block_matrix< Matrix, SymmGroup >::find_block ( charge  r,
charge  c 
) const

Definition at line 198 of file block_matrix.hpp.

199 {
200  std::size_t p1 = rows_.position(r);
201  std::size_t p2 = cols_.position(c);
202 
203  if (p1 == p2 && p1 != rows_.size()) return p1;
204  else return n_blocks();
205 }
size_type n_blocks() const
template<class Matrix , class SymmGroup >
template<class Generator >
void block_matrix< Matrix, SymmGroup >::generate ( Generator  g)

Definition at line 317 of file block_matrix.hpp.

318 {
319  for(std::size_t k = 0; k < n_blocks(); ++k) ::detail::generate_impl(data_[k], g);
320 }
void generate_impl(Matrix &m, Generator g)
size_type n_blocks() const
template<class Matrix , class SymmGroup >
bool block_matrix< Matrix, SymmGroup >::has_block ( charge  r,
charge  c 
) const

Definition at line 208 of file block_matrix.hpp.

209 {
210  std::size_t p1 = rows_.position(r);
211  if (p1 == rows_.size()) return false;
212  std::size_t p2 = cols_.position(c);
213  if (p2 == cols_.size()) return false;
214  return (p1 == p2);
215 }
template<class Matrix , class SymmGroup >
bool block_matrix< Matrix, SymmGroup >::has_block ( std::pair< charge, size_type > const &  r,
std::pair< charge, size_type > const &  c 
) const

Definition at line 218 of file block_matrix.hpp.

220 {
221  return has_block(r.first, c.first);
222 }
bool has_block(charge r, charge c) const
template<class Matrix, class SymmGroup >
block_matrix< Matrix, SymmGroup >::size_type block_matrix< Matrix, SymmGroup >::insert_block ( Matrix const &  mtx,
charge  c1,
charge  c2 
)

Definition at line 132 of file block_matrix.hpp.

133 {
134  assert( !has_block(c1, c2) );
135 
136  std::pair<charge, size_type>
137  p1 = std::make_pair(c1, num_rows(mtx)),
138  p2 = std::make_pair(c2, num_cols(mtx));
139 
140  size_type i1 = rows_.insert(p1);
141  cols_.insert(i1, p2);
142  Matrix* block = new Matrix(mtx);
143  data_.insert(data_.begin() + i1, block);
144 
145  return i1;
146  //rows_.push_back(p1);
147  //cols_.push_back(p2);
148  //data_.push_back(mtx);
149 }
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:99
bool has_block(charge r, charge c) const
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:102
Matrix::size_type size_type
Definition: block_matrix.h:50
template<class Matrix, class SymmGroup >
block_matrix< Matrix, SymmGroup >::size_type block_matrix< Matrix, SymmGroup >::insert_block ( Matrix *  mtx,
charge  c1,
charge  c2 
)

Definition at line 152 of file block_matrix.hpp.

153 {
154  assert( !has_block(c1, c2) );
155 
156  std::pair<charge, size_type>
157  p1 = std::make_pair(c1, num_rows(*mtx)),
158  p2 = std::make_pair(c2, num_cols(*mtx));
159 
160  size_type i1 = rows_.insert(p1);
161  cols_.insert(i1, p2);
162  data_.insert(data_.begin() + i1, mtx);
163 
164  return i1;
165 }
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:99
bool has_block(charge r, charge c) const
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:102
Matrix::size_type size_type
Definition: block_matrix.h:50
template<class Matrix , class SymmGroup >
Index< SymmGroup > const & block_matrix< Matrix, SymmGroup >::left_basis ( ) const

Definition at line 168 of file block_matrix.hpp.

168 { return rows_; }
template<class Matrix , class SymmGroup >
template<class Archive >
void block_matrix< Matrix, SymmGroup >::load ( Archive &  ar)

Definition at line 407 of file block_matrix.hpp.

408 {
409  ar["rows_"] >> rows_;
410  ar["cols_"] >> cols_;
411 
412  data_.clear();
413  if (alps::is_complex<typename Matrix::value_type>() && !ar.is_complex("data_"))
414  {
416  std::vector<LoadMatrix> tmp;
417  ar["data_"] >> tmp;
418  for(typename std::vector<LoadMatrix>::const_iterator it = tmp.begin(); it != tmp.end(); ++it)
419  data_.push_back(new Matrix(maquis::bindings::matrix_cast<Matrix>(*it)));
420  } else {
421  std::vector<Matrix> tmp;
422  ar["data_"] >> tmp;
423  // TODO: is swap here possible?
424  for(typename std::vector<Matrix>::const_iterator it = tmp.begin(); it != tmp.end(); ++it)
425  data_.push_back(new Matrix(*it));
426  }
427 }
template<class Matrix, class SymmGroup >
void block_matrix< Matrix, SymmGroup >::match_and_add_block ( Matrix const &  mtx,
charge  c1,
charge  c2 
)

Definition at line 342 of file block_matrix.hpp.

343 {
344 
345  if (this->has_block(c1, c2))
346  {
347  if (num_rows(mtx) == num_rows((*this)(c1, c2)) &&
348  num_cols(mtx) == num_cols((*this)(c1, c2)))
349  (*this)(c1, c2) += mtx;
350  else if (num_rows(mtx) > num_rows((*this)(c1, c2)) &&
351  num_cols(mtx) > num_cols((*this)(c1, c2)))
352  {
353  resize_block(c1, c2, num_rows(mtx), num_cols(mtx));
354  (*this)(c1, c2) += mtx;
355  } else {
356  std::size_t maxrows = std::max(num_rows(mtx),
357  num_rows((*this)(c1, c2)));
358  std::size_t maxcols = std::max(num_cols(mtx),
359  num_cols((*this)(c1, c2)));
360 
361  Matrix cpy(mtx); // only in this case do we need to copy the argument matrix
362 
363  resize_block(c1, c2, maxrows, maxcols); // I think useless
364  resize(cpy, maxrows, maxcols);
365 
366  (*this)(c1, c2) += cpy;
367  }
368  } else
369  insert_block(mtx, c1, c2);
370 }
size_type insert_block(Matrix const &, charge, charge)
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:99
void resize_block(charge r, charge c, size_type new_r, size_type new_c, bool pretend=false)
bool has_block(charge r, charge c) const
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:102
template<class Matrix , class SymmGroup >
Matrix::size_type block_matrix< Matrix, SymmGroup >::n_blocks ( ) const

Definition at line 174 of file block_matrix.hpp.

174 { return data_.size(); }
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup >::real_type block_matrix< Matrix, SymmGroup >::norm ( ) const

Definition at line 281 of file block_matrix.hpp.

282 {
283  std::vector<real_type> vt; vt.reserve(data_.size());
284  semi_parallel_for(/*locale::compact(n_blocks())*/, std::size_t k = 0; k < n_blocks(); ++k) vt.push_back(norm_square(data_[k]));
285  return maquis::sqrt(maquis::accumulate(vt.begin(), vt.end(), real_type(0.)));
286 }
size_type n_blocks() const
#define semi_parallel_for(constraint,...)
maquis::traits::real_type< Matrix >::type real_type
Definition: block_matrix.h:53
T sqrt(T arg)
Definition: bindings.hpp:49
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
Definition: bindings.hpp:44
template<class Matrix , class SymmGroup >
std::size_t block_matrix< Matrix, SymmGroup >::num_elements ( ) const

Definition at line 497 of file block_matrix.hpp.

498 {
499  size_t ret = 0;
500  for (size_t k = 0; k < n_blocks(); ++k)
501  ret += num_rows(data_[k])*num_cols(data_[k]);
502  return ret;
503 }
size_type n_blocks() const
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:99
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:102
template<class Matrix , class SymmGroup >
Matrix::value_type & block_matrix< Matrix, SymmGroup >::operator() ( std::pair< charge, size_type > const &  r,
std::pair< charge, size_type > const &  c 
)

Definition at line 225 of file block_matrix.hpp.

227 {
228  assert( rows_.position(r.first) == cols_.position(c.first) );
229  return data_[rows_.position(r.first)](r.second, c.second);
230 }
template<class Matrix , class SymmGroup >
Matrix::value_type const & block_matrix< Matrix, SymmGroup >::operator() ( std::pair< charge, size_type > const &  r,
std::pair< charge, size_type > const &  c 
) const

Definition at line 233 of file block_matrix.hpp.

235 {
236  assert( rows_.position(r.first) == cols_.position(c.first) );
237  return data_[rows_.position(r.first)](r.second, c.second);
238 }
template<class Matrix, class SymmGroup>
Matrix const& block_matrix< Matrix, SymmGroup >::operator() ( charge  r,
charge  c 
) const
inline

Definition at line 132 of file block_matrix.h.

133  {
134  assert( has_block(r, c) );
135  assert( rows_.position(r) == cols_.position(c) );
136  return data_[rows_.position(r)];
137  }
bool has_block(charge r, charge c) const
template<class Matrix, class SymmGroup>
Matrix& block_matrix< Matrix, SymmGroup >::operator() ( charge  r,
charge  c 
)
inline

Definition at line 139 of file block_matrix.h.

140  {
141  assert( has_block(r, c) );
142  assert( rows_.position(r) == cols_.position(c) );
143  return data_[rows_.position(r)];
144  }
bool has_block(charge r, charge c) const
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > const & block_matrix< Matrix, SymmGroup >::operator*= ( const scalar_type v)

Definition at line 256 of file block_matrix.hpp.

257 {
258  // todo: check if "omp for" used in nested regions
259  semi_parallel_for(/*locale::compact(n_blocks())*/, std::size_t k = 0; k < n_blocks(); ++k) data_[k] *= v;
260  return *this;
261 }
size_type n_blocks() const
#define semi_parallel_for(constraint,...)
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > & block_matrix< Matrix, SymmGroup >::operator+= ( block_matrix< Matrix, SymmGroup > const &  rhs)

Definition at line 102 of file block_matrix.hpp.

103 {
104  for (size_type k = 0; k < rhs.n_blocks(); ++k)
105  {
106  charge rhs_rc = rhs.rows_[k].first;
107  charge rhs_cc = rhs.cols_[k].first;
108  if (this->has_block(rhs_rc, rhs_cc))
109  (*this)(rhs_rc, rhs_cc) += rhs.data_[k];
110  else
111  this->insert_block(rhs.data_[k], rhs_rc, rhs_cc);
112  }
113  return *this;
114 }
bool has_block(charge r, charge c) const
Matrix::size_type size_type
Definition: block_matrix.h:50
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > & block_matrix< Matrix, SymmGroup >::operator-= ( block_matrix< Matrix, SymmGroup > const &  rhs)

Definition at line 117 of file block_matrix.hpp.

118 {
119  for (size_type k = 0; k < rhs.n_blocks(); ++k)
120  {
121  charge rhs_rc = rhs.rows_[k].first;
122  charge rhs_cc = rhs.cols_[k].first;
123  if (this->has_block(rhs_rc, rhs_cc))
124  (*this)(rhs_rc, rhs_cc) -= rhs.data_[k];
125  else
126  this->insert_block(-1*rhs.data_[k], rhs_rc, rhs_cc);
127  }
128  return *this;
129 }
bool has_block(charge r, charge c) const
Matrix::size_type size_type
Definition: block_matrix.h:50
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > const & block_matrix< Matrix, SymmGroup >::operator/= ( const scalar_type v)

Definition at line 264 of file block_matrix.hpp.

265 {
266  // todo: check if "omp for" used in nested regions
267  semi_parallel_for(/*locale::compact(n_blocks())*/, std::size_t k = 0; k < n_blocks(); ++k) data_[k] /= v;
268  return *this;
269 }
size_type n_blocks() const
#define semi_parallel_for(constraint,...)
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup > & block_matrix< Matrix, SymmGroup >::operator= ( block_matrix< Matrix, SymmGroup >  rhs)

Definition at line 72 of file block_matrix.hpp.

73 {
74  swap(*this, rhs);
75  return *this;
76 }
friend void swap(block_matrix &x, block_matrix &y)
Definition: block_matrix.h:125
template<class Matrix, class SymmGroup>
template<class OtherMatrix >
block_matrix& block_matrix< Matrix, SymmGroup >::operator= ( const block_matrix< OtherMatrix, SymmGroup > &  rhs)
template<class Matrix, class SymmGroup>
template<class OtherMatrix >
block_matrix<Matrix, SymmGroup>& block_matrix< Matrix, SymmGroup >::operator= ( const block_matrix< OtherMatrix, SymmGroup > &  rhs)

Definition at line 80 of file block_matrix.hpp.

81 {
82  rows_ = rhs.rows_;
83  cols_ = rhs.cols_;
84  data_.resize(rhs.data_.size());
85  for(int k = 0; k < data_.size(); k++){
86  data_[k].resize(num_rows(rhs.data_[k]), num_cols(rhs.data_[k]));
87  data_[k] = rhs.data_[k];
88  }
89  return *this;
90 }
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:99
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:102
template<class Matrix , class SymmGroup >
Matrix & block_matrix< Matrix, SymmGroup >::operator[] ( size_type  c)

Definition at line 192 of file block_matrix.hpp.

192 { return data_[c]; }
template<class Matrix , class SymmGroup >
Matrix const & block_matrix< Matrix, SymmGroup >::operator[] ( size_type  c) const

Definition at line 195 of file block_matrix.hpp.

195 { return data_[c]; }
template<class Matrix , class SymmGroup >
bool block_matrix< Matrix, SymmGroup >::reasonable ( ) const

Definition at line 488 of file block_matrix.hpp.

489 {
490  for (size_t k=0; k<n_blocks(); ++k)
491  if (num_rows((*this)[k]) != rows_[k].second || num_cols((*this)[k]) != cols_[k].second)
492  return false;
493  return true;
494 }
size_type n_blocks() const
std::size_t num_rows(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:99
std::size_t num_cols(maquis::dmrg::one_matrix< T > const &m)
Definition: one_matrix.hpp:102
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::remove_block ( charge  r,
charge  c 
)

Definition at line 384 of file block_matrix.hpp.

385 {
386  assert( has_block(r, c) );
387  assert( rows_.position(r) == cols_.position(c) );
388 
389  std::size_t which = rows_.position(r);
390 
391  rows_.erase(rows_.begin() + which);
392  cols_.erase(cols_.begin() + which);
393  data_.erase(data_.begin() + which);
394 }
bool has_block(charge r, charge c) const
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::remove_block ( std::size_t  which)

Definition at line 396 of file block_matrix.hpp.

397 {
398  assert( which < data_.size() );
399 
400  rows_.erase(rows_.begin() + which);
401  cols_.erase(cols_.begin() + which);
402  data_.erase(data_.begin() + which);
403 }
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::reserve ( charge  c1,
charge  c2,
std::size_t  r,
std::size_t  c 
)

Definition at line 448 of file block_matrix.hpp.

450 {
451  if (this->has_block(c1, c2))
452  {
453  std::size_t maxrows = std::max(rows_[rows_.position(c1)].second, r);
454  std::size_t maxcols = std::max(cols_[cols_.position(c2)].second, c);
455 
456  rows_[rows_.position(c1)].second = maxrows;
457  cols_[cols_.position(c2)].second = maxcols;
458  } else {
459  std::pair<charge, size_type>
460  p1 = std::make_pair(c1, r),
461  p2 = std::make_pair(c2, c);
462 
463  assert(rows_.size() == cols_.size());
464  assert(rows_.size() == data_.size());
465 
466  size_type i1 = rows_.insert(p1);
467  cols_.insert(i1, p2);
468  Matrix* block = new Matrix(1,1);
469  data_.insert(data_.begin() + i1, block);
470  }
471  assert( this->has_block(c1,c2) );
472 }
bool has_block(charge r, charge c) const
Matrix::size_type size_type
Definition: block_matrix.h:50
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::reserve_pos ( charge  c1,
charge  c2,
std::size_t  ri,
std::size_t  ci 
)
inline

Definition at line 475 of file block_matrix.hpp.

477 { reserve(c1, c2, ri+1, ci+1); }
void reserve(charge, charge, std::size_t, std::size_t)
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::resize_block ( charge  r,
charge  c,
size_type  new_r,
size_type  new_c,
bool  pretend = false 
)

Definition at line 373 of file block_matrix.hpp.

376 {
377  if (!pretend)
378  resize((*this)(r,c), new_r, new_c);
379  rows_[rows_.position(r)].second = new_r;
380  cols_[cols_.position(c)].second = new_c;
381 }
template<class Matrix , class SymmGroup >
Index< SymmGroup > const & block_matrix< Matrix, SymmGroup >::right_basis ( ) const

Definition at line 171 of file block_matrix.hpp.

171 { return cols_; }
template<class Matrix , class SymmGroup >
template<class Archive >
void block_matrix< Matrix, SymmGroup >::save ( Archive &  ar) const

Definition at line 431 of file block_matrix.hpp.

432 {
433  ar["rows_"] << rows_;
434  ar["cols_"] << cols_;
435 
436  std::vector<Matrix> tmp(data_.begin(), data_.end());
437  ar["data_"] << tmp;
438 }
template<class Matrix , class SymmGroup >
template<class Archive >
void block_matrix< Matrix, SymmGroup >::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

Definition at line 442 of file block_matrix.hpp.

443 {
444  ar & rows_ & cols_ & data_;
445 }
template<class Matrix, class SymmGroup>
void block_matrix< Matrix, SymmGroup >::shift_basis ( charge  diff)

Definition at line 185 of file block_matrix.hpp.

186 {
187  rows_.shift(diff);
188  cols_.shift(diff);
189 }
template<class Matrix , class SymmGroup >
block_matrix< Matrix, SymmGroup >::scalar_type block_matrix< Matrix, SymmGroup >::trace ( ) const

Definition at line 273 of file block_matrix.hpp.

274 {
275  std::vector<scalar_type> vt; vt.reserve(data_.size());
276  std::transform(data_.begin(), data_.end(), back_inserter(vt), utils::functor_trace());
277  return maquis::accumulate(vt.begin(), vt.end(), scalar_type(0.));
278 }
maquis::traits::scalar_type< Matrix >::type scalar_type
Definition: block_matrix.h:52
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
Definition: bindings.hpp:44
template<class Matrix , class SymmGroup >
void block_matrix< Matrix, SymmGroup >::transpose_inplace ( )

Definition at line 289 of file block_matrix.hpp.

290 {
291  std::for_each(data_.begin(), data_.end(), utils::functor_transpose_inplace());
292  std::swap(rows_, cols_);
293 }
void swap(MPSTensor< Matrix, SymmGroup > &x, MPSTensor< Matrix, SymmGroup > &y)

Friends And Related Function Documentation

template<class Matrix, class SymmGroup>
friend class block_matrix< typename storage::constrained< Matrix >::type, SymmGroup >
friend

Definition at line 46 of file block_matrix.h.

template<class Matrix, class SymmGroup>
void swap ( block_matrix< Matrix, SymmGroup > &  x,
block_matrix< Matrix, SymmGroup > &  y 
)
friend

Definition at line 125 of file block_matrix.h.

126  {
127  swap(x.data_, y.data_);
128  swap(x.rows_, y.rows_);
129  swap(x.cols_, y.cols_);
130  }
friend void swap(block_matrix &x, block_matrix &y)
Definition: block_matrix.h:125

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