From 8603d80029581272a04f78959cb1636395fa47bc Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Thu, 9 Aug 2018 11:09:10 -0700 Subject: [PATCH 1/4] Cast diagonalSize() to Scalar before multiplication. Without this, automatic differentiation in Ceres breaks because Scalar is a custom type that does not support multiplication by Index. --- Eigen/src/LU/FullPivLU.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index 50d1bb41b..8541dfa02 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -53,7 +53,7 @@ template struct traits > * Output: \verbinclude class_FullPivLU.out * * This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism. - * + * * \sa MatrixBase::fullPivLu(), MatrixBase::determinant(), MatrixBase::inverse() */ template class FullPivLU @@ -320,7 +320,7 @@ template class FullPivLU return m_usePrescribedThreshold ? m_prescribedThreshold // this formula comes from experimenting (see "LU precision tuning" thread on the list) // and turns out to be identical to Higham's formula used already in LDLt. - : NumTraits::epsilon() * m_lu.diagonalSize(); + : NumTraits::epsilon() * Scalar(m_lu.diagonalSize()); } /** \returns the rank of the matrix of which *this is the LU decomposition. From bfc5091dd56a18e3f6ed1dd30509f45d0fba0828 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Thu, 9 Aug 2018 14:46:17 -0700 Subject: [PATCH 2/4] Cast to diagonalSize to RealScalar instead Scalar. --- Eigen/src/LU/FullPivLU.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index 8541dfa02..344ec8926 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -320,7 +320,7 @@ template class FullPivLU return m_usePrescribedThreshold ? m_prescribedThreshold // this formula comes from experimenting (see "LU precision tuning" thread on the list) // and turns out to be identical to Higham's formula used already in LDLt. - : NumTraits::epsilon() * Scalar(m_lu.diagonalSize()); + : NumTraits::epsilon() * RealScalar(m_lu.diagonalSize()); } /** \returns the rank of the matrix of which *this is the LU decomposition. From 4be42862241d4f976d8ed92a2cc0ad5b06520ef9 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Fri, 10 Aug 2018 11:32:58 -0700 Subject: [PATCH 3/4] Made the code compile with gcc 5.4. --- .../Eigen/CXX11/src/Tensor/TensorBlock.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h index 45ddfdb39..cbf91013b 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h @@ -60,7 +60,7 @@ struct cond { * - kSkewedInnerDims: 100 blocks of size 100x1 (or 1x100 depending on a column * or row major layout) */ -enum class TensorBlockShapeType { +enum TensorBlockShapeType { kUniformAllDims, kSkewedInnerDims, }; @@ -152,11 +152,11 @@ struct TensorBlockCopyOp { const Scalar* src_base = &src_data[src_index]; Scalar* dst_base = &dst_data[dst_index]; - using Src = const Eigen::Array; - using Dst = Eigen::Array; + typedef const Eigen::Array Src; + typedef Eigen::Array Dst; - using SrcMap = Eigen::Map>; - using DstMap = Eigen::Map>; + typedef Eigen::Map> SrcMap; + typedef Eigen::Map> DstMap; const SrcMap src(src_base, num_coeff_to_copy, InnerStride<>(src_stride)); DstMap dst(dst_base, num_coeff_to_copy, InnerStride<>(dst_stride)); @@ -401,13 +401,13 @@ struct TensorBlockCwiseBinaryOp { const StorageIndex left_stride, const LeftScalar* left_data, const StorageIndex right_index, const StorageIndex right_stride, const RightScalar* right_data) { - using Lhs = const Eigen::Array; - using Rhs = const Eigen::Array; - using Out = Eigen::Array; + typedef const Eigen::Array Lhs; + typedef const Eigen::Array Rhs; + typedef Eigen::Array Out; - using LhsMap = Eigen::Map>; - using RhsMap = Eigen::Map>; - using OutMap = Eigen::Map>; + typedef Eigen::Map> LhsMap; + typedef Eigen::Map> RhsMap; + typedef Eigen::Map> OutMap; const LeftScalar* lhs_base = &left_data[left_index]; const RightScalar* rhs_base = &right_data[right_index]; From c8ea39867573b36c72c5342393f4e3ee22ab6406 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Fri, 10 Aug 2018 13:02:41 -0700 Subject: [PATCH 4/4] Avoided language features that are only available in cxx11 mode. --- .../Eigen/CXX11/src/Tensor/TensorExecutor.h | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h index 17008917a..3f3b5685d 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h @@ -36,7 +36,7 @@ template class TensorExecutor { public: - using StorageIndex = typename Expression::Index; + typedef typename Expression::Index StorageIndex; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(const Expression& expr, @@ -60,7 +60,7 @@ template class TensorExecutor { public: - using StorageIndex = typename Expression::Index; + typedef typename Expression::Index StorageIndex; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(const Expression& expr, @@ -102,21 +102,19 @@ template class TensorExecutor { public: - using Scalar = typename traits::Scalar; - using ScalarNoConst = typename remove_const::type; + typedef typename traits::Scalar Scalar; + typedef typename remove_const::type ScalarNoConst; - using Evaluator = TensorEvaluator; - using StorageIndex = typename traits::Index; + typedef TensorEvaluator Evaluator; + typedef typename traits::Index StorageIndex; static const int NumDims = traits::NumDimensions; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(const Expression& expr, const DefaultDevice& device = DefaultDevice()) { - using TensorBlock = - TensorBlock; - using TensorBlockMapper = TensorBlockMapper; + typedef TensorBlock TensorBlock; + typedef TensorBlockMapper TensorBlockMapper; Evaluator evaluator(expr, device); Index total_size = array_prod(evaluator.dimensions()); @@ -221,7 +219,7 @@ struct EvalRange { template class TensorExecutor { public: - using StorageIndex = typename Expression::Index; + typedef typename Expression::Index StorageIndex; static EIGEN_STRONG_INLINE void run(const Expression& expr, const ThreadPoolDevice& device) { @@ -249,20 +247,18 @@ class TensorExecutor { template class TensorExecutor { public: - using Scalar = typename traits::Scalar; - using ScalarNoConst = typename remove_const::type; + typedef typename traits::Scalar Scalar; + typedef typename remove_const::type ScalarNoConst; - using Evaluator = TensorEvaluator; - using StorageIndex = typename traits::Index; + typedef TensorEvaluator Evaluator; + typedef typename traits::Index StorageIndex; static const int NumDims = traits::NumDimensions; static EIGEN_STRONG_INLINE void run(const Expression& expr, const ThreadPoolDevice& device) { - using TensorBlock = - TensorBlock; - using TensorBlockMapper = - TensorBlockMapper; + typedef TensorBlock TensorBlock; + typedef TensorBlockMapper TensorBlockMapper; Evaluator evaluator(expr, device); StorageIndex total_size = array_prod(evaluator.dimensions());