From 8b101ade2b6aa964c07ce9edc26fd7c7317ff008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=C3=A1nchez?= Date: Sun, 17 Mar 2024 16:28:17 +0000 Subject: [PATCH] Fix CwiseUnaryView for MSVC. --- Eigen/src/Core/CwiseUnaryView.h | 101 +++++++++++++++----------------- 1 file changed, 47 insertions(+), 54 deletions(-) diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h index 6bd838b4d..49b141011 100644 --- a/Eigen/src/Core/CwiseUnaryView.h +++ b/Eigen/src/Core/CwiseUnaryView.h @@ -47,61 +47,9 @@ struct traits > : traits::value> -class CwiseUnaryViewImpl; - -} // namespace internal - -/** \class CwiseUnaryView - * \ingroup Core_Module - * - * \brief Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector - * - * \tparam ViewOp template functor implementing the view - * \tparam MatrixType the type of the matrix we are applying the unary operator - * - * This class represents a lvalue expression of a generic unary view operator of a matrix or a vector. - * It is the return type of real() and imag(), and most of the time this is the only way it is used. - * - * \sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp - */ -template -class CwiseUnaryView : public internal::CwiseUnaryViewImpl::StorageKind> { - public: - typedef typename internal::CwiseUnaryViewImpl::StorageKind>::Base Base; - EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView) - typedef typename internal::ref_selector::non_const_type MatrixTypeNested; - typedef internal::remove_all_t NestedExpression; - - explicit EIGEN_DEVICE_FUNC inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp()) - : m_matrix(mat), m_functor(func) {} - - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView) - - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); } - - /** \returns the functor representing unary operation */ - EIGEN_DEVICE_FUNC const ViewOp& functor() const { return m_functor; } - - /** \returns the nested expression */ - EIGEN_DEVICE_FUNC const internal::remove_all_t& nestedExpression() const { return m_matrix; } - - /** \returns the nested expression */ - EIGEN_DEVICE_FUNC std::remove_reference_t& nestedExpression() { return m_matrix; } - - protected: - MatrixTypeNested m_matrix; - ViewOp m_functor; -}; - -namespace internal { - // Generic API dispatcher -template +template ::value> class CwiseUnaryViewImpl : public generic_xpr_base >::type { public: typedef typename generic_xpr_base >::type Base; @@ -169,6 +117,51 @@ class CwiseUnaryViewImpl } // namespace internal +/** \class CwiseUnaryView + * \ingroup Core_Module + * + * \brief Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector + * + * \tparam ViewOp template functor implementing the view + * \tparam MatrixType the type of the matrix we are applying the unary operator + * + * This class represents a lvalue expression of a generic unary view operator of a matrix or a vector. + * It is the return type of real() and imag(), and most of the time this is the only way it is used. + * + * \sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp + */ +template +class CwiseUnaryView : public internal::CwiseUnaryViewImpl::StorageKind> { + public: + typedef typename internal::CwiseUnaryViewImpl::StorageKind>::Base Base; + EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView) + typedef typename internal::ref_selector::non_const_type MatrixTypeNested; + typedef internal::remove_all_t NestedExpression; + + explicit EIGEN_DEVICE_FUNC inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp()) + : m_matrix(mat), m_functor(func) {} + + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView) + + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); } + + /** \returns the functor representing unary operation */ + EIGEN_DEVICE_FUNC const ViewOp& functor() const { return m_functor; } + + /** \returns the nested expression */ + EIGEN_DEVICE_FUNC const internal::remove_all_t& nestedExpression() const { return m_matrix; } + + /** \returns the nested expression */ + EIGEN_DEVICE_FUNC std::remove_reference_t& nestedExpression() { return m_matrix; } + + protected: + MatrixTypeNested m_matrix; + ViewOp m_functor; +}; + } // namespace Eigen #endif // EIGEN_CWISE_UNARY_VIEW_H