33 template<
class Matrix,
class SymmGroup>
40 if (c1 == 1 && c2 == 0)
42 else if (c1 == 0 && c2 == 1)
44 else if (c1 == 1 && c2 == 1)
46 else if (c1 == 0 && c2 == 0)
53 template<
class Matrix,
class SymmGroup>
55 std::string s = std::string(),
56 int p = 0,
int start = 0)
58 for (
size_t k = 0; k < mpo[p].col_dim(); ++k)
60 if (mpo[p].at(start,k).op.n_blocks() == 0)
63 std::ostringstream oss;
66 oss <<
" " <<
identify_op(mpo[p].at(start, k).op) <<
" ";
67 if (p+1 < mpo.length())
70 maquis::cout << s+oss.str() << std::endl;
74 template<
class Matrix,
class SymmGroup>
82 scale *= access.
scale;
83 ss <<
" {" << mpo[p].tag_number(b1,b2) <<
"}(" << p <<
")";
86 if (p == mpo.size()-1) {
87 maquis::cout <<
"---" << std::endl;
88 maquis::cout <<
"scale: " << scale << std::endl;
89 maquis::cout <<
"term: " << ss.str() << std::endl;
95 row_proxy myrow = mpo[p+1].row(b2);
96 for (
typename row_proxy::const_iterator row_it = myrow.begin(); row_it != myrow.end(); ++row_it)
101 template<
class Matrix,
class SymmGroup>
107 for (std::size_t k = 0; k < in_mpo[p].col_dim(); ++k)
109 if (!in_mpo[p].has(start,k))
111 if (in_mpo[p].at(start,k).op.n_blocks() == 0)
114 ops[p] = boost::make_tuple(start, k, in_mpo[p].at(start, k).op * in_mpo[p].at(start, k).scale);
116 if (p+1 < in_mpo.length())
120 assert( ops.size() == out_mpo.length() );
121 using boost::tuples::get;
122 for (std::size_t t = 0; t < in_mpo.length(); ++t) {
125 o.
op = get<2>(ops[t]);
133 template<
class Matrix,
class SymmGroup>
137 for (std::size_t p = 0; p < ret.length(); ++p)
140 std::vector<boost::tuple<int, int, block_matrix<Matrix, SymmGroup> > > prempo(mpo.length());
145 template<
class Matrix,
class SymmGroup>
149 typedef typename SymmGroup::charge charge;
153 size_t L = mpo.length();
157 for (
size_t p = 0; p < L; ++p)
164 for (index_type r1 = 0; r1 < inp.
row_dim(); ++r1)
166 row_proxy row1 = inp.
row(r1);
167 for (index_type r2 = 0; r2 < inp.
row_dim(); ++r2)
169 row_proxy row2 = inp.
row(r2);
170 for (
typename row_proxy::const_iterator it1 = row1.begin(); it1 != row1.end(); ++it1)
172 index_type c1 = it1.index();
173 for (
typename row_proxy::const_iterator it2 = row2.begin(); it2 != row2.end(); ++it2) {
174 index_type c2 = it2.index();
176 assert(inp.
has(r1, c1));
177 assert(inp.
has(r2, c2));
180 gemm(inp.
at(r1, c1).op, inp.
at(r2, c2).op, t);
181 if (t.n_blocks() > 0)
183 t * (inp.
at(r1, c1).scale * inp.
at(r2, c2).scale));
192 maquis::cout <<
"Done squaring." << std::endl;
195 maquis::cout <<
"Done cleaning up." << std::endl;
200 template<
class Matrix,
class SymmGroup>
205 typedef typename MPOTensor<Matrix, SymmGroup>::CSCMatrix CSCMatrix;
207 maquis::cout <<
"Zeroing out MPO after site " << p0 << std::endl;
209 for (
int p = p0+1; p < mpo.size(); ++p) {
210 for (
int k = 2; k < mpo[p].row_dim(); ++k)
211 for (
int l = 2; l < mpo[p].col_dim(); ++l)
213 mpo[p].set(k,l, mpo[p].at(k,l).op, 0.0);
216 mpo[p].set(0,1, mpo[p].at(0,1).op, 0.0);
std::string identify_op(block_matrix< Matrix, SymmGroup > const &m)
MPO< Matrix, SymmGroup > cleanup_mpo(MPO< Matrix, SymmGroup > const &mpo)
index_type row_dim() const
size_type n_blocks() const
void cleanup_mpo_(MPO< Matrix, SymmGroup > const &in_mpo, MPO< Matrix, SymmGroup > &out_mpo, std::vector< boost::tuple< int, int, block_matrix< Matrix, SymmGroup > > > &ops, int p, int start)
row_proxy row(index_type row_i) const
void follow_mpo(MPO< Matrix, SymmGroup > const &mpo, std::string s=std::string(), int p=0, int start=0)
MPOTensor_detail::const_term_descriptor< Matrix, SymmGroup > at(index_type left_index, index_type right_index) const
MPO< Matrix, SymmGroup > zero_after(MPO< Matrix, SymmGroup > mpo, int p0)
definition of MPO class (vector of MPOTensor)
bool has(index_type left_index, index_type right_index) const
MPO< Matrix, SymmGroup > square_mpo(MPO< Matrix, SymmGroup > const &mpo)
declaration of MPOTensor object
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)
boost::numeric::ublas::matrix_column< const CSCMatrix > col_proxy
Index< SymmGroup > const & left_basis() const
index_type col_dim() const
void follow_and_print_terms(MPO< Matrix, SymmGroup > const &mpo, int p, int b1, int b2, std::string s="", typename MPOTensor< Matrix, SymmGroup >::value_type scale=1.)
Matrix::value_type value_type