diff --git a/Eigen/src/Core/ArrayWrapper.h b/Eigen/src/Core/ArrayWrapper.h index b45395d7a..b636d88ad 100644 --- a/Eigen/src/Core/ArrayWrapper.h +++ b/Eigen/src/Core/ArrayWrapper.h @@ -65,8 +65,8 @@ class ArrayWrapper : public ArrayBase > { return m_expression.innerStride(); } - EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } - EIGEN_DEVICE_FUNC inline const Scalar* data() const { return m_expression.data(); } + EIGEN_DEVICE_FUNC constexpr ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_expression.data(); } EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const { return m_expression.coeffRef(rowId, colId); @@ -144,8 +144,8 @@ class MatrixWrapper : public MatrixBase > { return m_expression.innerStride(); } - EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } - EIGEN_DEVICE_FUNC inline const Scalar* data() const { return m_expression.data(); } + EIGEN_DEVICE_FUNC constexpr ScalarWithConstIfNotLvalue* data() { return m_expression.data(); } + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_expression.data(); } EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const { return m_expression.derived().coeffRef(rowId, colId); diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 9b16ed289..709264c69 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -278,7 +278,7 @@ class BlockImpl_dense : public internal::dense_xpr_base { m_cols = cols; eigen_assert(m_rows * m_cols == 0 && "The number of rows times columns must equal the storage size."); } - EIGEN_DEVICE_FUNC const T* data() const { return nullptr; } - EIGEN_DEVICE_FUNC T* data() { return nullptr; } + EIGEN_DEVICE_FUNC constexpr const T* data() const { return nullptr; } + EIGEN_DEVICE_FUNC constexpr T* data() { return nullptr; } }; template @@ -288,8 +288,8 @@ class DenseStorage { m_cols = cols; eigen_assert(Rows_ * m_cols == 0 && "The number of rows times columns must equal the storage size."); } - EIGEN_DEVICE_FUNC const T* data() const { return nullptr; } - EIGEN_DEVICE_FUNC T* data() { return nullptr; } + EIGEN_DEVICE_FUNC constexpr const T* data() const { return nullptr; } + EIGEN_DEVICE_FUNC constexpr T* data() { return nullptr; } }; template @@ -318,8 +318,8 @@ class DenseStorage { m_rows = rows; eigen_assert(m_rows * Cols_ == 0 && "The number of rows times columns must equal the storage size."); } - EIGEN_DEVICE_FUNC const T* data() const { return nullptr; } - EIGEN_DEVICE_FUNC T* data() { return nullptr; } + EIGEN_DEVICE_FUNC constexpr const T* data() const { return nullptr; } + EIGEN_DEVICE_FUNC constexpr T* data() { return nullptr; } }; // dynamic-size matrix with fixed-size storage @@ -507,8 +507,8 @@ class DenseStorage { m_rows = rows; m_cols = cols; } - EIGEN_DEVICE_FUNC const T* data() const { return m_data; } - EIGEN_DEVICE_FUNC T* data() { return m_data; } + EIGEN_DEVICE_FUNC constexpr const T* data() const { return m_data; } + EIGEN_DEVICE_FUNC constexpr T* data() { return m_data; } }; // matrix with dynamic width and fixed height (so that matrix has dynamic size). @@ -574,8 +574,8 @@ class DenseStorage { } m_cols = cols; } - EIGEN_DEVICE_FUNC const T* data() const { return m_data; } - EIGEN_DEVICE_FUNC T* data() { return m_data; } + EIGEN_DEVICE_FUNC constexpr const T* data() const { return m_data; } + EIGEN_DEVICE_FUNC constexpr T* data() { return m_data; } }; // matrix with dynamic height and fixed width (so that matrix has dynamic size). @@ -641,8 +641,8 @@ class DenseStorage { } m_rows = rows; } - EIGEN_DEVICE_FUNC const T* data() const { return m_data; } - EIGEN_DEVICE_FUNC T* data() { return m_data; } + EIGEN_DEVICE_FUNC constexpr const T* data() const { return m_data; } + EIGEN_DEVICE_FUNC constexpr T* data() { return m_data; } }; } // end namespace Eigen diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index b7ae44fda..dc1248137 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h @@ -229,7 +229,7 @@ struct gemv_static_vector_if; template struct gemv_static_vector_if { - EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Scalar* data() { + EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr Scalar* data() { eigen_internal_assert(false && "should never be called"); return 0; } @@ -237,19 +237,19 @@ struct gemv_static_vector_if { template struct gemv_static_vector_if { - EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Scalar* data() { return 0; } + EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr Scalar* data() { return 0; } }; template struct gemv_static_vector_if { #if EIGEN_MAX_STATIC_ALIGN_BYTES != 0 internal::plain_array m_data; - EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } + EIGEN_STRONG_INLINE constexpr Scalar* data() { return m_data.array; } #else // Some architectures cannot align on the stack, // => let's manually enforce alignment by allocating more data and return the address of the first aligned element. internal::plain_array m_data; - EIGEN_STRONG_INLINE Scalar* data() { + EIGEN_STRONG_INLINE constexpr Scalar* data() { return reinterpret_cast((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) + EIGEN_MAX_ALIGN_BYTES); } diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index da95b5c40..1e83fdf70 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -94,7 +94,7 @@ class MapBase : public internal::dense_xpr_base : public MapBase::value, Scalar, const Scalar> ScalarWithConstIfNotLvalue; - EIGEN_DEVICE_FUNC inline const Scalar* data() const { return this->m_data; } - EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return this->m_data; } + EIGEN_DEVICE_FUNC constexpr ScalarWithConstIfNotLvalue* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index df90318bf..62195f4e3 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -270,10 +270,10 @@ class PlainObjectBase : public internal::dense_xpr_base::type } /** \returns a const pointer to the data array of this matrix */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar* data() const { return m_storage.data(); } + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_storage.data(); } /** \returns a pointer to the data array of this matrix */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar* data() { return m_storage.data(); } + EIGEN_DEVICE_FUNC constexpr Scalar* data() { return m_storage.data(); } /** Resizes \c *this to a \a rows x \a cols matrix. * diff --git a/Eigen/src/Core/Reshaped.h b/Eigen/src/Core/Reshaped.h index b881dd6cd..4b34e16f6 100644 --- a/Eigen/src/Core/Reshaped.h +++ b/Eigen/src/Core/Reshaped.h @@ -173,7 +173,7 @@ class ReshapedImpl_dense #ifdef EIGEN_PARSED_BY_DOXYGEN /** \sa MapBase::data() */ - EIGEN_DEVICE_FUNC inline const Scalar* data() const; + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const; EIGEN_DEVICE_FUNC inline Index innerStride() const; EIGEN_DEVICE_FUNC inline Index outerStride() const; #endif diff --git a/Eigen/src/Core/Stride.h b/Eigen/src/Core/Stride.h index a8fdeaf37..14b025c46 100644 --- a/Eigen/src/Core/Stride.h +++ b/Eigen/src/Core/Stride.h @@ -70,6 +70,13 @@ class Stride { /** Copy constructor */ EIGEN_DEVICE_FUNC Stride(const Stride& other) : m_outer(other.outer()), m_inner(other.inner()) {} + /** Copy assignment operator */ + EIGEN_DEVICE_FUNC Stride& operator=(const Stride& other) { + m_outer.setValue(other.outer()); + m_inner.setValue(other.inner()); + return *this; + } + /** \returns the outer stride */ EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index outer() const { return m_outer.value(); } /** \returns the inner stride */ diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 1cc7a2867..89e3d95fd 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -119,10 +119,12 @@ class TransposeImpl : public internal::TransposeImpl_base::value, Scalar, const Scalar> ScalarWithConstIfNotLvalue; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarWithConstIfNotLvalue* data() { + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr ScalarWithConstIfNotLvalue* data() { + return derived().nestedExpression().data(); + } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar* data() const { return derived().nestedExpression().data(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar* data() const { return derived().nestedExpression().data(); } // FIXME: shall we keep the const version of coeffRef? EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& coeffRef(Index rowId, Index colId) const { diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index c2994b204..19d9917d7 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -241,7 +241,7 @@ class blas_data_mapper { EIGEN_DEVICE_FUNC const Index stride() const { return m_stride; } EIGEN_DEVICE_FUNC const Index incr() const { return 1; } - EIGEN_DEVICE_FUNC const Scalar* data() const { return m_data; } + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_data; } EIGEN_DEVICE_FUNC Index firstAligned(Index size) const { if (std::uintptr_t(m_data) % sizeof(Scalar)) { @@ -430,7 +430,7 @@ class blas_data_mapper { EIGEN_DEVICE_FUNC const Index stride() const { return m_stride; } EIGEN_DEVICE_FUNC const Index incr() const { return m_incr.value(); } - EIGEN_DEVICE_FUNC Scalar* data() const { return m_data; } + EIGEN_DEVICE_FUNC constexpr Scalar* data() const { return m_data; } protected: Scalar* EIGEN_RESTRICT m_data; diff --git a/Eigen/src/Core/util/MaxSizeVector.h b/Eigen/src/Core/util/MaxSizeVector.h index 2f1e3d35e..54b556dd0 100644 --- a/Eigen/src/Core/util/MaxSizeVector.h +++ b/Eigen/src/Core/util/MaxSizeVector.h @@ -116,17 +116,17 @@ class MaxSizeVector { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool empty() const { return size_ == 0; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* data() { return data_; } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr T* data() { return data_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T* data() const { return data_; } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const T* data() const { return data_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* begin() { return data_; } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr T* begin() { return data_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* end() { return data_ + size_; } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr T* end() { return data_ + size_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T* begin() const { return data_; } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const T* begin() const { return data_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T* end() const { return data_ + size_; } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const T* end() const { return data_ + size_; } private: size_t reserve_; diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index fd3fc58f4..b1a9f21fa 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -588,9 +588,9 @@ class Transform { EIGEN_DEVICE_FUNC inline Transform inverse(TransformTraits traits = (TransformTraits)Mode) const; /** \returns a const pointer to the column major internal matrix */ - EIGEN_DEVICE_FUNC const Scalar* data() const { return m_matrix.data(); } + EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_matrix.data(); } /** \returns a non-const pointer to the column major internal matrix */ - EIGEN_DEVICE_FUNC Scalar* data() { return m_matrix.data(); } + EIGEN_DEVICE_FUNC constexpr Scalar* data() { return m_matrix.data(); } /** \returns \c *this with scalar type casted to \a NewScalarType * diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h index 24ebb7cac..16ee8da16 100644 --- a/Eigen/src/SparseCore/SparseMatrix.h +++ b/Eigen/src/SparseCore/SparseMatrix.h @@ -202,9 +202,9 @@ class SparseMatrix : public SparseCompressedBase= 0 && row < m_size) : (row == 0 && col >= 0 && col < m_size));