From 9175f50d6f88bd38789f2a9c6d4f0bfe1b8b6b37 Mon Sep 17 00:00:00 2001 From: acxz <5379597-acxz@users.noreply.gitlab.com> Date: Mon, 16 Nov 2020 15:37:40 +0000 Subject: Add EIGEN_DEVICE_FUNC to TranspositionsBase Fixes #2057. --- Eigen/src/Core/Transpositions.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'Eigen/src/Core/Transpositions.h') diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h index f6d02f7d8..fcfe6f428 100644 --- a/Eigen/src/Core/Transpositions.h +++ b/Eigen/src/Core/Transpositions.h @@ -10,20 +10,22 @@ #ifndef EIGEN_TRANSPOSITIONS_H #define EIGEN_TRANSPOSITIONS_H -namespace Eigen { +namespace Eigen { template class TranspositionsBase { typedef internal::traits Traits; - + public: typedef typename Traits::IndicesType IndicesType; typedef typename IndicesType::Scalar StorageIndex; typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + EIGEN_DEVICE_FUNC Derived& derived() { return *static_cast(this); } + EIGEN_DEVICE_FUNC const Derived& derived() const { return *static_cast(this); } /** Copies the \a other transpositions into \c *this */ @@ -35,10 +37,13 @@ class TranspositionsBase } /** \returns the number of transpositions */ + EIGEN_DEVICE_FUNC Index size() const { return indices().size(); } /** \returns the number of rows of the equivalent permutation matrix */ + EIGEN_DEVICE_FUNC Index rows() const { return indices().size(); } /** \returns the number of columns of the equivalent permutation matrix */ + EIGEN_DEVICE_FUNC Index cols() const { return indices().size(); } /** Direct access to the underlying index vector */ @@ -55,8 +60,10 @@ class TranspositionsBase inline StorageIndex& operator[](Index i) { return indices()(i); } /** const version of indices(). */ + EIGEN_DEVICE_FUNC const IndicesType& indices() const { return derived().indices(); } /** \returns a reference to the stored array representing the transpositions. */ + EIGEN_DEVICE_FUNC IndicesType& indices() { return derived().indices(); } /** Resizes to given size. */ @@ -178,8 +185,10 @@ class Transpositions : public TranspositionsBase,P #endif /** const version of indices(). */ + EIGEN_DEVICE_FUNC const IndicesType& indices() const { return m_indices; } - + /** \returns a reference to the stored array representing the transpositions. */ + EIGEN_DEVICE_FUNC IndicesType& indices() { return m_indices; } protected: @@ -279,9 +290,11 @@ class TranspositionsWrapper } /** const version of indices(). */ + EIGEN_DEVICE_FUNC const IndicesType& indices() const { return m_indices; } /** \returns a reference to the stored array representing the transpositions. */ + EIGEN_DEVICE_FUNC IndicesType& indices() { return m_indices; } protected: @@ -335,8 +348,11 @@ class Transpose > explicit Transpose(const TranspositionType& t) : m_transpositions(t) {} + EIGEN_DEVICE_FUNC Index size() const { return m_transpositions.size(); } + EIGEN_DEVICE_FUNC Index rows() const { return m_transpositions.size(); } + EIGEN_DEVICE_FUNC Index cols() const { return m_transpositions.size(); } /** \returns the \a matrix with the inverse transpositions applied to the columns. @@ -356,7 +372,7 @@ class Transpose > { return Product(*this, matrix.derived()); } - + const TranspositionType& nestedExpression() const { return m_transpositions; } protected: -- cgit v1.2.3