6#include <boost/multi_array.hpp>
16template<
typename Symmetry,
typename Scalar=
double>
19typedef SparseMatrix<double,ColMajor,EIGEN_DEFAULT_SPARSE_INDEX_TYPE>
MatrixType;
27 void set (
size_t Daux1,
size_t Daux2,
size_t D)
31 data.resize(boost::extents[Daux1][Daux2]);
59 for (
size_t j=0; j<
N_cols; ++j)
61 Mout(0,j) =
data[i][j];
71 for (
size_t j=0; j<
N_rows; ++j)
73 Mout(j,0) =
data[j][i];
81 for (
size_t i=0; i<
N_rows; ++i)
82 for (
size_t j=0; j<
N_cols; ++j)
84 data[i][j].data.setZero();
94 assert(
N_rows ==
N_cols and
"auxdim called although SuperMatrix is not quadratic");
99 double memory (MEMUNIT memunit=GB)
const
103 for (
size_t i=0; i<
N_rows; ++i)
104 for (
size_t j=0; j<
N_cols; ++j)
106 return out += calc_memory<Scalar>(
data[i][j].
data, memunit);
114 size_t Dres =
data[0][0].data.rows();
115 for (
size_t i=0; i<
N_rows; ++i)
116 for (
size_t j=0; j<
N_cols; ++j)
118 assert(
data[i][j].
data.rows() == Dres);
119 assert(
data[i][j].
data.cols() == Dres);
124 std::vector<typename Symmetry::qType>
calc_qOp()
const
126 std::set<typename Symmetry::qType> qOps;
127 for (
size_t i=0; i<
N_rows; ++i)
128 for (
size_t j=0; j<
N_cols; ++j)
130 qOps.insert(
data[i][j].Q);
133 std::vector<typename Symmetry::qType> out(qOps.size());
134 copy(qOps.begin(), qOps.end(), out.begin());
144 boost::multi_array<OperatorType,2>
data;
148 for (
size_t i=0; i<
N_rows; ++i)
149 for (
size_t j=0; j<
N_cols; ++j)
151 data[i][j].data.resize(
D,
D);
156template<
typename Symmetry,
typename Scalar>
159 assert(M1.
D() == M2.
D());
167 else if (M1.
cols() == 1)
176 for (
size_t r1=0; r1<M1.
rows(); ++r1)
177 for (
size_t c1=0; c1<M1.
cols(); ++c1)
178 for (
size_t r2=0; r2<M2.
rows(); ++r2)
179 for (
size_t c2=0; c2<M2.
cols(); ++c2)
182 auto Qsum = Symmetry::reduceSilent(M1(r1,c1).Q, M2(r2,c2).Q);
184 assert(Qsum.size() == 1 and
"tensor_product of SuperMatrices called with wrong symmetry!");
185 Mout(r1*M2.
rows()+r2, c1*M2.
cols()+c2).Q = Qsum[0];
191template<
typename Symmetry,
typename Scalar>
204 else if (M1.
cols()==1 and M2.
cols()==1)
217 for (
size_t r1=0; r1<M1.
rows(); ++r1)
218 for (
size_t c1=0; c1<M1.
cols(); ++c1)
220 Mout(r1,c1) = M1(r1,c1);
223 for (
size_t r2=0; r2<M2.
rows(); ++r2)
224 for (
size_t c2=0; c2<M2.
cols(); ++c2)
226 Mout(R+r2,C+c2) = M2(r2,c2);
232template<
typename Symmetry,
typename Scalar>
235 os << std::showpos << std::setprecision(1) << std::fixed;
236 for (
int i=0; i<M.rows(); ++i)
238 for (
int n=0; n<M.D(); ++n)
240 for (
int j=0; j<M.cols(); ++j)
242 for (
int m=0; m<M.D(); ++m)
245 os << Matrix<Scalar,Dynamic,Dynamic>(M(i,j).data)(n,m);
249 if (n!=M.D()-1) {os << std::endl;}
251 if (i!=M.rows()-1) {os << std::endl << std::endl;}
SuperMatrix< Symmetry, Scalar > directSum(const SuperMatrix< Symmetry, Scalar > &M1, const SuperMatrix< Symmetry, Scalar > &M2)
std::ostream & operator<<(std::ostream &os, const SuperMatrix< Symmetry, Scalar > &M)
SuperMatrix< Symmetry, Scalar > tensor_product(const SuperMatrix< Symmetry, Scalar > &M1, const SuperMatrix< Symmetry, Scalar > &M2)
boost::multi_array< OperatorType, 2 > data
double memory(MEMUNIT memunit=GB) const
std::vector< typename Symmetry::qType > calc_qOp() const
SuperMatrix< Symmetry, Scalar > row(size_t i)
SiteOperator< Symmetry, Scalar > OperatorType
OperatorType & operator()(size_t i, size_t j)
void set(size_t Daux1, size_t Daux2, size_t D)
void setRowVector(size_t Daux, size_t D)
void setMatrix(size_t Daux, size_t D)
void setColVector(size_t Daux, size_t D)
SparseMatrix< double, ColMajor, EIGEN_DEFAULT_SPARSE_INDEX_TYPE > MatrixType
void innerResize(size_t D)
SuperMatrix< Symmetry, Scalar > col(size_t i)