Update Eigen to commit:ae3aba99db4c829b4cc4d9fdd54321dedd814dc4 CHANGELOG ========= ae3aba99d - Fix typo in CoreEvaluators.h ee4f86f90 - Fix MSAN in vectorized casting evaluator 6dbbf0a84 - CMake: only create uninstall target when eigen is top level fb2fca90b - Avoid unnecessary matrix copy in BDCSVD and JacobiSVD d6b23a225 - Fix unused local typedef warning in matrix exponential PiperOrigin-RevId: 756397904 Change-Id: Ic6f355c0f282a639defe5f55dbbbc8ae01cd956f
diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index e3af2d2..63f1895 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h
@@ -726,6 +726,7 @@ Index count) const { constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode); PacketBlock<PacketType, NumPackets> packets; + for (Index i = 0; i < NumPackets; i++) packets.packet[i] = pzero(PacketType()); Index offset = begin / SrcPacketSize; Index actualBegin = begin % SrcPacketSize; for (; offset < NumPackets; offset++) { @@ -743,6 +744,7 @@ Index count) const { constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode); PacketBlock<PacketType, NumPackets> packets; + for (Index i = 0; i < NumPackets; i++) packets.packet[i] = pzero(PacketType()); Index offset = begin / SrcPacketSize; Index actualBegin = begin % SrcPacketSize; for (; offset < NumPackets; offset++) {
diff --git a/Eigen/src/SVD/BDCSVD.h b/Eigen/src/SVD/BDCSVD.h index 64fec75..85661a3 100644 --- a/Eigen/src/SVD/BDCSVD.h +++ b/Eigen/src/SVD/BDCSVD.h
@@ -165,7 +165,8 @@ * * \param matrix the matrix to decompose */ - BDCSVD(const MatrixType& matrix) : m_algoswap(16), m_numIters(0) { + template <typename Derived> + BDCSVD(const MatrixBase<Derived>& matrix) : m_algoswap(16), m_numIters(0) { compute_impl(matrix, internal::get_computation_options(Options)); } @@ -193,7 +194,10 @@ * * \param matrix the matrix to decompose */ - BDCSVD& compute(const MatrixType& matrix) { return compute_impl(matrix, m_computationOptions); } + template <typename Derived> + BDCSVD& compute(const MatrixBase<Derived>& matrix) { + return compute_impl(matrix, m_computationOptions); + } /** \brief Method performing the decomposition of given matrix, as specified by * the `computationOptions` parameter. @@ -204,7 +208,8 @@ * \deprecated Will be removed in the next major Eigen version. Options should * be specified in the \a Options template parameter. */ - EIGEN_DEPRECATED BDCSVD& compute(const MatrixType& matrix, unsigned int computationOptions) { + template <typename Derived> + EIGEN_DEPRECATED BDCSVD& compute(const MatrixBase<Derived>& matrix, unsigned int computationOptions) { internal::check_svd_options_assertions<MatrixType, Options>(computationOptions, matrix.rows(), matrix.cols()); return compute_impl(matrix, computationOptions); } @@ -215,7 +220,8 @@ } private: - BDCSVD& compute_impl(const MatrixType& matrix, unsigned int computationOptions); + template <typename Derived> + BDCSVD& compute_impl(const MatrixBase<Derived>& matrix, unsigned int computationOptions); void divide(Index firstCol, Index lastCol, Index firstRowW, Index firstColW, Index shift); void computeSVDofM(Index firstCol, Index n, MatrixXr& U, VectorType& singVals, MatrixXr& V); void computeSingVals(const ArrayRef& col0, const ArrayRef& diag, const IndicesRef& perm, VectorType& singVals, @@ -307,8 +313,13 @@ } // end allocate template <typename MatrixType, int Options> -BDCSVD<MatrixType, Options>& BDCSVD<MatrixType, Options>::compute_impl(const MatrixType& matrix, +template <typename Derived> +BDCSVD<MatrixType, Options>& BDCSVD<MatrixType, Options>::compute_impl(const MatrixBase<Derived>& matrix, unsigned int computationOptions) { + EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived, MatrixType); + EIGEN_STATIC_ASSERT((std::is_same<typename Derived::Scalar, typename MatrixType::Scalar>::value), + Input matrix must have the same Scalar type as the BDCSVD object.); + #ifdef EIGEN_BDCSVD_DEBUG_VERBOSE std::cout << "\n\n\n=================================================================================================" "=====================\n\n\n";
diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index ecbc363..1abde17 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h
@@ -565,7 +565,10 @@ * * \param matrix the matrix to decompose */ - explicit JacobiSVD(const MatrixType& matrix) { compute_impl(matrix, internal::get_computation_options(Options)); } + template <typename Derived> + explicit JacobiSVD(const MatrixBase<Derived>& matrix) { + compute_impl(matrix, internal::get_computation_options(Options)); + } /** \brief Constructor performing the decomposition of given matrix using specified options * for computing unitaries. @@ -580,8 +583,10 @@ * be specified in the \a Options template parameter. */ // EIGEN_DEPRECATED // TODO(cantonios): re-enable after fixing a few 3p libraries that error on deprecation warnings. - JacobiSVD(const MatrixType& matrix, unsigned int computationOptions) { - internal::check_svd_options_assertions<MatrixType, Options>(computationOptions, matrix.rows(), matrix.cols()); + template <typename Derived> + JacobiSVD(const MatrixBase<Derived>& matrix, unsigned int computationOptions) { + internal::check_svd_options_assertions<MatrixBase<Derived>, Options>(computationOptions, matrix.rows(), + matrix.cols()); compute_impl(matrix, computationOptions); } @@ -590,7 +595,10 @@ * * \param matrix the matrix to decompose */ - JacobiSVD& compute(const MatrixType& matrix) { return compute_impl(matrix, m_computationOptions); } + template <typename Derived> + JacobiSVD& compute(const MatrixBase<Derived>& matrix) { + return compute_impl(matrix, m_computationOptions); + } /** \brief Method performing the decomposition of given matrix, as specified by * the `computationOptions` parameter. @@ -601,8 +609,10 @@ * \deprecated Will be removed in the next major Eigen version. Options should * be specified in the \a Options template parameter. */ - EIGEN_DEPRECATED JacobiSVD& compute(const MatrixType& matrix, unsigned int computationOptions) { - internal::check_svd_options_assertions<MatrixType, Options>(m_computationOptions, matrix.rows(), matrix.cols()); + template <typename Derived> + EIGEN_DEPRECATED JacobiSVD& compute(const MatrixBase<Derived>& matrix, unsigned int computationOptions) { + internal::check_svd_options_assertions<MatrixBase<Derived>, Options>(m_computationOptions, matrix.rows(), + matrix.cols()); return compute_impl(matrix, computationOptions); } @@ -626,7 +636,8 @@ } private: - JacobiSVD& compute_impl(const MatrixType& matrix, unsigned int computationOptions); + template <typename Derived> + JacobiSVD& compute_impl(const MatrixBase<Derived>& matrix, unsigned int computationOptions); protected: using Base::m_computationOptions; @@ -664,8 +675,13 @@ }; template <typename MatrixType, int Options> -JacobiSVD<MatrixType, Options>& JacobiSVD<MatrixType, Options>::compute_impl(const MatrixType& matrix, +template <typename Derived> +JacobiSVD<MatrixType, Options>& JacobiSVD<MatrixType, Options>::compute_impl(const MatrixBase<Derived>& matrix, unsigned int computationOptions) { + EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived, MatrixType); + EIGEN_STATIC_ASSERT((std::is_same<typename Derived::Scalar, typename MatrixType::Scalar>::value), + Input matrix must have the same Scalar type as the BDCSVD object.); + using std::abs; allocate(matrix.rows(), matrix.cols(), computationOptions);
diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h index a28aa96..f4e0428 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
@@ -284,12 +284,13 @@ struct matrix_exp_computeUV<MatrixType, long double> { template <typename ArgType> static void run(const ArgType& arg, MatrixType& U, MatrixType& V, int& squarings) { - using Scalar = typename traits<MatrixType>::Scalar; #if LDBL_MANT_DIG == 53 // double precision matrix_exp_computeUV<MatrixType, double>::run(arg, U, V, squarings); #else + using Scalar = typename traits<MatrixType>::Scalar; + using std::frexp; using std::pow; const long double l1norm = arg.cwiseAbs().colwise().sum().maxCoeff();