38 template <
class Matrix,
class SymmGroup>
50 alpha_i.
insert( std::make_pair(SymmGroup::IdentityCharge,1) );
51 beta_i.
insert( std::make_pair(SymmGroup::IdentityCharge,1) );
56 std::vector<std::pair<index_id, bool> > in_left, in_right;
57 std::vector<std::pair<index_id, index_id> > phys_ids;
60 for (
size_t i=0; i<length; ++i) {
63 phys_ids.push_back( std::make_pair(id1, id2) );
65 in_left.push_back( std::make_pair(id1,
true) );
66 in_right.push_back( std::make_pair(id2,
true) );
69 in_left.push_back( std::make_pair(beta,
true) );
70 in_right.push_back( std::make_pair(alpha,
true) );
72 set_id curr_s = midx.
create_set(in_left, in_right);
75 for (
size_t p=0; p<length; ++p) {
76 assert( phys_ids.size() == length-p );
83 std::vector<std::pair<index_id, bool> > svd_left, svd_right;
85 for (
size_t i=0; i<length-p; ++i) {
87 svd_left.push_back( std::make_pair(phys_ids[i].first,
true) );
88 svd_left.push_back( std::make_pair(phys_ids[i].second,
false) );
90 svd_right.push_back( std::make_pair(phys_ids[i].first,
false) );
91 svd_right.push_back( std::make_pair(phys_ids[i].second,
true) );
94 svd_left.push_back( std::make_pair(alpha,
false) );
95 svd_right.push_back( std::make_pair(beta,
false) );
97 set_id svd_s = midx.
create_set(svd_left, svd_right);
99 reshape(midx, curr_s, svd_s, block, btmp);
105 gemm(U, Ssqrt, btmp);
106 gemm(Ssqrt, V, block);
108 assert( phys_ids.size() == 1 );
109 std::vector<std::pair<index_id, bool> > vec_left, vec_right;
110 index_id id1 = phys_ids[0].first;
111 index_id id2 = phys_ids[0].second;
112 vec_left.push_back( std::make_pair(id1,
true) );
113 vec_left.push_back( std::make_pair(id2,
false) );
114 vec_left.push_back( std::make_pair(alpha,
false) );
115 vec_right.push_back( std::make_pair(beta,
false) );
117 set_id new_s = midx.
create_set(vec_left, vec_right);
119 reshape(midx, curr_s, new_s, block, btmp);
127 index_id phys_mpo1 = midx_mpo.insert_index(phys_i);
128 index_id phys_mpo2 = midx_mpo.insert_index(phys_i);
129 index_id aux_right = midx_mpo.insert_index(aux_right_i);
131 std::vector<std::pair<index_id, bool> > vec_curr_mpo_l, vec_curr_mpo_r;
132 vec_curr_mpo_l.push_back( std::make_pair(phys_mpo1,
true) );
133 vec_curr_mpo_l.push_back( std::make_pair(phys_mpo2,
false) );
134 vec_curr_mpo_l.push_back( std::make_pair(aux_left,
false) );
135 vec_curr_mpo_r.push_back( std::make_pair(aux_right,
false) );
137 set_id curr_mpo_s = midx_mpo.create_set(vec_curr_mpo_l, vec_curr_mpo_r);
142 for (
size_t r=0; r<mpo[p].row_dim(); ++r)
143 for (
size_t c=0; c<mpo[p].col_dim(); ++c)
144 if (mpo[p].has(r, c))
145 mpo[p](r, c).allocate_blocks();
148 it != midx_mpo.end();
152 boost::tie(lc, rc) = midx_mpo.get_coords(curr_mpo_s, *it);
153 if (!btmp.has_block(lc.first, rc.first))
156 size_t li = aux_left_i.
position( (*it)[aux_left] );
157 size_t ri = aux_right_i.
position( (*it)[aux_right] );
159 if (btmp(lc, rc) != 0.) {
161 mpo[p](li, ri).reserve((*it)[phys_mpo1].first, (*it)[phys_mpo2].first,
164 mpo[p](li, ri)((*it)[phys_mpo1], (*it)[phys_mpo2]) = btmp(lc, rc);
174 std::vector<std::pair<index_id, bool> > out_left, out_right;
178 for (
size_t i=p+1; i<length; ++i) {
181 phys_ids.push_back( std::make_pair(id1, id2) );
183 out_right.push_back( std::make_pair(id1,
false) );
184 out_right.push_back( std::make_pair(id2,
true) );
187 out_left.push_back( std::make_pair(alpha,
false) );
188 out_right.push_back( std::make_pair(beta,
false) );
190 curr_s = midx.
create_set(out_left, out_right);
void run(std::string const &chkp1, std::string const &chkp2)
MPO< Matrix, SymmGroup > block_to_mpo(Index< SymmGroup > const &phys_i, block_matrix< Matrix, SymmGroup > block, std::size_t length)
std::pair< charge, elem_id > coord_t
declaration of block_matrix class
std::size_t size_of_block(charge c) const
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
index_id insert_index(index_t const &idx)
set_id create_set(std::vector< std::pair< index_id, bool > > const &vec_left, std::vector< std::pair< index_id, bool > > const &vec_right)
block_matrix< Matrix, SymmGroup > adjoin(block_matrix< Matrix, SymmGroup > const &m)
definition of MPO class (vector of MPOTensor)
void svd(block_matrix< Matrix, SymmGroup > const &M, block_matrix< Matrix, SymmGroup > &U, block_matrix< Matrix, SymmGroup > &V, block_matrix< DiagMatrix, SymmGroup > &S)
declaration of MPOTensor object
std::size_t position(charge c) const
algorithms for block_matrix (gemm, svd, etc.)
std::size_t insert(std::pair< charge, std::size_t > const &x)
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
Index< SymmGroup > const & left_basis() const
std::size_t sum_of_sizes() const