diff --git a/Eigen/src/Sparse/RandomSetter.h b/Eigen/src/Sparse/RandomSetter.h index 88e2fe632..d908e315f 100644 --- a/Eigen/src/Sparse/RandomSetter.h +++ b/Eigen/src/Sparse/RandomSetter.h @@ -40,22 +40,34 @@ template struct StdMapTraits static void setInvalidKey(Type&, const KeyType&) {} }; -#ifdef _HASH_MAP -/** Represents a __gnu_cxx::hash_map +#ifdef EIGEN_UNORDERED_MAP_SUPPORT +/** 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 + * #define EIGEN_UNORDERED_MAP_SUPPORT + * namespace std { + * using std::tr1::unordered_map; + * } + * \endcode * * \see RandomSetter */ -template struct GnuHashMapTraits +template struct StdUnorderedMapTraits { typedef int KeyType; - typedef __gnu_cxx::hash_map Type; + typedef std::unordered_map Type; enum { IsSorted = 0 }; static void setInvalidKey(Type&, const KeyType&) {} }; -#endif +#endif // EIGEN_UNORDERED_MAP_SUPPORT #ifdef _DENSE_HASH_MAP_H_ /** Represents a google::dense_hash_map diff --git a/test/commainitializer.cpp b/test/commainitializer.cpp index a93a57d8f..503dd9be4 100644 --- a/test/commainitializer.cpp +++ b/test/commainitializer.cpp @@ -30,7 +30,10 @@ void test_commainitializer() Matrix4d m4; VERIFY_RAISES_ASSERT( (m3 << 1, 2, 3, 4, 5, 6, 7, 8) ); + + #ifndef _MSC_VER VERIFY_RAISES_ASSERT( (m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) ); + #endif double data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Matrix3d ref = Map >(data); diff --git a/test/sparse.h b/test/sparse.h index d18217e0a..128b129e8 100644 --- a/test/sparse.h +++ b/test/sparse.h @@ -24,15 +24,20 @@ #ifndef EIGEN_TESTSPARSE_H -#ifdef __GNUC__ -#include +#include "main.h" + +#if EIGEN_GNUC_AT_LEAST(4,0) +#include +#define EIGEN_UNORDERED_MAP_SUPPORT +namespace std { + using std::tr1::unordered_map; +} #endif #ifdef EIGEN_GOOGLEHASH_SUPPORT #include #endif -#include "main.h" #include #include #include diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp index 68e35736c..93065bbde 100644 --- a/test/sparse_basic.cpp +++ b/test/sparse_basic.cpp @@ -167,8 +167,8 @@ template void sparse_basic(const SparseMatrixType& re // VERIFY_IS_APPROX(m, refMat); VERIFY(( test_random_setter >(m,refMat,nonzeroCoords) )); - #ifdef _HASH_MAP - VERIFY(( test_random_setter >(m,refMat,nonzeroCoords) )); + #ifdef EIGEN_UNORDERED_MAP_SUPPORT + VERIFY(( test_random_setter >(m,refMat,nonzeroCoords) )); #endif #ifdef _DENSE_HASH_MAP_H_ VERIFY(( test_random_setter >(m,refMat,nonzeroCoords) )); diff --git a/test/submatrices.cpp b/test/submatrices.cpp index c9552ace2..63c61baca 100644 --- a/test/submatrices.cpp +++ b/test/submatrices.cpp @@ -57,6 +57,7 @@ template void submatrices(const MatrixType& m) Row.h Column.h Block.h Minor.h DiagonalCoeffs.h */ typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; typedef Matrix VectorType; typedef Matrix RowVectorType; int rows = m.rows(); @@ -140,11 +141,11 @@ template void submatrices(const MatrixType& m) } // stress some basic stuffs with block matrices - VERIFY(ones.col(c1).sum() == Scalar(rows)); - VERIFY(ones.row(r1).sum() == Scalar(cols)); + VERIFY(ei_real(ones.col(c1).sum()) == RealScalar(rows)); + VERIFY(ei_real(ones.row(r1).sum()) == RealScalar(cols)); - VERIFY(ones.col(c1).dot(ones.col(c2)) == Scalar(rows)); - VERIFY(ones.row(r1).dot(ones.row(r2)) == Scalar(cols)); + VERIFY(ei_real(ones.col(c1).dot(ones.col(c2))) == RealScalar(rows)); + VERIFY(ei_real(ones.row(r1).dot(ones.row(r2))) == RealScalar(cols)); } void test_submatrices()