12 #define EIGEN_SPARSE_TRANSPOSED_COPY_PLUGIN {nb_transposed_copies++;}
13 #define VERIFY_TRANSPOSITION_COUNT(XPR,N) {\
14 nb_transposed_copies = 0; \
16 if(nb_transposed_copies!=N) std::cerr << "nb_transposed_copies == " << nb_transposed_copies << "\n"; \
17 VERIFY( (#XPR) && nb_transposed_copies==N ); \
24 for(
Index k = 0; k<
mat.outerSize(); ++k)
27 for(
typename T::InnerIterator it(
mat,k); it; ++it)
49 typedef typename SparseMatrixType::StorageIndex StorageIndex;
59 OtherSparseMatrixType
res;
64 up =
mat.template triangularView<Upper>();
67 up_sym_d = mat_d.template selfadjointView<Upper>();
68 lo_sym_d = mat_d.template selfadjointView<Lower>();
95 res_d =
mat*
p.inverse();
96 VERIFY(
res.isApprox(res_d) &&
"mat*inv(p)");
101 res_d =
p.inverse()*mat_d;
102 VERIFY(
res.isApprox(res_d) &&
"inv(p)*mat");
107 res_d = (
p * mat_d) *
p.inverse();
108 VERIFY(
res.isApprox(res_d) &&
"p*mat*inv(p)");
113 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper to full");
117 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower to full");
122 VERIFY(
res.isApprox(res_d) &&
"upper selfadjoint to full");
126 VERIFY(
res.isApprox(res_d) &&
"lower selfadjoint full");
131 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper to full");
135 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower to full");
139 VERIFY(
res.isApprox(res_d) &&
"upper selfadjoint to full");
143 VERIFY(
res.isApprox(res_d) &&
"lower selfadjoint full");
146 res.template selfadjointView<Upper>() =
mat.template selfadjointView<Upper>();
147 res_d = up_sym_d.template triangularView<Upper>();
148 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper to upper");
150 res.template selfadjointView<Lower>() =
mat.template selfadjointView<Upper>();
152 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper to lower");
154 res.template selfadjointView<Upper>() =
mat.template selfadjointView<Lower>();
155 res_d = lo_sym_d.template triangularView<Upper>();
156 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower to upper");
158 res.template selfadjointView<Lower>() =
mat.template selfadjointView<Lower>();
160 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower to lower");
164 res.template selfadjointView<Upper>() =
mat.template selfadjointView<Upper>().twistedBy(
p);
165 res_d = ((
p * up_sym_d) *
p.inverse()).
eval().template triangularView<Upper>();
166 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper twisted to upper");
168 res.template selfadjointView<Upper>() =
mat.template selfadjointView<Lower>().twistedBy(
p);
169 res_d = ((
p * lo_sym_d) *
p.inverse()).
eval().template triangularView<Upper>();
170 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower twisted to upper");
172 res.template selfadjointView<Lower>() =
mat.template selfadjointView<Lower>().twistedBy(
p);
174 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower twisted to lower");
176 res.template selfadjointView<Lower>() =
mat.template selfadjointView<Upper>().twistedBy(
p);
178 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper twisted to lower");
181 res.template selfadjointView<Upper>() = up.template selfadjointView<Upper>().twistedBy(
p);
182 res_d = ((
p * up_sym_d) *
p.inverse()).
eval().template triangularView<Upper>();
183 VERIFY(
res.isApprox(res_d) &&
"upper selfadjoint twisted to upper");
185 res.template selfadjointView<Upper>() = lo.template selfadjointView<Lower>().twistedBy(
p);
186 res_d = ((
p * lo_sym_d) *
p.inverse()).
eval().template triangularView<Upper>();
187 VERIFY(
res.isApprox(res_d) &&
"lower selfadjoint twisted to upper");
189 res.template selfadjointView<Lower>() = lo.template selfadjointView<Lower>().twistedBy(
p);
191 VERIFY(
res.isApprox(res_d) &&
"lower selfadjoint twisted to lower");
193 res.template selfadjointView<Lower>() = up.template selfadjointView<Upper>().twistedBy(
p);
195 VERIFY(
res.isApprox(res_d) &&
"upper selfadjoint twisted to lower");
199 res_d = (
p * up_sym_d) *
p.inverse();
200 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint upper twisted to full");
203 res_d = (
p * lo_sym_d) *
p.inverse();
204 VERIFY(
res.isApprox(res_d) &&
"full selfadjoint lower twisted to full");
207 res_d = (
p * up_sym_d) *
p.inverse();
208 VERIFY(
res.isApprox(res_d) &&
"upper selfadjoint twisted to full");
211 res_d = (
p * lo_sym_d) *
p.inverse();
212 VERIFY(
res.isApprox(res_d) &&
"lower selfadjoint twisted to full");
226 int s = Eigen::internal::random<int>(1,50);