27 const Index inner = ref.innerSize();
28 const Index outer = ref.outerSize();
32 typedef typename SparseMatrixType::StorageIndex StorageIndex;
40 Scalar s1 = internal::random<Scalar>();
44 initSparse<Scalar>(
density, refMat,
m);
49 for (
int t = 0;
t < 10; ++
t) {
50 Index j = internal::random<Index>(0,
cols - 2);
51 Index i = internal::random<Index>(0,
rows - 2);
53 Index h = internal::random<Index>(1,
rows -
i);
111 initSparse<Scalar>(
density, refMat2,
m2);
112 Index j0 = internal::random<Index>(0, outer - 1);
113 Index j1 = internal::random<Index>(0, outer - 1);
114 Index r0 = internal::random<Index>(0,
rows - 1);
115 Index c0 = internal::random<Index>(0,
cols - 1);
125 refMat2.row(r0) *=
Scalar(3);
129 refMat2.col(c0) *=
Scalar(4);
133 refMat2.row(r0) /=
Scalar(3);
137 refMat2.col(c0) /=
Scalar(4);
145 m3.reserve(VectorXi::Constant(outer,
int(inner / 2)));
148 m3.insertByOuterInner(
j,
k) = internal::convert_index<StorageIndex>(
k + 1);
159 VERIFY(m3.innerVector(j0).nonZeros() == m3.transpose().innerVector(j0).nonZeros());
170 initSparse<Scalar>(
density, refMat2,
m2);
171 if (internal::random<float>(0, 1) > 0.5f)
m2.makeCompressed();
172 Index j0 = internal::random<Index>(0, outer - 2);
173 Index j1 = internal::random<Index>(0, outer - 2);
174 Index n0 = internal::random<Index>(1, outer - (
std::max)(j0, j1));
175 if (SparseMatrixType::IsRowMajor)
179 if (SparseMatrixType::IsRowMajor)
181 refMat2.middleRows(j0, n0) + refMat2.middleRows(j1, n0));
184 refMat2.block(0, j0,
rows, n0) + refMat2.block(0, j1,
rows, n0));
188 VERIFY(
m2.innerVectors(j0, n0).nonZeros() ==
m2.transpose().innerVectors(j0, n0).nonZeros());
190 m2.innerVectors(j0, n0) =
m2.innerVectors(j0, n0) +
m2.innerVectors(j1, n0);
191 if (SparseMatrixType::IsRowMajor)
192 refMat2.middleRows(j0, n0) = (refMat2.middleRows(j0, n0) + refMat2.middleRows(j1, n0)).
eval();
194 refMat2.middleCols(j0, n0) = (refMat2.middleCols(j0, n0) + refMat2.middleCols(j1, n0)).
eval();
203 initSparse<Scalar>(
density, refMat2,
m2);
204 Index j0 = internal::random<Index>(0, outer - 2);
205 Index j1 = internal::random<Index>(0, outer - 2);
206 Index n0 = internal::random<Index>(1, outer - (
std::max)(j0, j1));
207 if (SparseMatrixType::IsRowMajor)
212 if (SparseMatrixType::IsRowMajor)
214 refMat2.block(j0, 0, n0,
cols) + refMat2.block(j1, 0, n0,
cols));
217 refMat2.block(0, j0,
rows, n0) + refMat2.block(0, j1,
rows, n0));
219 Index i = internal::random<Index>(0,
m2.outerSize() - 1);
220 if (SparseMatrixType::IsRowMajor) {
221 m2.innerVector(
i) =
m2.innerVector(
i) * s1;
222 refMat2.row(
i) = refMat2.row(
i) * s1;
225 m2.innerVector(
i) =
m2.innerVector(
i) * s1;
226 refMat2.col(
i) = refMat2.col(
i) * s1;
230 Index r0 = internal::random<Index>(0,
rows - 2);
231 Index c0 = internal::random<Index>(0,
cols - 2);
232 Index r1 = internal::random<Index>(1,
rows - r0);
233 Index c1 = internal::random<Index>(1,
cols - c0);
244 if (
m2.nonZeros() > 0) {
249 Index n = internal::random<Index>(1, 10);
251 Index o1 = internal::random<Index>(0, outer - 1);
252 Index o2 = internal::random<Index>(0, outer - 1);
253 if (SparseMatrixType::IsRowMajor) {
254 m3.innerVector(o1) =
m2.row(o2);
255 refMat3.row(o1) = refMat2.row(o2);
257 m3.innerVector(o1) =
m2.col(o2);
258 refMat3.col(o1) = refMat2.col(o2);
260 if (internal::random<bool>()) m3.makeCompressed();
270 initSparse<Scalar>(
density, refMat2,
m2);
272 Index j0 = internal::random<Index>(0, outer - 1);
276 typename SparseMatrixType::InnerIterator matrix_iterator(
m2, j0);
277 while (block_iterator) {
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
Definition: BenchSparseUtil.h:23
Matrix< Scalar, Dynamic, 1 > DenseVector
Definition: BenchSparseUtil.h:24
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
RowVector3d w
Definition: Matrix_resize_int.cpp:3
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
m m block(1, 0, 2, 2)<< 4
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
An InnerIterator allows to loop over the element of any matrix expression.
Definition: CoreIterators.h:37
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:198
a sparse vector class
Definition: SparseVector.h:62
float real
Definition: datatypes.h:10
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
#define VERIFY(a)
Definition: main.h:362
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X &x)
Definition: Meta.h:592
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
double Zero
Definition: pseudosolid_node_update_elements.cc:35
t
Definition: plotPSD.py:36
std::enable_if_t<(T::Flags &RowMajorBit)==RowMajorBit, typename T::RowXpr > innervec(T &A, Index i)
Definition: sparse_block.cpp:14
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition: sparse_permutations.cpp:47
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2