27 template<
typename SparseMatrixType>
void sparse_block(
const SparseMatrixType&
ref)
36 typedef typename SparseMatrixType::StorageIndex StorageIndex;
44 Scalar s1 = internal::random<Scalar>();
48 initSparse<Scalar>(
density, refMat,
m);
53 for (
int t=0;
t<10; ++
t)
127 initSparse<Scalar>(
density, refMat2,
m2);
128 Index j0 = internal::random<Index>(0,outer-1);
129 Index j1 = internal::random<Index>(0,outer-1);
130 Index r0 = internal::random<Index>(0,
rows-1);
131 Index c0 = internal::random<Index>(0,
cols-1);
141 refMat2.row(r0) *=
Scalar(3);
145 refMat2.col(c0) *=
Scalar(4);
149 refMat2.row(r0) /=
Scalar(3);
153 refMat2.col(c0) /=
Scalar(4);
161 m3.reserve(VectorXi::Constant(outer,
int(inner/2)));
164 m3.insertByOuterInner(
j,k) = internal::convert_index<StorageIndex>(k+1);
179 VERIFY(
m3.innerVector(
j0).nonZeros() ==
m3.transpose().innerVector(
j0).nonZeros());
190 initSparse<Scalar>(
density, refMat2,
m2);
191 if(internal::random<float>(0,1)>0.5
f)
m2.makeCompressed();
192 Index j0 = internal::random<Index>(0,outer-2);
193 Index j1 = internal::random<Index>(0,outer-2);
195 if(SparseMatrixType::IsRowMajor)
199 if(SparseMatrixType::IsRowMajor)
201 refMat2.middleRows(
j0,n0)+refMat2.middleRows(
j1,n0));
204 refMat2.block(0,
j0,
rows,n0)+refMat2.block(0,
j1,
rows,n0));
208 VERIFY(
m2.innerVectors(
j0,n0).nonZeros() ==
m2.transpose().innerVectors(
j0,n0).nonZeros());
210 m2.innerVectors(
j0,n0) =
m2.innerVectors(
j0,n0) +
m2.innerVectors(
j1,n0);
211 if(SparseMatrixType::IsRowMajor)
212 refMat2.middleRows(
j0,n0) = (refMat2.middleRows(
j0,n0) + refMat2.middleRows(
j1,n0)).
eval();
214 refMat2.middleCols(
j0,n0) = (refMat2.middleCols(
j0,n0) + refMat2.middleCols(
j1,n0)).
eval();
223 initSparse<Scalar>(
density, refMat2,
m2);
224 Index j0 = internal::random<Index>(0,outer-2);
225 Index j1 = internal::random<Index>(0,outer-2);
227 if(SparseMatrixType::IsRowMajor)
232 if(SparseMatrixType::IsRowMajor)
234 refMat2.block(
j0,0,n0,
cols)+refMat2.block(
j1,0,n0,
cols));
237 refMat2.block(0,
j0,
rows,n0)+refMat2.block(0,
j1,
rows,n0));
239 Index i = internal::random<Index>(0,
m2.outerSize()-1);
240 if(SparseMatrixType::IsRowMajor) {
241 m2.innerVector(
i) =
m2.innerVector(
i) * s1;
242 refMat2.row(
i) = refMat2.row(
i) * s1;
245 m2.innerVector(
i) =
m2.innerVector(
i) * s1;
246 refMat2.col(
i) = refMat2.col(
i) * s1;
250 Index r0 = internal::random<Index>(0,
rows-2);
251 Index c0 = internal::random<Index>(0,
cols-2);
269 Index n = internal::random<Index>(1,10);
272 Index o1 = internal::random<Index>(0,outer-1);
273 Index o2 = internal::random<Index>(0,outer-1);
274 if(SparseMatrixType::IsRowMajor)
276 m3.innerVector(o1) =
m2.row(o2);
277 refMat3.row(o1) = refMat2.row(o2);
281 m3.innerVector(o1) =
m2.col(o2);
282 refMat3.col(o1) = refMat2.col(o2);
284 if(internal::random<bool>())
296 int r = Eigen::internal::random<int>(1,200),
c = Eigen::internal::random<int>(1,200);
297 if(Eigen::internal::random<int>(0,4) == 0) {
310 r = Eigen::internal::random<int>(1,100);
311 c = Eigen::internal::random<int>(1,100);
312 if(Eigen::internal::random<int>(0,4) == 0) {
318 #ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW