10 #ifndef EIGEN_TESTSPARSE_H 11 #define EIGEN_TESTSPARSE_H 13 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 17 #if EIGEN_GNUC_AT_LEAST(4,0) && !defined __ICC && !defined(__clang__) 27 #include <tr1/unordered_map> 28 #define EIGEN_UNORDERED_MAP_SUPPORT 30 using std::tr1::unordered_map;
34 #ifdef EIGEN_GOOGLEHASH_SUPPORT 35 #include <google/sparse_hash_map> 38 #include <Eigen/Cholesky> 40 #include <Eigen/Sparse> 56 template<
typename Scalar,
int Opt1,
int Opt2,
typename StorageIndex>
void 67 sparseMat.
reserve(VectorXi::Constant(IsRowMajor ? refMat.
rows() : refMat.
cols(),
int((1.5*density)*(IsRowMajor?refMat.
cols():refMat.
rows()))));
77 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
81 v = internal::random<Scalar>()*
Scalar(3.);
111 template<
typename Scalar,
int Opt1,
int Opt2,
typename Index>
void 130 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
133 v = internal::random<Scalar>()*
Scalar(3.);
160 template<
typename Scalar,
int Options,
typename Index>
void 164 std::vector<int>* zeroCoords = 0,
165 std::vector<int>* nonzeroCoords = 0)
167 sparseVec.
reserve(
int(refVec.size()*density));
169 for(
int i=0;
i<refVec.size();
i++)
171 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
176 nonzeroCoords->push_back(
i);
179 zeroCoords->push_back(
i);
184 template<
typename Scalar,
int Options,
typename Index>
void 188 std::vector<int>* zeroCoords = 0,
189 std::vector<int>* nonzeroCoords = 0)
191 sparseVec.
reserve(
int(refVec.size()*density));
193 for(
int i=0;
i<refVec.size();
i++)
195 Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() :
Scalar(0);
200 nonzeroCoords->push_back(
i);
203 zeroCoords->push_back(
i);
209 #include <unsupported/Eigen/SparseExtra> 210 #endif // EIGEN_TESTSPARSE_H EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const
Scalar & insertBackByOuterInner(Index outer, Index inner)
const mpreal ai(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Scalar & insertBack(Index i)
A versatible sparse matrix representation.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const
Scalar & insertByOuterInner(Index j, Index i)
void reserve(Index reserveSize)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
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 reserve(Index reserveSize)
The matrix class, also used for vectors and row-vectors.
void swap(mpfr::mpreal &x, mpfr::mpreal &y)