12 #define EIGEN_NO_DEPRECATED_WARNING 13 #include "sparse_product.cpp" 15 #include <Eigen/SparseExtra> 17 template<
typename SetterType,
typename DenseType,
typename Scalar,
int Options>
23 std::vector<Vector2i> remaining = nonzeroCoords;
24 while(!remaining.empty())
26 int i = internal::random<int>(0,
static_cast<int>(remaining.size())-1);
27 w(remaining[i].
x(),remaining[i].
y()) = ref.coeff(remaining[i].
x(),remaining[i].
y());
28 remaining[
i] = remaining.back();
35 template<
typename SetterType,
typename DenseType,
typename T>
39 std::vector<Vector2i> remaining = nonzeroCoords;
40 while(!remaining.empty())
42 int i = internal::random<int>(0,
static_cast<int>(remaining.size())-1);
43 sm.
coeffRef(remaining[i].
x(),remaining[i].
y()) = ref.coeff(remaining[i].
x(),remaining[i].
y());
44 remaining[
i] = remaining.back();
50 template<
typename SparseMatrixType>
void sparse_extra(
const SparseMatrixType&
ref)
55 enum { Flags = SparseMatrixType::Flags };
57 double density = (
std::max)(8./(rows*cols), 0.01);
62 SparseMatrixType
m(rows, cols);
63 DenseMatrix refMat = DenseMatrix::Zero(rows, cols);
64 DenseVector
vec1 = DenseVector::Random(rows);
66 std::vector<Vector2i> zeroCoords;
67 std::vector<Vector2i> nonzeroCoords;
68 initSparse<Scalar>(density, refMat,
m, 0, &zeroCoords, &nonzeroCoords);
70 if (zeroCoords.size()==0 || nonzeroCoords.size()==0)
74 for (
int i=0;
i<(
int)zeroCoords.size(); ++
i)
82 m.coeffRef(nonzeroCoords[0].
x(), nonzeroCoords[0].
y()) =
Scalar(5);
83 refMat.coeffRef(nonzeroCoords[0].
x(), nonzeroCoords[0].
y()) =
Scalar(5);
104 #ifdef EIGEN_UNORDERED_MAP_SUPPORT 107 #ifdef _DENSE_HASH_MAP_H_ 110 #ifdef _SPARSE_HASH_MAP_H_ 135 int s = Eigen::internal::random<int>(1,50);
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
#define VERIFY_RAISES_ASSERT(a)
A versatible sparse matrix representation.
Matrix< Scalar, Dynamic, 1 > DenseVector
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
A sparse matrix class designed for matrix assembly purpose.
bool isApprox(const SparseMatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
The RandomSetter is a wrapper object allowing to set/update a sparse matrix with random access...
Scalar & coeffRef(Index row, Index col)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x