10 #ifndef EIGEN_TESTSPARSE_H 11 #define EIGEN_TESTSPARSE_H 13 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 27 #include <unordered_map> 28 #define EIGEN_UNORDERED_MAP_SUPPORT 32 #include <Eigen/Cholesky> 34 #include <Eigen/Sparse> 50 template<
typename Scalar,
int Opt1,
int Opt2,
typename StorageIndex>
void 61 sparseMat.
reserve(VectorXi::Constant(IsRowMajor ? refMat.
rows() : refMat.
cols(),
int((1.5*density)*(IsRowMajor?refMat.
cols():refMat.
rows()))));
71 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
75 v = internal::random<Scalar>()*
Scalar(3.);
105 template<
typename Scalar,
int Opt1,
int Opt2,
typename Index>
void 124 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
127 v = internal::random<Scalar>()*
Scalar(3.);
154 template<
typename Scalar,
int Options,
typename Index>
void 158 std::vector<int>* zeroCoords = 0,
159 std::vector<int>* nonzeroCoords = 0)
161 sparseVec.
reserve(
int(refVec.size()*density));
163 for(
int i=0;
i<refVec.size();
i++)
165 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
170 nonzeroCoords->push_back(
i);
173 zeroCoords->push_back(
i);
178 template<
typename Scalar,
int Options,
typename Index>
void 182 std::vector<int>* zeroCoords = 0,
183 std::vector<int>* nonzeroCoords = 0)
185 sparseVec.
reserve(
int(refVec.size()*density));
187 for(
int i=0;
i<refVec.size();
i++)
189 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
194 nonzeroCoords->push_back(
i);
197 zeroCoords->push_back(
i);
203 #include <unsupported/Eigen/SparseExtra> 204 #endif // EIGEN_TESTSPARSE_H
Scalar & insertBackByOuterInner(Index outer, Index inner)
Scalar & insertBack(Index i)
A versatible sparse matrix representation.
Scalar & insertByOuterInner(Index j, Index i)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
void reserve(Index reserveSize)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< int, Dynamic, 1 > v
A sparse matrix class designed for matrix assembly purpose.
void initSparse(double density, Matrix< Scalar, Dynamic, Dynamic, Opt1 > &refMat, SparseMatrix< Scalar, Opt2, StorageIndex > &sparseMat, int flags=0, std::vector< Matrix< StorageIndex, 2, 1 > > *zeroCoords=0, std::vector< Matrix< StorageIndex, 2, 1 > > *nonzeroCoords=0)
void reserve(Index reserveSize=1000)
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
void reserve(Index reserveSize)
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT