From dc6ad5e25b786ec6874158b33a77babf14d66941 Mon Sep 17 00:00:00 2001 From: Hauke Heibel Date: Mon, 21 Jun 2010 11:36:00 +0200 Subject: [PATCH] More Index related stuff. --- Eigen/src/Core/Map.h | 1 + Eigen/src/Core/Stride.h | 18 ++++++++++-------- test/basicstuff.cpp | 4 ++-- test/cwiseop.cpp | 4 ++-- test/determinant.cpp | 9 +++++---- test/diagonalmatrices.cpp | 4 ++-- test/geo_alignedbox.cpp | 4 ++-- test/geo_hyperplane.cpp | 4 ++-- test/geo_parametrizedline.cpp | 4 ++-- test/linearstructure.cpp | 4 ++-- test/map.cpp | 3 ++- test/mapstride.cpp | 7 ++++--- 12 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index cb65b8e00..91ab03c10 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -77,6 +77,7 @@ template struct ei_traits > : public ei_traits { + typedef typename PlainObjectType::Index Index; typedef typename PlainObjectType::Scalar Scalar; enum { InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0 diff --git a/Eigen/src/Core/Stride.h b/Eigen/src/Core/Stride.h index afae0345e..a965b5a55 100644 --- a/Eigen/src/Core/Stride.h +++ b/Eigen/src/Core/Stride.h @@ -55,7 +55,7 @@ template class Stride { public: - + typedef DenseIndex Index; enum { InnerStrideAtCompileTime = _InnerStrideAtCompileTime, OuterStrideAtCompileTime = _OuterStrideAtCompileTime @@ -69,7 +69,7 @@ class Stride } /** Constructor allowing to pass the strides at runtime */ - Stride(int outerStride, int innerStride) + Stride(Index outerStride, Index innerStride) : m_outer(outerStride), m_inner(innerStride) { ei_assert(innerStride>=0 && outerStride>=0); @@ -81,13 +81,13 @@ class Stride {} /** \returns the outer stride */ - inline int outer() const { return m_outer.value(); } + inline Index outer() const { return m_outer.value(); } /** \returns the inner stride */ - inline int inner() const { return m_inner.value(); } + inline Index inner() const { return m_inner.value(); } protected: - ei_variable_if_dynamic m_outer; - ei_variable_if_dynamic m_inner; + ei_variable_if_dynamic m_outer; + ei_variable_if_dynamic m_inner; }; /** \brief Convenience specialization of Stride to specify only an inner stride */ @@ -96,8 +96,9 @@ class InnerStride : public Stride<0, Value> { typedef Stride<0, Value> Base; public: + typedef DenseIndex Index; InnerStride() : Base() {} - InnerStride(int v) : Base(0, v) {} + InnerStride(Index v) : Base(0, v) {} }; /** \brief Convenience specialization of Stride to specify only an outer stride */ @@ -106,8 +107,9 @@ class OuterStride : public Stride { typedef Stride Base; public: + typedef DenseIndex Index; OuterStride() : Base() {} - OuterStride(int v) : Base(v,0) {} + OuterStride(Index v) : Base(v,0) {} }; #endif // EIGEN_STRIDE_H diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index e1afc0ecc..3e5626454 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -50,8 +50,8 @@ template void basicStuff(const MatrixType& m) Scalar x = ei_random(); - int r = ei_random(0, rows-1), - c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), + c = ei_random(0, cols-1); m1.coeffRef(r,c) = x; VERIFY_IS_APPROX(x, m1.coeff(r,c)); diff --git a/test/cwiseop.cpp b/test/cwiseop.cpp index ee7c8d2c4..dda05e621 100644 --- a/test/cwiseop.cpp +++ b/test/cwiseop.cpp @@ -60,8 +60,8 @@ template void cwiseops(const MatrixType& m) vones = VectorType::Ones(rows), v3(rows); - int r = ei_random(0, rows-1), - c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), + c = ei_random(0, cols-1); Scalar s1 = ei_random(); diff --git a/test/determinant.cpp b/test/determinant.cpp index 7aa9a870d..0e8f98988 100644 --- a/test/determinant.cpp +++ b/test/determinant.cpp @@ -31,7 +31,8 @@ template void determinant(const MatrixType& m) /* this test covers the following files: Determinant.h */ - int size = m.rows(); + typedef typename MatrixType::Index Index; + Index size = m.rows(); MatrixType m1(size, size), m2(size, size); m1.setRandom(); @@ -41,10 +42,10 @@ template void determinant(const MatrixType& m) VERIFY_IS_APPROX(MatrixType::Identity(size, size).determinant(), Scalar(1)); VERIFY_IS_APPROX((m1*m2).eval().determinant(), m1.determinant() * m2.determinant()); if(size==1) return; - int i = ei_random(0, size-1); - int j; + Index i = ei_random(0, size-1); + Index j; do { - j = ei_random(0, size-1); + j = ei_random(0, size-1); } while(j==i); m2 = m1; m2.row(i).swap(m2.row(j)); diff --git a/test/diagonalmatrices.cpp b/test/diagonalmatrices.cpp index 2bc75ba1c..8408dda44 100644 --- a/test/diagonalmatrices.cpp +++ b/test/diagonalmatrices.cpp @@ -66,8 +66,8 @@ template void diagonalmatrices(const MatrixType& m) sq_m1.transpose() = ldm1; VERIFY_IS_APPROX(sq_m1, ldm1.toDenseMatrix()); - int i = ei_random(0, rows-1); - int j = ei_random(0, cols-1); + Index i = ei_random(0, rows-1); + Index j = ei_random(0, cols-1); VERIFY_IS_APPROX( ((ldm1 * m1)(i,j)) , ldm1.diagonal()(i) * m1(i,j) ); VERIFY_IS_APPROX( ((ldm1 * (m1+m2))(i,j)) , ldm1.diagonal()(i) * (m1+m2)(i,j) ); diff --git a/test/geo_alignedbox.cpp b/test/geo_alignedbox.cpp index e38349b2a..9c347df00 100644 --- a/test/geo_alignedbox.cpp +++ b/test/geo_alignedbox.cpp @@ -35,8 +35,8 @@ template void alignedbox(const BoxType& _box) /* this test covers the following files: AlignedBox.h */ - - const int dim = _box.dim(); + typedef typename BoxType::Index Index; + const Index dim = _box.dim(); typedef typename BoxType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; diff --git a/test/geo_hyperplane.cpp b/test/geo_hyperplane.cpp index cd19698bc..d40d6719c 100644 --- a/test/geo_hyperplane.cpp +++ b/test/geo_hyperplane.cpp @@ -33,8 +33,8 @@ template void hyperplane(const HyperplaneType& _plane) /* this test covers the following files: Hyperplane.h */ - - const int dim = _plane.dim(); + typedef typename HyperplaneType::Index Index; + const Index dim = _plane.dim(); typedef typename HyperplaneType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; diff --git a/test/geo_parametrizedline.cpp b/test/geo_parametrizedline.cpp index 137324a98..43db48df1 100644 --- a/test/geo_parametrizedline.cpp +++ b/test/geo_parametrizedline.cpp @@ -33,8 +33,8 @@ template void parametrizedline(const LineType& _line) /* this test covers the following files: ParametrizedLine.h */ - - const int dim = _line.dim(); + typedef typename LineType::Index Index; + const Index dim = _line.dim(); typedef typename LineType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef Matrix VectorType; diff --git a/test/linearstructure.cpp b/test/linearstructure.cpp index 1d86af337..a0b8982dd 100644 --- a/test/linearstructure.cpp +++ b/test/linearstructure.cpp @@ -45,8 +45,8 @@ template void linearStructure(const MatrixType& m) Scalar s1 = ei_random(); while (ei_abs(s1)<1e-3) s1 = ei_random(); - int r = ei_random(0, rows-1), - c = ei_random(0, cols-1); + Index r = ei_random(0, rows-1), + c = ei_random(0, cols-1); VERIFY_IS_APPROX(-(-m1), m1); VERIFY_IS_APPROX(m1+m1, 2*m1); diff --git a/test/map.cpp b/test/map.cpp index 695d62982..98d513588 100644 --- a/test/map.cpp +++ b/test/map.cpp @@ -82,9 +82,10 @@ template void map_class_matrix(const MatrixType& m) template void map_static_methods(const VectorType& m) { + typedef typename VectorType::Index Index; typedef typename VectorType::Scalar Scalar; - int size = m.size(); + Index size = m.size(); // test Map.h Scalar* array1 = ei_aligned_new(size); diff --git a/test/mapstride.cpp b/test/mapstride.cpp index ff6e71a66..072b2134c 100644 --- a/test/mapstride.cpp +++ b/test/mapstride.cpp @@ -26,13 +26,14 @@ template void map_class_vector(const VectorType& m) { + typedef typename VectorType::Index Index; typedef typename VectorType::Scalar Scalar; - int size = m.size(); + Index size = m.size(); VectorType v = VectorType::Random(size); - int arraysize = 3*size; + Index arraysize = 3*size; Scalar* array = ei_aligned_new(arraysize); @@ -68,7 +69,7 @@ template void map_class_matrix(const MatrixType& _m) MatrixType m = MatrixType::Random(rows,cols); - int arraysize = 2*(rows+4)*(cols+4); + Index arraysize = 2*(rows+4)*(cols+4); Scalar* array = ei_aligned_new(arraysize);