From 5adcc6c7b48b7a213af91bc123a02ab87751228e Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 7 Feb 2013 19:06:14 +0100 Subject: Add support for NVCC5: most of the Core and part of LU are callable from CUDA code. Still a lot to do. --- Eigen/src/plugins/ArrayCwiseUnaryOps.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Eigen/src/plugins/ArrayCwiseUnaryOps.h') diff --git a/Eigen/src/plugins/ArrayCwiseUnaryOps.h b/Eigen/src/plugins/ArrayCwiseUnaryOps.h index a59636790..afb0fb6e3 100644 --- a/Eigen/src/plugins/ArrayCwiseUnaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseUnaryOps.h @@ -7,6 +7,7 @@ * * \sa abs2() */ +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> abs() const { @@ -20,6 +21,7 @@ abs() const * * \sa abs(), square() */ +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> abs2() const { @@ -33,6 +35,7 @@ abs2() const * * \sa pow(), log(), sin(), cos() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> exp() const { @@ -46,6 +49,7 @@ exp() const * * \sa exp() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> log() const { @@ -59,6 +63,7 @@ log() const * * \sa pow(), square() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> sqrt() const { @@ -72,6 +77,7 @@ sqrt() const * * \sa sin(), acos() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> cos() const { @@ -86,6 +92,7 @@ cos() const * * \sa cos(), asin() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> sin() const { @@ -99,6 +106,7 @@ sin() const * * \sa cos(), asin() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> acos() const { @@ -112,6 +120,7 @@ acos() const * * \sa sin(), acos() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> asin() const { @@ -125,6 +134,7 @@ asin() const * * \sa cos(), sin() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, Derived> tan() const { @@ -139,6 +149,7 @@ tan() const * * \sa exp(), log() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> pow(const Scalar& exponent) const { @@ -154,6 +165,7 @@ pow(const Scalar& exponent) const * * \sa operator/(), operator*() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> inverse() const { @@ -167,6 +179,7 @@ inverse() const * * \sa operator/(), operator*(), abs2() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> square() const { @@ -180,6 +193,7 @@ square() const * * \sa square(), pow() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> cube() const { -- cgit v1.2.3 From 6126ad801f89cb88d46ed0dae0d8e9448652c506 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 31 Jul 2013 15:30:50 +0200 Subject: Extend support for nvcc to Array objects and wrappers --- Eigen/src/Core/ArrayBase.h | 12 ++++++++++++ Eigen/src/Core/ArrayWrapper.h | 33 +++++++++++++++++++++++++++++++++ Eigen/src/Core/CwiseBinaryOp.h | 1 + Eigen/src/Core/Diagonal.h | 18 ++++++++++++++++++ Eigen/src/Core/DiagonalMatrix.h | 33 +++++++++++++++++++++++++++++++++ Eigen/src/Core/MatrixBase.h | 20 +++++++++++++++++--- Eigen/src/plugins/ArrayCwiseBinaryOps.h | 11 +++++++++++ Eigen/src/plugins/ArrayCwiseUnaryOps.h | 1 + 8 files changed, 126 insertions(+), 3 deletions(-) (limited to 'Eigen/src/plugins/ArrayCwiseUnaryOps.h') diff --git a/Eigen/src/Core/ArrayBase.h b/Eigen/src/Core/ArrayBase.h index 38852600d..9c6daf4fe 100644 --- a/Eigen/src/Core/ArrayBase.h +++ b/Eigen/src/Core/ArrayBase.h @@ -118,40 +118,52 @@ template class ArrayBase /** Special case of the template operator=, in order to prevent the compiler * from generating a default operator= (issue hit with g++ 4.1) */ + EIGEN_DEVICE_FUNC Derived& operator=(const ArrayBase& other) { return internal::assign_selector::run(derived(), other.derived()); } + EIGEN_DEVICE_FUNC Derived& operator+=(const Scalar& scalar) { return *this = derived() + scalar; } + EIGEN_DEVICE_FUNC Derived& operator-=(const Scalar& scalar) { return *this = derived() - scalar; } template + EIGEN_DEVICE_FUNC Derived& operator+=(const ArrayBase& other); template + EIGEN_DEVICE_FUNC Derived& operator-=(const ArrayBase& other); template + EIGEN_DEVICE_FUNC Derived& operator*=(const ArrayBase& other); template + EIGEN_DEVICE_FUNC Derived& operator/=(const ArrayBase& other); public: + EIGEN_DEVICE_FUNC ArrayBase& array() { return *this; } + EIGEN_DEVICE_FUNC const ArrayBase& array() const { return *this; } /** \returns an \link Eigen::MatrixBase Matrix \endlink expression of this array * \sa MatrixBase::array() */ + EIGEN_DEVICE_FUNC MatrixWrapper matrix() { return derived(); } + EIGEN_DEVICE_FUNC const MatrixWrapper matrix() const { return derived(); } // template // inline void evalTo(Dest& dst) const { dst = matrix(); } protected: + EIGEN_DEVICE_FUNC ArrayBase() : Base() {} private: diff --git a/Eigen/src/Core/ArrayWrapper.h b/Eigen/src/Core/ArrayWrapper.h index a791bc358..21830745b 100644 --- a/Eigen/src/Core/ArrayWrapper.h +++ b/Eigen/src/Core/ArrayWrapper.h @@ -48,41 +48,54 @@ class ArrayWrapper : public ArrayBase > typedef typename internal::nested::type NestedExpressionType; + EIGEN_DEVICE_FUNC inline ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {} + EIGEN_DEVICE_FUNC inline Index rows() const { return m_expression.rows(); } + EIGEN_DEVICE_FUNC inline Index cols() const { return m_expression.cols(); } + EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_expression.outerStride(); } + EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_expression.innerStride(); } + EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); } + EIGEN_DEVICE_FUNC inline const Scalar* data() const { return m_expression.data(); } + EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index rowId, Index colId) const { return m_expression.coeff(rowId, colId); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index rowId, Index colId) { return m_expression.const_cast_derived().coeffRef(rowId, colId); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const { return m_expression.const_cast_derived().coeffRef(rowId, colId); } + EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index index) const { return m_expression.coeff(index); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) { return m_expression.const_cast_derived().coeffRef(index); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_expression.const_cast_derived().coeffRef(index); @@ -113,9 +126,11 @@ class ArrayWrapper : public ArrayBase > } template + EIGEN_DEVICE_FUNC inline void evalTo(Dest& dst) const { dst = m_expression; } const typename internal::remove_all::type& + EIGEN_DEVICE_FUNC nestedExpression() const { return m_expression; @@ -123,9 +138,11 @@ class ArrayWrapper : public ArrayBase > /** Forwards the resizing request to the nested expression * \sa DenseBase::resize(Index) */ + EIGEN_DEVICE_FUNC void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); } /** Forwards the resizing request to the nested expression * \sa DenseBase::resize(Index,Index)*/ + EIGEN_DEVICE_FUNC void resize(Index nbRows, Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); } protected: @@ -168,41 +185,54 @@ class MatrixWrapper : public MatrixBase > typedef typename internal::nested::type NestedExpressionType; + EIGEN_DEVICE_FUNC inline MatrixWrapper(ExpressionType& a_matrix) : m_expression(a_matrix) {} + EIGEN_DEVICE_FUNC inline Index rows() const { return m_expression.rows(); } + EIGEN_DEVICE_FUNC inline Index cols() const { return m_expression.cols(); } + EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_expression.outerStride(); } + EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_expression.innerStride(); } + EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); } + EIGEN_DEVICE_FUNC inline const Scalar* data() const { return m_expression.data(); } + EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index rowId, Index colId) const { return m_expression.coeff(rowId, colId); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index rowId, Index colId) { return m_expression.const_cast_derived().coeffRef(rowId, colId); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const { return m_expression.derived().coeffRef(rowId, colId); } + EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index index) const { return m_expression.coeff(index); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) { return m_expression.const_cast_derived().coeffRef(index); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_expression.const_cast_derived().coeffRef(index); @@ -232,6 +262,7 @@ class MatrixWrapper : public MatrixBase > m_expression.const_cast_derived().template writePacket(index, val); } + EIGEN_DEVICE_FUNC const typename internal::remove_all::type& nestedExpression() const { @@ -240,9 +271,11 @@ class MatrixWrapper : public MatrixBase > /** Forwards the resizing request to the nested expression * \sa DenseBase::resize(Index) */ + EIGEN_DEVICE_FUNC void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); } /** Forwards the resizing request to the nested expression * \sa DenseBase::resize(Index,Index)*/ + EIGEN_DEVICE_FUNC void resize(Index nbRows, Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); } protected: diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index e603fb9d6..e20daacc8 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -235,3 +235,4 @@ MatrixBase::operator+=(const MatrixBase& other) } // end namespace Eigen #endif // EIGEN_CWISE_BINARY_OP_H + diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index aab8007b3..4436c6a69 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -70,20 +70,25 @@ template class Diagonal typedef typename internal::dense_xpr_base::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal) + EIGEN_DEVICE_FUNC inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal) + EIGEN_DEVICE_FUNC inline Index rows() const { return m_index.value()<0 ? (std::min)(m_matrix.cols(),m_matrix.rows()+m_index.value()) : (std::min)(m_matrix.rows(),m_matrix.cols()-m_index.value()); } + EIGEN_DEVICE_FUNC inline Index cols() const { return 1; } + EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_matrix.outerStride() + 1; } + EIGEN_DEVICE_FUNC inline Index outerStride() const { return 0; @@ -95,47 +100,57 @@ template class Diagonal const Scalar >::type ScalarWithConstIfNotLvalue; + EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return &(m_matrix.const_cast_derived().coeffRef(rowOffset(), colOffset())); } + EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(m_matrix.const_cast_derived().coeffRef(rowOffset(), colOffset())); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index) { EIGEN_STATIC_ASSERT_LVALUE(MatrixType) return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset()); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index row, Index) const { return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset()); } + EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index row, Index) const { return m_matrix.coeff(row+rowOffset(), row+colOffset()); } + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index idx) { EIGEN_STATIC_ASSERT_LVALUE(MatrixType) return m_matrix.const_cast_derived().coeffRef(idx+rowOffset(), idx+colOffset()); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index idx) const { return m_matrix.const_cast_derived().coeffRef(idx+rowOffset(), idx+colOffset()); } + EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index idx) const { return m_matrix.coeff(idx+rowOffset(), idx+colOffset()); } + EIGEN_DEVICE_FUNC const typename internal::remove_all::type& nestedExpression() const { return m_matrix; } + EIGEN_DEVICE_FUNC int index() const { return m_index.value(); @@ -147,8 +162,11 @@ template class Diagonal private: // some compilers may fail to optimize std::max etc in case of compile-time constants... + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index absDiagIndex() const { return m_index.value()>0 ? m_index.value() : -m_index.value(); } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value()>0 ? 0 : -m_index.value(); } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value()>0 ? m_index.value() : 0; } // triger a compile time error is someone try to call packet template typename MatrixType::PacketReturnType packet(Index) const; diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index e6c220f41..f7ac22f8b 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -37,45 +37,59 @@ class DiagonalBase : public EigenBase typedef DenseMatrixType DenseType; typedef DiagonalMatrix PlainObject; + EIGEN_DEVICE_FUNC inline const Derived& derived() const { return *static_cast(this); } + EIGEN_DEVICE_FUNC inline Derived& derived() { return *static_cast(this); } + EIGEN_DEVICE_FUNC DenseMatrixType toDenseMatrix() const { return derived(); } template + EIGEN_DEVICE_FUNC void evalTo(MatrixBase &other) const; template + EIGEN_DEVICE_FUNC void addTo(MatrixBase &other) const { other.diagonal() += diagonal(); } template + EIGEN_DEVICE_FUNC void subTo(MatrixBase &other) const { other.diagonal() -= diagonal(); } + EIGEN_DEVICE_FUNC inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); } + EIGEN_DEVICE_FUNC inline DiagonalVectorType& diagonal() { return derived().diagonal(); } + EIGEN_DEVICE_FUNC inline Index rows() const { return diagonal().size(); } + EIGEN_DEVICE_FUNC inline Index cols() const { return diagonal().size(); } /** \returns the diagonal matrix product of \c *this by the matrix \a matrix. */ template + EIGEN_DEVICE_FUNC const DiagonalProduct operator*(const MatrixBase &matrix) const { return DiagonalProduct(matrix.derived(), derived()); } + EIGEN_DEVICE_FUNC inline const DiagonalWrapper, const DiagonalVectorType> > inverse() const { return diagonal().cwiseInverse(); } + EIGEN_DEVICE_FUNC inline const DiagonalWrapper, const DiagonalVectorType> > operator*(const Scalar& scalar) const { return diagonal() * scalar; } + EIGEN_DEVICE_FUNC friend inline const DiagonalWrapper, const DiagonalVectorType> > operator*(const Scalar& scalar, const DiagonalBase& other) { @@ -84,11 +98,13 @@ class DiagonalBase : public EigenBase #ifdef EIGEN2_SUPPORT template + EIGEN_DEVICE_FUNC bool isApprox(const DiagonalBase& other, typename NumTraits::Real precision = NumTraits::dummy_precision()) const { return diagonal().isApprox(other.diagonal(), precision); } template + EIGEN_DEVICE_FUNC bool isApprox(const MatrixBase& other, typename NumTraits::Real precision = NumTraits::dummy_precision()) const { return toDenseMatrix().isApprox(other, precision); @@ -151,24 +167,31 @@ class DiagonalMatrix public: /** const version of diagonal(). */ + EIGEN_DEVICE_FUNC inline const DiagonalVectorType& diagonal() const { return m_diagonal; } /** \returns a reference to the stored vector of diagonal coefficients. */ + EIGEN_DEVICE_FUNC inline DiagonalVectorType& diagonal() { return m_diagonal; } /** Default constructor without initialization */ + EIGEN_DEVICE_FUNC inline DiagonalMatrix() {} /** Constructs a diagonal matrix with given dimension */ + EIGEN_DEVICE_FUNC inline DiagonalMatrix(Index dim) : m_diagonal(dim) {} /** 2D constructor. */ + EIGEN_DEVICE_FUNC inline DiagonalMatrix(const Scalar& x, const Scalar& y) : m_diagonal(x,y) {} /** 3D constructor. */ + EIGEN_DEVICE_FUNC inline DiagonalMatrix(const Scalar& x, const Scalar& y, const Scalar& z) : m_diagonal(x,y,z) {} /** Copy constructor. */ template + EIGEN_DEVICE_FUNC inline DiagonalMatrix(const DiagonalBase& other) : m_diagonal(other.diagonal()) {} #ifndef EIGEN_PARSED_BY_DOXYGEN @@ -178,11 +201,13 @@ class DiagonalMatrix /** generic constructor from expression of the diagonal coefficients */ template + EIGEN_DEVICE_FUNC explicit inline DiagonalMatrix(const MatrixBase& other) : m_diagonal(other) {} /** Copy operator. */ template + EIGEN_DEVICE_FUNC DiagonalMatrix& operator=(const DiagonalBase& other) { m_diagonal = other.diagonal(); @@ -193,6 +218,7 @@ class DiagonalMatrix /** This is a special case of the templated operator=. Its purpose is to * prevent a default operator= from hiding the templated operator=. */ + EIGEN_DEVICE_FUNC DiagonalMatrix& operator=(const DiagonalMatrix& other) { m_diagonal = other.diagonal(); @@ -201,14 +227,19 @@ class DiagonalMatrix #endif /** Resizes to given size. */ + EIGEN_DEVICE_FUNC inline void resize(Index size) { m_diagonal.resize(size); } /** Sets all coefficients to zero. */ + EIGEN_DEVICE_FUNC inline void setZero() { m_diagonal.setZero(); } /** Resizes and sets all coefficients to zero. */ + EIGEN_DEVICE_FUNC inline void setZero(Index size) { m_diagonal.setZero(size); } /** Sets this matrix to be the identity matrix of the current size. */ + EIGEN_DEVICE_FUNC inline void setIdentity() { m_diagonal.setOnes(); } /** Sets this matrix to be the identity matrix of the given size. */ + EIGEN_DEVICE_FUNC inline void setIdentity(Index size) { m_diagonal.setOnes(size); } }; @@ -255,9 +286,11 @@ class DiagonalWrapper #endif /** Constructor from expression of diagonal coefficients to wrap. */ + EIGEN_DEVICE_FUNC inline DiagonalWrapper(DiagonalVectorType& a_diagonal) : m_diagonal(a_diagonal) {} /** \returns a const reference to the wrapped expression of diagonal coefficients. */ + EIGEN_DEVICE_FUNC const DiagonalVectorType& diagonal() const { return m_diagonal; } protected: diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index eed10de2d..8b8a868b7 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -98,6 +98,7 @@ template class MatrixBase /** \returns the size of the main diagonal, which is min(rows(),cols()). * \sa rows(), cols(), SizeAtCompileTime. */ + EIGEN_DEVICE_FUNC inline Index diagonalSize() const { return (std::min)(rows(),cols()); } /** \brief The plain matrix type corresponding to this expression. @@ -206,6 +207,7 @@ template class MatrixBase void applyOnTheRight(const EigenBase& other); template + EIGEN_DEVICE_FUNC const DiagonalProduct operator*(const DiagonalBase &diagonal) const; @@ -231,15 +233,23 @@ template class MatrixBase EIGEN_DEVICE_FUNC void adjointInPlace(); typedef Diagonal DiagonalReturnType; + EIGEN_DEVICE_FUNC DiagonalReturnType diagonal(); - typedef typename internal::add_const >::type ConstDiagonalReturnType; + + typedef typename internal::add_const >::type ConstDiagonalReturnType; + EIGEN_DEVICE_FUNC ConstDiagonalReturnType diagonal() const; template struct DiagonalIndexReturnType { typedef Diagonal Type; }; template struct ConstDiagonalIndexReturnType { typedef const Diagonal Type; }; - template typename DiagonalIndexReturnType::Type diagonal(); - template typename ConstDiagonalIndexReturnType::Type diagonal() const; + template + EIGEN_DEVICE_FUNC + typename DiagonalIndexReturnType::Type diagonal(); + + template + EIGEN_DEVICE_FUNC + typename ConstDiagonalIndexReturnType::Type diagonal() const; // Note: The "MatrixBase::" prefixes are added to help MSVC9 to match these declarations with the later implementations. // On the other hand they confuse MSVC8... @@ -247,7 +257,10 @@ template class MatrixBase typename MatrixBase::template DiagonalIndexReturnType::Type diagonal(Index index); typename MatrixBase::template ConstDiagonalIndexReturnType::Type diagonal(Index index) const; #else + EIGEN_DEVICE_FUNC typename DiagonalIndexReturnType::Type diagonal(Index index); + + EIGEN_DEVICE_FUNC typename ConstDiagonalIndexReturnType::Type diagonal(Index index) const; #endif @@ -285,6 +298,7 @@ template class MatrixBase static const BasisReturnType UnitZ(); static const BasisReturnType UnitW(); + EIGEN_DEVICE_FUNC const DiagonalWrapper asDiagonal() const; const PermutationWrapper asPermutation() const; diff --git a/Eigen/src/plugins/ArrayCwiseBinaryOps.h b/Eigen/src/plugins/ArrayCwiseBinaryOps.h index 5c8c476ee..2a77fd956 100644 --- a/Eigen/src/plugins/ArrayCwiseBinaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseBinaryOps.h @@ -3,6 +3,7 @@ * \sa MatrixBase::cwiseProduct */ template +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived) operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { @@ -14,6 +15,7 @@ operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const * \sa MatrixBase::cwiseQuotient */ template +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { @@ -33,6 +35,7 @@ EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op) * * \sa max() */ +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const CwiseNullaryOp, PlainObject> > #ifdef EIGEN_PARSED_BY_DOXYGEN @@ -58,6 +61,7 @@ EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op) * * \sa min() */ +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const CwiseNullaryOp, PlainObject> > #ifdef EIGEN_PARSED_BY_DOXYGEN @@ -143,12 +147,14 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator!=,std::not_equal_to) * * \sa operator+=(), operator-() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> operator+(const Scalar& scalar) const { return CwiseUnaryOp, const Derived>(derived(), internal::scalar_add_op(scalar)); } +EIGEN_DEVICE_FUNC friend inline const CwiseUnaryOp, const Derived> operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) { @@ -162,12 +168,14 @@ operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& * * \sa operator+(), operator-=() */ +EIGEN_DEVICE_FUNC inline const CwiseUnaryOp, const Derived> operator-(const Scalar& scalar) const { return *this + (-scalar); } +EIGEN_DEVICE_FUNC friend inline const CwiseUnaryOp, const CwiseUnaryOp, const Derived> > operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) { @@ -184,6 +192,7 @@ operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& * \sa operator||(), select() */ template +EIGEN_DEVICE_FUNC inline const CwiseBinaryOp operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { @@ -202,6 +211,7 @@ operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const * \sa operator&&(), select() */ template +EIGEN_DEVICE_FUNC inline const CwiseBinaryOp operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { @@ -209,3 +219,4 @@ operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL); return CwiseBinaryOp(derived(),other.derived()); } + diff --git a/Eigen/src/plugins/ArrayCwiseUnaryOps.h b/Eigen/src/plugins/ArrayCwiseUnaryOps.h index afb0fb6e3..71a7d4185 100644 --- a/Eigen/src/plugins/ArrayCwiseUnaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseUnaryOps.h @@ -201,6 +201,7 @@ cube() const } #define EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(METHOD_NAME,FUNCTOR) \ + EIGEN_DEVICE_FUNC \ inline const CwiseUnaryOp >, const Derived> \ METHOD_NAME(const Scalar& s) const { \ return CwiseUnaryOp >, const Derived> \ -- cgit v1.2.3