mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 12:15:11 +08:00
made RandomSetter C++11 compatible
This commit is contained in:
parent
eeacbd26c8
commit
9abf4d0bec
@ -33,21 +33,8 @@ template<typename Scalar> struct StdMapTraits
|
|||||||
static void setInvalidKey(Type&, const KeyType&) {}
|
static void setInvalidKey(Type&, const KeyType&) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EIGEN_UNORDERED_MAP_SUPPORT
|
|
||||||
/** Represents a std::unordered_map
|
/** Represents a std::unordered_map
|
||||||
*
|
|
||||||
* To use it you need to both define EIGEN_UNORDERED_MAP_SUPPORT and include the unordered_map header file
|
|
||||||
* yourself making sure that unordered_map is defined in the std namespace.
|
|
||||||
*
|
|
||||||
* For instance, with current version of gcc you can either enable C++0x standard (-std=c++0x) or do:
|
|
||||||
* \code
|
|
||||||
* #include <tr1/unordered_map>
|
|
||||||
* #define EIGEN_UNORDERED_MAP_SUPPORT
|
|
||||||
* namespace std {
|
|
||||||
* using std::tr1::unordered_map;
|
|
||||||
* }
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* \see RandomSetter
|
* \see RandomSetter
|
||||||
*/
|
*/
|
||||||
template<typename Scalar> struct StdUnorderedMapTraits
|
template<typename Scalar> struct StdUnorderedMapTraits
|
||||||
@ -60,7 +47,6 @@ template<typename Scalar> struct StdUnorderedMapTraits
|
|||||||
|
|
||||||
static void setInvalidKey(Type&, const KeyType&) {}
|
static void setInvalidKey(Type&, const KeyType&) {}
|
||||||
};
|
};
|
||||||
#endif // EIGEN_UNORDERED_MAP_SUPPORT
|
|
||||||
|
|
||||||
#if defined(EIGEN_GOOGLEHASH_SUPPORT)
|
#if defined(EIGEN_GOOGLEHASH_SUPPORT)
|
||||||
|
|
||||||
@ -149,12 +135,12 @@ template<typename Scalar> struct GoogleSparseHashMapTraits
|
|||||||
*
|
*
|
||||||
* The possible values for the template parameter MapTraits are:
|
* The possible values for the template parameter MapTraits are:
|
||||||
* - \b StdMapTraits: corresponds to std::map. (does not perform very well)
|
* - \b StdMapTraits: corresponds to std::map. (does not perform very well)
|
||||||
* - \b GnuHashMapTraits: corresponds to __gnu_cxx::hash_map (available only with GCC)
|
* - \b StdUnorderedMapTraits: corresponds to std::unordered_map
|
||||||
* - \b GoogleDenseHashMapTraits: corresponds to google::dense_hash_map (best efficiency, reasonable memory consumption)
|
* - \b GoogleDenseHashMapTraits: corresponds to google::dense_hash_map (best efficiency, reasonable memory consumption)
|
||||||
* - \b GoogleSparseHashMapTraits: corresponds to google::sparse_hash_map (best memory consumption, relatively good performance)
|
* - \b GoogleSparseHashMapTraits: corresponds to google::sparse_hash_map (best memory consumption, relatively good performance)
|
||||||
*
|
*
|
||||||
* The default map implementation depends on the availability, and the preferred order is:
|
* The default map implementation depends on the availability, and the preferred order is:
|
||||||
* GoogleSparseHashMapTraits, GnuHashMapTraits, and finally StdMapTraits.
|
* GoogleSparseHashMapTraits, StdUnorderedMapTraits, and finally StdMapTraits.
|
||||||
*
|
*
|
||||||
* For performance and memory consumption reasons it is highly recommended to use one of
|
* For performance and memory consumption reasons it is highly recommended to use one of
|
||||||
* Google's hash_map implementations. To enable the support for them, you must define
|
* Google's hash_map implementations. To enable the support for them, you must define
|
||||||
@ -167,10 +153,8 @@ template<typename SparseMatrixType,
|
|||||||
template <typename T> class MapTraits =
|
template <typename T> class MapTraits =
|
||||||
#if defined(EIGEN_GOOGLEHASH_SUPPORT)
|
#if defined(EIGEN_GOOGLEHASH_SUPPORT)
|
||||||
GoogleDenseHashMapTraits
|
GoogleDenseHashMapTraits
|
||||||
#elif defined(_HASH_MAP)
|
|
||||||
GnuHashMapTraits
|
|
||||||
#else
|
#else
|
||||||
StdMapTraits
|
StdUnorderedMapTraits
|
||||||
#endif
|
#endif
|
||||||
,int OuterPacketBits = 6>
|
,int OuterPacketBits = 6>
|
||||||
class RandomSetter
|
class RandomSetter
|
||||||
|
@ -28,7 +28,6 @@ static long g_dense_op_sparse_count = 0;
|
|||||||
#include "sparse_product.cpp"
|
#include "sparse_product.cpp"
|
||||||
|
|
||||||
|
|
||||||
#if EIGEN_HAS_CXX11
|
|
||||||
|
|
||||||
#ifdef min
|
#ifdef min
|
||||||
#undef min
|
#undef min
|
||||||
@ -39,9 +38,6 @@ static long g_dense_op_sparse_count = 0;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#define EIGEN_UNORDERED_MAP_SUPPORT
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include <Eigen/SparseExtra>
|
#include <Eigen/SparseExtra>
|
||||||
@ -133,9 +129,7 @@ template<typename SparseMatrixType> void sparse_extra(const SparseMatrixType& re
|
|||||||
// VERIFY_IS_APPROX(m, refMat);
|
// VERIFY_IS_APPROX(m, refMat);
|
||||||
|
|
||||||
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, StdMapTraits> >(m,refMat,nonzeroCoords) ));
|
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, StdMapTraits> >(m,refMat,nonzeroCoords) ));
|
||||||
#ifdef EIGEN_UNORDERED_MAP_SUPPORT
|
|
||||||
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, StdUnorderedMapTraits> >(m,refMat,nonzeroCoords) ));
|
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, StdUnorderedMapTraits> >(m,refMat,nonzeroCoords) ));
|
||||||
#endif
|
|
||||||
#ifdef EIGEN_GOOGLEHASH_SUPPORT
|
#ifdef EIGEN_GOOGLEHASH_SUPPORT
|
||||||
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, GoogleDenseHashMapTraits> >(m,refMat,nonzeroCoords) ));
|
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, GoogleDenseHashMapTraits> >(m,refMat,nonzeroCoords) ));
|
||||||
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, GoogleSparseHashMapTraits> >(m,refMat,nonzeroCoords) ));
|
VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, GoogleSparseHashMapTraits> >(m,refMat,nonzeroCoords) ));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user