From 5960befc206ac7405841a9da2436f377e4df694f Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 19 Feb 2014 21:42:29 +0100 Subject: [PATCH 1/5] More int versus Index fixes --- Eigen/src/SparseCore/SparseMatrix.h | 9 +++++---- Eigen/src/SparseCore/SparsePermutation.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h index 0e7e760fb..9ac18bcf6 100644 --- a/Eigen/src/SparseCore/SparseMatrix.h +++ b/Eigen/src/SparseCore/SparseMatrix.h @@ -223,7 +223,7 @@ class SparseMatrix if(isCompressed()) { - reserve(VectorXi::Constant(outerSize(), 2)); + reserve(Matrix::Constant(outerSize(), 2)); } return insertUncompressed(row,col); } @@ -939,12 +939,13 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa EIGEN_UNUSED_VARIABLE(Options); enum { IsRowMajor = SparseMatrixType::IsRowMajor }; typedef typename SparseMatrixType::Scalar Scalar; + typedef typename SparseMatrixType::Index Index; SparseMatrix trMat(mat.rows(),mat.cols()); if(begin!=end) { // pass 1: count the nnz per inner-vector - VectorXi wi(trMat.outerSize()); + Matrix wi(trMat.outerSize()); wi.setZero(); for(InputIterator it(begin); it!=end; ++it) { @@ -1018,7 +1019,7 @@ void SparseMatrix::sumupDuplicates() { eigen_assert(!isCompressed()); // TODO, in practice we should be able to use m_innerNonZeros for that task - VectorXi wi(innerSize()); + Matrix wi(innerSize()); wi.fill(-1); Index count = 0; // for each inner-vector, wi[inner_index] will hold the position of first element into the index/value buffers @@ -1081,7 +1082,7 @@ EIGEN_DONT_INLINE SparseMatrix& SparseMatrix positions(dest.outerSize()); for (Index j=0; j tmp(m_matrix.rows(), m_matrix.cols()); - VectorXi sizes(m_matrix.outerSize()); + Matrix sizes(m_matrix.outerSize()); for(Index j=0; j tmp(m_matrix.rows(), m_matrix.cols()); - VectorXi sizes(tmp.outerSize()); + Matrix sizes(tmp.outerSize()); sizes.setZero(); PermutationMatrix perm; if((Side==OnTheLeft) ^ Transposed) From 3e439889e0dd10f67d328f3c688178d1e6c091d8 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Mon, 24 Feb 2014 13:12:10 +0100 Subject: [PATCH 2/5] Specify what non-resizeable objects are in transposeInPlace and adjointInPlace (cf bug #749) --- Eigen/src/Core/Transpose.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 976708a0f..aba3f6670 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -293,7 +293,8 @@ struct inplace_transpose_selector { // non square matrix * Notice however that this method is only useful if you want to replace a matrix by its own transpose. * If you just need the transpose of a matrix, use transpose(). * - * \note if the matrix is not square, then \c *this must be a resizable matrix. + * \note if the matrix is not square, then \c *this must be a resizable matrix. + * This excludes (non-square) fixed-size matrices, block-expressions and maps. * * \sa transpose(), adjoint(), adjointInPlace() */ template @@ -324,6 +325,7 @@ inline void DenseBase::transposeInPlace() * If you just need the adjoint of a matrix, use adjoint(). * * \note if the matrix is not square, then \c *this must be a resizable matrix. + * This excludes (non-square) fixed-size matrices, block-expressions and maps. * * \sa transpose(), adjoint(), transposeInPlace() */ template From 6fecb6f1b6d17883525f3f34dd5c1860faeecbd8 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Mon, 24 Feb 2014 14:10:17 +0000 Subject: [PATCH 3/5] Fix bug #748 - array_5 test fails for seed 1392781168. --- test/array.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/test/array.cpp b/test/array.cpp index f1deda7e3..5f49fc1ea 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -173,21 +173,14 @@ template void array_real(const ArrayType& m) Scalar s1 = internal::random(); // these tests are mostly to check possible compilation issues. -// VERIFY_IS_APPROX(m1.sin(), std::sin(m1)); VERIFY_IS_APPROX(m1.sin(), sin(m1)); -// VERIFY_IS_APPROX(m1.cos(), std::cos(m1)); VERIFY_IS_APPROX(m1.cos(), cos(m1)); -// VERIFY_IS_APPROX(m1.asin(), std::asin(m1)); VERIFY_IS_APPROX(m1.asin(), asin(m1)); -// VERIFY_IS_APPROX(m1.acos(), std::acos(m1)); VERIFY_IS_APPROX(m1.acos(), acos(m1)); -// VERIFY_IS_APPROX(m1.tan(), std::tan(m1)); VERIFY_IS_APPROX(m1.tan(), tan(m1)); VERIFY_IS_APPROX(cos(m1+RealScalar(3)*m2), cos((m1+RealScalar(3)*m2).eval())); -// VERIFY_IS_APPROX(std::cos(m1+RealScalar(3)*m2), std::cos((m1+RealScalar(3)*m2).eval())); -// VERIFY_IS_APPROX(m1.abs().sqrt(), std::sqrt(std::abs(m1))); VERIFY_IS_APPROX(m1.abs().sqrt(), sqrt(abs(m1))); VERIFY_IS_APPROX(m1.abs(), sqrt(numext::abs2(m1))); @@ -196,9 +189,10 @@ template void array_real(const ArrayType& m) if(!NumTraits::IsComplex) VERIFY_IS_APPROX(numext::real(m1), m1); - VERIFY_IS_APPROX(m1.abs().log() , log(abs(m1))); + // shift argument of logarithm so that it is not zero + Scalar smallNumber = NumTraits::dummy_precision(); + VERIFY_IS_APPROX((m1.abs() + smallNumber).log() , log(abs(m1) + smallNumber)); -// VERIFY_IS_APPROX(m1.exp(), std::exp(m1)); VERIFY_IS_APPROX(m1.exp() * m2.exp(), exp(m1+m2)); VERIFY_IS_APPROX(m1.exp(), exp(m1)); VERIFY_IS_APPROX(m1.exp() / m2.exp(),(m1-m2).exp()); @@ -242,7 +236,6 @@ template void array_complex(const ArrayType& m) m2(i,j) = sqrt(m1(i,j)); VERIFY_IS_APPROX(m1.sqrt(), m2); -// VERIFY_IS_APPROX(m1.sqrt(), std::sqrt(m1)); VERIFY_IS_APPROX(m1.sqrt(), Eigen::sqrt(m1)); } From 21fecd5252061c05cfb9f91e4e9becf25089949d Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 24 Feb 2014 17:12:17 +0100 Subject: [PATCH 4/5] Workaround clang ABI change with unsed arguments (ugly fix) --- .../Core/products/GeneralBlockPanelKernel.h | 12 +++++++ Eigen/src/Core/products/GeneralMatrixVector.h | 31 ++++++++++++------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 780fa74d3..10cd34e9e 100644 --- a/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -1130,6 +1130,10 @@ EIGEN_DONT_INLINE void gemm_pack_lhs=depth && offset<=stride)); eigen_assert( (StorageOrder==RowMajor) || ((Pack1%PacketSize)==0 && Pack1<=4*PacketSize) ); +#ifdef __clang__ + // Workaround clang ABI change with unsed arguments + if(!PanelMode) depth += stride + offset; +#endif conj_if::IsComplex && Conjugate> cj; const_blas_data_mapper lhs(_lhs,lhsStride); Index count = 0; @@ -1216,6 +1220,10 @@ EIGEN_DONT_INLINE void gemm_pack_rhs=depth && offset<=stride)); +#ifdef __clang__ + // Workaround clang ABI change with unsed arguments + if(!PanelMode) depth += stride + offset; +#endif conj_if::IsComplex && Conjugate> cj; Index packet_cols = (cols/nr) * nr; Index count = 0; @@ -1267,6 +1275,10 @@ EIGEN_DONT_INLINE void gemm_pack_rhs=depth && offset<=stride)); +#ifdef __clang__ + // Workaround clang ABI change with unsed arguments + if(!PanelMode) depth += stride + offset; +#endif conj_if::IsComplex && Conjugate> cj; Index packet_cols = (cols/nr) * nr; Index count = 0; diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index c8697c913..c3e1e7142 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -80,11 +80,8 @@ EIGEN_DONT_INLINE static void run( Index rows, Index cols, const LhsScalar* lhs, Index lhsStride, const RhsScalar* rhs, Index rhsIncr, - ResScalar* res, Index - #ifdef EIGEN_INTERNAL_DEBUGGING - resIncr - #endif - , RhsScalar alpha); + ResScalar* res, Index resIncr, + RhsScalar alpha); }; template @@ -92,13 +89,17 @@ EIGEN_DONT_INLINE void general_matrix_vector_product Date: Mon, 24 Feb 2014 18:13:49 +0100 Subject: [PATCH 5/5] Implement bug #317: use a template function call to suppress unused variable warnings. This also fix the issue of the previous changeset in a much nicer way. --- .../Core/products/GeneralBlockPanelKernel.h | 18 ++++++------------ Eigen/src/Core/products/GeneralMatrixVector.h | 15 ++------------- Eigen/src/Core/util/Macros.h | 7 ++++++- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 10cd34e9e..08cc14bd7 100644 --- a/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -1128,12 +1128,10 @@ EIGEN_DONT_INLINE void gemm_pack_lhs::size }; EIGEN_ASM_COMMENT("EIGEN PRODUCT PACK LHS"); + EIGEN_UNUSED_VARIABLE(stride); + EIGEN_UNUSED_VARIABLE(offset); eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride)); eigen_assert( (StorageOrder==RowMajor) || ((Pack1%PacketSize)==0 && Pack1<=4*PacketSize) ); -#ifdef __clang__ - // Workaround clang ABI change with unsed arguments - if(!PanelMode) depth += stride + offset; -#endif conj_if::IsComplex && Conjugate> cj; const_blas_data_mapper lhs(_lhs,lhsStride); Index count = 0; @@ -1219,11 +1217,9 @@ EIGEN_DONT_INLINE void gemm_pack_rhs=depth && offset<=stride)); -#ifdef __clang__ - // Workaround clang ABI change with unsed arguments - if(!PanelMode) depth += stride + offset; -#endif conj_if::IsComplex && Conjugate> cj; Index packet_cols = (cols/nr) * nr; Index count = 0; @@ -1274,11 +1270,9 @@ EIGEN_DONT_INLINE void gemm_pack_rhs=depth && offset<=stride)); -#ifdef __clang__ - // Workaround clang ABI change with unsed arguments - if(!PanelMode) depth += stride + offset; -#endif conj_if::IsComplex && Conjugate> cj; Index packet_cols = (cols/nr) * nr; Index count = 0; diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index c3e1e7142..a73ce5ff0 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -92,14 +92,8 @@ EIGEN_DONT_INLINE void general_matrix_vector_product void ignore_unused_variable(const T&) {} + } +} +#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var); #if !defined(EIGEN_ASM_COMMENT) #if (defined __GNUC__) && ( defined(__i386__) || defined(__x86_64__) )