From 12439e12490b9fd79fe18aa30ce09648dcb644ba Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 5 Apr 2013 16:35:49 +0200 Subject: Port SelfCwiseBinaryOp and Dot.h to nvcc, fix portability issue with std::min/max --- Eigen/src/Core/SelfCwiseBinaryOp.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'Eigen/src/Core/SelfCwiseBinaryOp.h') diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index 0caf2bab1..40f9eb618 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -52,21 +52,24 @@ template class SelfCwiseBinaryOp typedef typename internal::packet_traits::type Packet; + EIGEN_DEVICE_FUNC inline SelfCwiseBinaryOp(Lhs& xpr, const BinaryOp& func = BinaryOp()) : m_matrix(xpr), m_functor(func) {} - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } - inline Index outerStride() const { return m_matrix.outerStride(); } - inline Index innerStride() const { return m_matrix.innerStride(); } - inline const Scalar* data() const { return m_matrix.data(); } + EIGEN_DEVICE_FUNC inline Index rows() const { return m_matrix.rows(); } + EIGEN_DEVICE_FUNC inline Index cols() const { return m_matrix.cols(); } + EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_matrix.outerStride(); } + EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_matrix.innerStride(); } + EIGEN_DEVICE_FUNC inline const Scalar* data() const { return m_matrix.data(); } // note that this function is needed by assign to correctly align loads/stores // TODO make Assign use .data() + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col) { EIGEN_STATIC_ASSERT_LVALUE(Lhs) return m_matrix.const_cast_derived().coeffRef(row, col); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index row, Index col) const { return m_matrix.coeffRef(row, col); @@ -74,17 +77,20 @@ template class SelfCwiseBinaryOp // note that this function is needed by assign to correctly align loads/stores // TODO make Assign use .data() + EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) { EIGEN_STATIC_ASSERT_LVALUE(Lhs) return m_matrix.const_cast_derived().coeffRef(index); } + EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_matrix.const_cast_derived().coeffRef(index); } template + EIGEN_DEVICE_FUNC void copyCoeff(Index row, Index col, const DenseBase& other) { OtherDerived& _other = other.const_cast_derived(); @@ -95,6 +101,7 @@ template class SelfCwiseBinaryOp } template + EIGEN_DEVICE_FUNC void copyCoeff(Index index, const DenseBase& other) { OtherDerived& _other = other.const_cast_derived(); @@ -125,6 +132,7 @@ template class SelfCwiseBinaryOp // reimplement lazyAssign to handle complex *= real // see CwiseBinaryOp ctor for details template + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE SelfCwiseBinaryOp& lazyAssign(const DenseBase& rhs) { EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs,RhsDerived) @@ -144,17 +152,20 @@ template class SelfCwiseBinaryOp // overloaded to honor evaluation of special matrices // maybe another solution would be to not use SelfCwiseBinaryOp // at first... + EIGEN_DEVICE_FUNC SelfCwiseBinaryOp& operator=(const Rhs& _rhs) { typename internal::nested::type rhs(_rhs); return Base::operator=(rhs); } + EIGEN_DEVICE_FUNC Lhs& expression() const { return m_matrix; } + EIGEN_DEVICE_FUNC const BinaryOp& functor() const { return m_functor; -- cgit v1.2.3