Add EIGEN_DEVICE_FUNC to TranspositionsBase

Fixes #2057.
This commit is contained in:
acxz 2020-11-16 15:37:40 +00:00 committed by David Tellenbach
parent 280f4f2407
commit 9175f50d6f

View File

@ -10,20 +10,22 @@
#ifndef EIGEN_TRANSPOSITIONS_H #ifndef EIGEN_TRANSPOSITIONS_H
#define EIGEN_TRANSPOSITIONS_H #define EIGEN_TRANSPOSITIONS_H
namespace Eigen { namespace Eigen {
template<typename Derived> template<typename Derived>
class TranspositionsBase class TranspositionsBase
{ {
typedef internal::traits<Derived> Traits; typedef internal::traits<Derived> Traits;
public: public:
typedef typename Traits::IndicesType IndicesType; typedef typename Traits::IndicesType IndicesType;
typedef typename IndicesType::Scalar StorageIndex; typedef typename IndicesType::Scalar StorageIndex;
typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
EIGEN_DEVICE_FUNC
Derived& derived() { return *static_cast<Derived*>(this); } Derived& derived() { return *static_cast<Derived*>(this); }
EIGEN_DEVICE_FUNC
const Derived& derived() const { return *static_cast<const Derived*>(this); } const Derived& derived() const { return *static_cast<const Derived*>(this); }
/** Copies the \a other transpositions into \c *this */ /** Copies the \a other transpositions into \c *this */
@ -35,10 +37,13 @@ class TranspositionsBase
} }
/** \returns the number of transpositions */ /** \returns the number of transpositions */
EIGEN_DEVICE_FUNC
Index size() const { return indices().size(); } Index size() const { return indices().size(); }
/** \returns the number of rows of the equivalent permutation matrix */ /** \returns the number of rows of the equivalent permutation matrix */
EIGEN_DEVICE_FUNC
Index rows() const { return indices().size(); } Index rows() const { return indices().size(); }
/** \returns the number of columns of the equivalent permutation matrix */ /** \returns the number of columns of the equivalent permutation matrix */
EIGEN_DEVICE_FUNC
Index cols() const { return indices().size(); } Index cols() const { return indices().size(); }
/** Direct access to the underlying index vector */ /** Direct access to the underlying index vector */
@ -55,8 +60,10 @@ class TranspositionsBase
inline StorageIndex& operator[](Index i) { return indices()(i); } inline StorageIndex& operator[](Index i) { return indices()(i); }
/** const version of indices(). */ /** const version of indices(). */
EIGEN_DEVICE_FUNC
const IndicesType& indices() const { return derived().indices(); } const IndicesType& indices() const { return derived().indices(); }
/** \returns a reference to the stored array representing the transpositions. */ /** \returns a reference to the stored array representing the transpositions. */
EIGEN_DEVICE_FUNC
IndicesType& indices() { return derived().indices(); } IndicesType& indices() { return derived().indices(); }
/** Resizes to given size. */ /** Resizes to given size. */
@ -178,8 +185,10 @@ class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTim
{} {}
/** const version of indices(). */ /** const version of indices(). */
EIGEN_DEVICE_FUNC
const IndicesType& indices() const { return m_indices; } const IndicesType& indices() const { return m_indices; }
/** \returns a reference to the stored array representing the transpositions. */ /** \returns a reference to the stored array representing the transpositions. */
EIGEN_DEVICE_FUNC
IndicesType& indices() { return m_indices; } IndicesType& indices() { return m_indices; }
protected: protected:
@ -237,9 +246,11 @@ class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,P
#endif #endif
/** const version of indices(). */ /** const version of indices(). */
EIGEN_DEVICE_FUNC
const IndicesType& indices() const { return m_indices; } const IndicesType& indices() const { return m_indices; }
/** \returns a reference to the stored array representing the transpositions. */ /** \returns a reference to the stored array representing the transpositions. */
EIGEN_DEVICE_FUNC
IndicesType& indices() { return m_indices; } IndicesType& indices() { return m_indices; }
protected: protected:
@ -279,9 +290,11 @@ class TranspositionsWrapper
} }
/** const version of indices(). */ /** const version of indices(). */
EIGEN_DEVICE_FUNC
const IndicesType& indices() const { return m_indices; } const IndicesType& indices() const { return m_indices; }
/** \returns a reference to the stored array representing the transpositions. */ /** \returns a reference to the stored array representing the transpositions. */
EIGEN_DEVICE_FUNC
IndicesType& indices() { return m_indices; } IndicesType& indices() { return m_indices; }
protected: protected:
@ -335,8 +348,11 @@ class Transpose<TranspositionsBase<TranspositionsDerived> >
explicit Transpose(const TranspositionType& t) : m_transpositions(t) {} explicit Transpose(const TranspositionType& t) : m_transpositions(t) {}
EIGEN_DEVICE_FUNC
Index size() const { return m_transpositions.size(); } Index size() const { return m_transpositions.size(); }
EIGEN_DEVICE_FUNC
Index rows() const { return m_transpositions.size(); } Index rows() const { return m_transpositions.size(); }
EIGEN_DEVICE_FUNC
Index cols() const { return m_transpositions.size(); } Index cols() const { return m_transpositions.size(); }
/** \returns the \a matrix with the inverse transpositions applied to the columns. /** \returns the \a matrix with the inverse transpositions applied to the columns.
@ -356,7 +372,7 @@ class Transpose<TranspositionsBase<TranspositionsDerived> >
{ {
return Product<Transpose, OtherDerived, AliasFreeProduct>(*this, matrix.derived()); return Product<Transpose, OtherDerived, AliasFreeProduct>(*this, matrix.derived());
} }
const TranspositionType& nestedExpression() const { return m_transpositions; } const TranspositionType& nestedExpression() const { return m_transpositions; }
protected: protected: