diff --git a/Eigen/src/SVD/BDCSVD.h b/Eigen/src/SVD/BDCSVD.h index 9af96ec31..bab1e4d70 100644 --- a/Eigen/src/SVD/BDCSVD.h +++ b/Eigen/src/SVD/BDCSVD.h @@ -75,7 +75,7 @@ struct allocate_small_svd { * * \tparam MatrixType_ the type of the matrix of which we are computing the SVD decomposition * - * \tparam Options this optional parameter allows one to specify options for computing unitaries \a U and \a V. + * \tparam Options_ this optional parameter allows one to specify options for computing unitaries \a U and \a V. * Possible values are #ComputeThinU, #ComputeThinV, #ComputeFullU, #ComputeFullV. * It is not possible to request both the thin and full version of \a U or \a V. * By default, unitaries are not computed. @@ -93,8 +93,8 @@ struct allocate_small_svd { * * \sa class JacobiSVD */ -template -class BDCSVD : public SVDBase > { +template +class BDCSVD : public SVDBase > { typedef SVDBase Base; public: @@ -104,17 +104,19 @@ public: using Base::computeV; typedef MatrixType_ MatrixType; - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; + typedef typename Base::Scalar Scalar; + typedef typename Base::RealScalar RealScalar; typedef typename NumTraits::Literal Literal; + enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - DiagSizeAtCompileTime = internal::min_size_prefer_dynamic(RowsAtCompileTime, ColsAtCompileTime), - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - MaxDiagSizeAtCompileTime = internal::min_size_prefer_fixed(MaxRowsAtCompileTime, MaxColsAtCompileTime), - MatrixOptions = MatrixType::Options + Options = Options_, + RowsAtCompileTime = Base::RowsAtCompileTime, + ColsAtCompileTime = Base::ColsAtCompileTime, + DiagSizeAtCompileTime = Base::DiagSizeAtCompileTime, + MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime, + MaxColsAtCompileTime = Base::MaxColsAtCompileTime, + MaxDiagSizeAtCompileTime = Base::MaxDiagSizeAtCompileTime, + MatrixOptions = Base::MatrixOptions }; typedef typename Base::MatrixUType MatrixUType; diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 8ae583a8e..88a555304 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -510,23 +510,24 @@ struct traits > : svd_traits -class JacobiSVD : public SVDBase > { +template +class JacobiSVD : public SVDBase > { typedef SVDBase Base; public: typedef MatrixType_ MatrixType; - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; + typedef typename Base::Scalar Scalar; + typedef typename Base::RealScalar RealScalar; enum { + Options = Options_, QRPreconditioner = internal::get_qr_preconditioner(Options), - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - DiagSizeAtCompileTime = internal::min_size_prefer_dynamic(RowsAtCompileTime, ColsAtCompileTime), - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - MaxDiagSizeAtCompileTime = internal::min_size_prefer_fixed(MaxRowsAtCompileTime, MaxColsAtCompileTime), - MatrixOptions = MatrixType::Options + RowsAtCompileTime = Base::RowsAtCompileTime, + ColsAtCompileTime = Base::ColsAtCompileTime, + DiagSizeAtCompileTime = Base::DiagSizeAtCompileTime, + MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime, + MaxColsAtCompileTime = Base::MaxColsAtCompileTime, + MaxDiagSizeAtCompileTime = Base::MaxDiagSizeAtCompileTime, + MatrixOptions = Base::MatrixOptions }; typedef typename Base::MatrixUType MatrixUType; @@ -591,7 +592,7 @@ class JacobiSVD : public SVDBase > { * \deprecated Will be removed in the next major Eigen version. Options should * be specified in the \a Options template parameter. */ - EIGEN_DEPRECATED + // 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(computationOptions, matrix.rows(), matrix.cols()); compute_impl(matrix, computationOptions); @@ -655,9 +656,9 @@ class JacobiSVD : public SVDBase > { "JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. " "Use the ColPivHouseholderQR preconditioner instead.") - template + template friend struct internal::svd_precondition_2x2_block_to_be_real; - template + template friend struct internal::qr_preconditioner_impl; internal::qr_preconditioner_impl diff --git a/Eigen/src/SVD/SVDBase.h b/Eigen/src/SVD/SVDBase.h index 85b3e2057..f01c7a92f 100644 --- a/Eigen/src/SVD/SVDBase.h +++ b/Eigen/src/SVD/SVDBase.h @@ -32,10 +32,10 @@ constexpr int get_qr_preconditioner(int options) { return options & QRPreconditi constexpr int get_computation_options(int options) { return options & ComputationOptionsBits; } -constexpr int should_svd_compute_thin_u(int options) { return options & ComputeThinU; } -constexpr int should_svd_compute_full_u(int options) { return options & ComputeFullU; } -constexpr int should_svd_compute_thin_v(int options) { return options & ComputeThinV; } -constexpr int should_svd_compute_full_v(int options) { return options & ComputeFullV; } +constexpr bool should_svd_compute_thin_u(int options) { return (options & ComputeThinU) != 0; } +constexpr bool should_svd_compute_full_u(int options) { return (options & ComputeFullU) != 0; } +constexpr bool should_svd_compute_thin_v(int options) { return (options & ComputeThinV) != 0; } +constexpr bool should_svd_compute_full_v(int options) { return (options & ComputeFullV) != 0; } template void check_svd_options_assertions(unsigned int computationOptions, Index rows, Index cols) { @@ -61,8 +61,9 @@ template struct traits > enum { Flags = 0 }; }; -template +template struct svd_traits : traits { + static constexpr int Options = Options_; static constexpr bool ShouldComputeFullU = internal::should_svd_compute_full_u(Options); static constexpr bool ShouldComputeThinU = internal::should_svd_compute_thin_u(Options); static constexpr bool ShouldComputeFullV = internal::should_svd_compute_full_v(Options); diff --git a/test/jacobisvd.cpp b/test/jacobisvd.cpp index fab588204..724e29f58 100644 --- a/test/jacobisvd.cpp +++ b/test/jacobisvd.cpp @@ -106,7 +106,8 @@ void msvc_workaround() { const Foo::Bar a; const Foo::Bar b; - std::max EIGEN_NOT_A_MACRO (a,b); + const Foo::Bar c = std::max EIGEN_NOT_A_MACRO (a,b); + EIGEN_UNUSED_VARIABLE(c) } EIGEN_DECLARE_TEST(jacobisvd) diff --git a/test/svd_common.h b/test/svd_common.h index 11e225f82..9822595bf 100644 --- a/test/svd_common.h +++ b/test/svd_common.h @@ -113,9 +113,8 @@ void svd_least_square(const MatrixType& m) { RhsType rhs = RhsType::Random(rows, internal::random(1, cols)); SvdType svd(m); - if (internal::is_same::value) - svd.setThreshold(1e-8); - else if(internal::is_same::value) svd.setThreshold(2e-4); + if (internal::is_same::value) svd.setThreshold(RealScalar(1e-8)); + else if(internal::is_same::value) svd.setThreshold(RealScalar(2e-4)); SolutionType x = svd.solve(rhs); diff --git a/test/svd_fill.h b/test/svd_fill.h index d68647e99..6411f57a3 100644 --- a/test/svd_fill.h +++ b/test/svd_fill.h @@ -64,8 +64,11 @@ void svd_fill_random(MatrixType &m, int Option = 0) } Matrix samples(9); - samples << 0, four_denorms(), - -RealScalar(1)/NumTraits::highest(), RealScalar(1)/NumTraits::highest(), (std::numeric_limits::min)(), pow((std::numeric_limits::min)(),0.8); + samples << Scalar(0), four_denorms(), + -RealScalar(1)/NumTraits::highest(), + RealScalar(1)/NumTraits::highest(), + (std::numeric_limits::min)(), + pow((std::numeric_limits::min)(), RealScalar(0.8)); if(Option==Symmetric) {