From 61895c59787ebaca6011fa58781c8f2285525b31 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen <4643818-rmlarsen1@users.noreply.gitlab.com> Date: Tue, 24 Feb 2026 19:59:10 -0800 Subject: [PATCH] Selectively add constexpr to Core expression template scaffolding libeigen/eigen!2184 Closes #3041 Co-authored-by: Rasmus Munk Larsen --- Eigen/src/Core/Array.h | 2 +- Eigen/src/Core/ArrayBase.h | 8 +- Eigen/src/Core/ArrayWrapper.h | 9 +- Eigen/src/Core/Assign.h | 18 +- Eigen/src/Core/AssignEvaluator.h | 6 +- Eigen/src/Core/Block.h | 28 +-- Eigen/src/Core/CommaInitializer.h | 2 +- Eigen/src/Core/CoreEvaluators.h | 191 ++++++++++--------- Eigen/src/Core/CwiseBinaryOp.h | 10 +- Eigen/src/Core/CwiseNullaryOp.h | 6 +- Eigen/src/Core/CwiseTernaryOp.h | 12 +- Eigen/src/Core/CwiseUnaryOp.h | 12 +- Eigen/src/Core/CwiseUnaryView.h | 10 +- Eigen/src/Core/DenseBase.h | 64 +++---- Eigen/src/Core/DenseCoeffsBase.h | 6 +- Eigen/src/Core/Diagonal.h | 22 ++- Eigen/src/Core/DiagonalMatrix.h | 42 ++-- Eigen/src/Core/Dot.h | 10 +- Eigen/src/Core/EigenBase.h | 18 +- Eigen/src/Core/ForceAlignedAccess.h | 2 +- Eigen/src/Core/Fuzzy.h | 12 +- Eigen/src/Core/GlobalFunctions.h | 8 +- Eigen/src/Core/IndexedView.h | 13 +- Eigen/src/Core/Inverse.h | 4 +- Eigen/src/Core/Map.h | 9 +- Eigen/src/Core/MapBase.h | 24 +-- Eigen/src/Core/MathFunctions.h | 14 +- Eigen/src/Core/MathFunctionsImpl.h | 9 +- Eigen/src/Core/Matrix.h | 12 +- Eigen/src/Core/MatrixBase.h | 68 +++---- Eigen/src/Core/NestByValue.h | 22 ++- Eigen/src/Core/NoAlias.h | 4 +- Eigen/src/Core/PlainObjectBase.h | 42 ++-- Eigen/src/Core/Product.h | 6 +- Eigen/src/Core/ProductEvaluators.h | 28 +-- Eigen/src/Core/Redux.h | 12 +- Eigen/src/Core/Ref.h | 17 +- Eigen/src/Core/Replicate.h | 6 +- Eigen/src/Core/Reshaped.h | 49 ++--- Eigen/src/Core/Reverse.h | 4 +- Eigen/src/Core/Select.h | 6 +- Eigen/src/Core/SelfAdjointView.h | 4 +- Eigen/src/Core/SelfCwiseBinaryOp.h | 8 +- Eigen/src/Core/SkewSymmetricMatrix3.h | 2 +- Eigen/src/Core/Solve.h | 4 +- Eigen/src/Core/Stride.h | 17 +- Eigen/src/Core/Swap.h | 7 +- Eigen/src/Core/Transpose.h | 17 +- Eigen/src/Core/TriangularMatrix.h | 4 +- Eigen/src/Core/VectorBlock.h | 4 +- Eigen/src/Core/functors/AssignmentFunctors.h | 2 +- Eigen/src/Core/functors/BinaryFunctors.h | 79 ++++---- Eigen/src/Core/functors/NullaryFunctors.h | 24 +-- Eigen/src/Core/functors/TernaryFunctors.h | 4 +- Eigen/src/Core/functors/UnaryFunctors.h | 150 ++++++++------- Eigen/src/Core/util/BlasUtil.h | 66 ++++--- Eigen/src/Core/util/Constants.h | 38 ++-- Eigen/src/Core/util/IntegralConstant.h | 6 +- Eigen/src/Core/util/Macros.h | 10 +- Eigen/src/Core/util/Meta.h | 30 +-- Eigen/src/Core/util/XprHelper.h | 16 +- Eigen/src/plugins/ArrayCwiseBinaryOps.inc | 26 +-- Eigen/src/plugins/ArrayCwiseUnaryOps.inc | 104 +++++----- Eigen/src/plugins/BlockMethods.inc | 178 +++++++++-------- Eigen/src/plugins/CommonCwiseBinaryOps.inc | 20 +- Eigen/src/plugins/CommonCwiseUnaryOps.inc | 22 +-- Eigen/src/plugins/MatrixCwiseBinaryOps.inc | 68 +++---- Eigen/src/plugins/MatrixCwiseUnaryOps.inc | 31 ++- Eigen/src/plugins/ReshapedMethods.inc | 18 +- test/constexpr.cpp | 21 ++ 70 files changed, 986 insertions(+), 841 deletions(-) diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h index 8f4f3453e..b6b4637a2 100644 --- a/Eigen/src/Core/Array.h +++ b/Eigen/src/Core/Array.h @@ -245,7 +245,7 @@ class Array : public PlainObjectBase&) */ template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Array( const EigenBase& other, std::enable_if_t::value, PrivateType> = PrivateType()) diff --git a/Eigen/src/Core/ArrayBase.h b/Eigen/src/Core/ArrayBase.h index 675b0bb51..dacc23933 100644 --- a/Eigen/src/Core/ArrayBase.h +++ b/Eigen/src/Core/ArrayBase.h @@ -168,13 +168,13 @@ class ArrayBase : public DenseBase { } public: - EIGEN_DEVICE_FUNC ArrayBase& array() { return *this; } - EIGEN_DEVICE_FUNC const ArrayBase& array() const { return *this; } + EIGEN_DEVICE_FUNC constexpr ArrayBase& array() { return *this; } + EIGEN_DEVICE_FUNC constexpr 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 MatrixWrapper(derived()); } - EIGEN_DEVICE_FUNC const MatrixWrapper matrix() const { + EIGEN_DEVICE_FUNC constexpr MatrixWrapper matrix() { return MatrixWrapper(derived()); } + EIGEN_DEVICE_FUNC constexpr const MatrixWrapper matrix() const { return MatrixWrapper(derived()); } diff --git a/Eigen/src/Core/ArrayWrapper.h b/Eigen/src/Core/ArrayWrapper.h index a0a6483c9..fb05ab55d 100644 --- a/Eigen/src/Core/ArrayWrapper.h +++ b/Eigen/src/Core/ArrayWrapper.h @@ -54,7 +54,8 @@ class ArrayWrapper : public ArrayBase > { using Base::coeffRef; - EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {} + EIGEN_DEVICE_FUNC constexpr explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix) + : m_expression(matrix) {} EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); } @@ -75,7 +76,7 @@ class ArrayWrapper : public ArrayBase > { dst = m_expression; } - EIGEN_DEVICE_FUNC const internal::remove_all_t& nestedExpression() const { + EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t& nestedExpression() const { return m_expression; } @@ -129,7 +130,7 @@ class MatrixWrapper : public MatrixBase > { using Base::coeffRef; - EIGEN_DEVICE_FUNC explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {} + EIGEN_DEVICE_FUNC constexpr explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {} EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); } @@ -145,7 +146,7 @@ class MatrixWrapper : public MatrixBase > { EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_expression.coeffRef(index); } - EIGEN_DEVICE_FUNC const internal::remove_all_t& nestedExpression() const { + EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t& nestedExpression() const { return m_expression; } diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 4b30f7bb6..3d30d868c 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -19,7 +19,8 @@ namespace Eigen { template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::lazyAssign(const DenseBase& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::lazyAssign( + const DenseBase& other) { enum { SameType = internal::is_same::value }; EIGEN_STATIC_ASSERT_LVALUE(Derived) @@ -36,40 +37,43 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::lazyAssign(co template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::operator=( + const DenseBase& other) { internal::call_assignment(derived(), other.derived()); return derived(); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) { internal::call_assignment(derived(), other.derived()); return derived(); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const MatrixBase& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const MatrixBase& other) { internal::call_assignment(derived(), other.derived()); return derived(); } template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const DenseBase& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase::operator=( + const DenseBase& other) { internal::call_assignment(derived(), other.derived()); return derived(); } template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase::operator=( + const EigenBase& other) { internal::call_assignment(derived(), other.derived()); return derived(); } template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase::operator=( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase::operator=( const ReturnByValue& other) { other.derived().evalTo(derived()); return derived(); diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index 061ac6c2c..3afdd3e62 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -681,8 +681,8 @@ class generic_dense_assignment_kernel { EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_dstExpr.cols(); } EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return m_dstExpr.outerStride(); } - EIGEN_DEVICE_FUNC DstEvaluatorType& dstEvaluator() noexcept { return m_dst; } - EIGEN_DEVICE_FUNC const SrcEvaluatorType& srcEvaluator() const noexcept { return m_src; } + EIGEN_DEVICE_FUNC constexpr DstEvaluatorType& dstEvaluator() noexcept { return m_dst; } + EIGEN_DEVICE_FUNC constexpr const SrcEvaluatorType& srcEvaluator() const noexcept { return m_src; } /// Assign src(row,col) to dst(row,col) through the assignment functor. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void assignCoeff(Index row, Index col) { @@ -690,7 +690,7 @@ class generic_dense_assignment_kernel { } /// \sa assignCoeff(Index,Index) - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(Index index) { + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void assignCoeff(Index index) { m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index)); } diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index ddec4a7b0..c2d8beab9 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -121,14 +121,14 @@ class Block /** Column or Row constructor */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Block(XprType& xpr, Index i) : Impl(xpr, i) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Block(XprType& xpr, Index i) : Impl(xpr, i) { eigen_assert((i >= 0) && (((BlockRows == 1) && (BlockCols == XprType::ColsAtCompileTime) && i < xpr.rows()) || ((BlockRows == XprType::RowsAtCompileTime) && (BlockCols == 1) && i < xpr.cols()))); } /** Fixed-size constructor */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Block(XprType& xpr, Index startRow, Index startCol) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Block(XprType& xpr, Index startRow, Index startCol) : Impl(xpr, startRow, startCol) { EIGEN_STATIC_ASSERT(RowsAtCompileTime != Dynamic && ColsAtCompileTime != Dynamic, THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) @@ -138,8 +138,8 @@ class Block /** Dynamic-size constructor */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Block(XprType& xpr, Index startRow, Index startCol, Index blockRows, - Index blockCols) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Block(XprType& xpr, Index startRow, Index startCol, Index blockRows, + Index blockCols) : Impl(xpr, startRow, startCol, blockRows, blockCols) { eigen_assert((RowsAtCompileTime == Dynamic || RowsAtCompileTime == blockRows) && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == blockCols)); @@ -175,11 +175,11 @@ class BlockImpl public: typedef Impl Base; EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl) - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index i) : Impl(xpr, i) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index i) : Impl(xpr, i) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol) : Impl(xpr, startRow, startCol) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol, Index blockRows, - Index blockCols) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol, + Index blockRows, Index blockCols) : Impl(xpr, startRow, startCol, blockRows, blockCols) {} }; @@ -198,7 +198,7 @@ class BlockImpl_dense : public internal::dense_xpr_base struct CommaInitializer { typedef typename XprType::Scalar Scalar; - EIGEN_DEVICE_FUNC inline CommaInitializer(XprType& xpr, const Scalar& s) + EIGEN_DEVICE_FUNC constexpr CommaInitializer(XprType& xpr, const Scalar& s) : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) { eigen_assert(m_xpr.rows() > 0 && m_xpr.cols() > 0 && "Cannot comma-initialize a 0x0 matrix (operator<<)"); m_xpr.coeffRef(0, 0) = s; diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index d2649d246..9df0c9641 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -103,13 +103,13 @@ struct evaluator_assume_aliasing { template struct evaluator : public unary_evaluator { typedef unary_evaluator Base; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : Base(xpr) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : Base(xpr) {} }; // TODO: Think about const-correctness template struct evaluator : evaluator { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : evaluator(xpr) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : evaluator(xpr) {} }; // ---------- base class for all evaluators ---------- @@ -293,20 +293,25 @@ struct unary_evaluator, IndexBased> : evaluator_base::Alignment }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& t) : m_argImpl(t.nestedExpression()) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& t) + : m_argImpl(t.nestedExpression()) {} typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_argImpl.coeff(col, row); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_argImpl.coeff(index); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + return m_argImpl.coeff(index); + } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_argImpl.coeffRef(col, row); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { + return m_argImpl.coeffRef(col, row); + } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename XprType::Scalar& coeffRef(Index index) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename XprType::Scalar& coeffRef(Index index) { return m_argImpl.coeffRef(index); } @@ -365,11 +370,12 @@ template ::value> struct nullary_wrapper { template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, + IndexType j) const { return op(i, j); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return op(i); } @@ -386,7 +392,8 @@ struct nullary_wrapper { template struct nullary_wrapper { template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType = 0, IndexType = 0) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType = 0, + IndexType = 0) const { return op(); } template @@ -398,7 +405,8 @@ struct nullary_wrapper { template struct nullary_wrapper { template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j = 0) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, + IndexType j = 0) const { return op(i, j); } template @@ -413,7 +421,8 @@ struct nullary_wrapper { template struct nullary_wrapper { template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, + IndexType j) const { eigen_assert(i == 0 || j == 0); return op(i + j); } @@ -424,7 +433,7 @@ struct nullary_wrapper { } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return op(i); } template @@ -452,19 +461,19 @@ struct evaluator> Alignment = AlignedMax }; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& n) : m_functor(n.functor()), m_wrapper() { + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& n) : m_functor(n.functor()), m_wrapper() { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } typedef typename XprType::CoeffReturnType CoeffReturnType; template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType row, IndexType col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType row, IndexType col) const { return m_wrapper(m_functor, row, col); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType index) const { return m_wrapper(m_functor, index); } @@ -509,18 +518,18 @@ struct unary_evaluator, IndexBased> : evaluator_b Alignment = evaluator::Alignment }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& op) : m_d(op) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& op) : m_d(op) { EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits::Cost); EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } typedef typename XprType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.argImpl.coeff(row, col)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_d.func()(m_d.argImpl.coeff(index)); } @@ -547,9 +556,9 @@ struct unary_evaluator, IndexBased> : evaluator_b protected: // this helper permits to completely eliminate the functor if it is empty struct Data { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Data(const XprType& xpr) : op(xpr.functor()), argImpl(xpr.nestedExpression()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& func() const { return op; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const UnaryOp& func() const { return op; } UnaryOp op; evaluator argImpl; }; @@ -578,7 +587,7 @@ struct unary_evaluator, ArgType>, In Alignment = evaluator::Alignment }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& xpr) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_rows(xpr.rows()), m_cols(xpr.cols()) { EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits::Cost); EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); @@ -610,15 +619,15 @@ struct unary_evaluator, ArgType>, In Index actualCol = IsRowMajor ? col + offset : col; return m_argImpl.coeff(actualRow, actualCol); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE SrcType srcCoeff(Index index, Index offset) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE SrcType srcCoeff(Index index, Index offset) const { Index actualIndex = index + offset; return m_argImpl.coeff(actualIndex); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE DstType coeff(Index row, Index col) const { return cast(srcCoeff(row, col, 0)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE DstType coeff(Index index) const { return cast(srcCoeff(index, 0)); } @@ -900,7 +909,7 @@ struct evaluator> typedef CwiseTernaryOp XprType; typedef ternary_evaluator> Base; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {} + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : Base(xpr) {} }; template @@ -929,18 +938,18 @@ struct ternary_evaluator, IndexBased evaluator::Alignment) }; - EIGEN_DEVICE_FUNC explicit ternary_evaluator(const XprType& xpr) : m_d(xpr) { + EIGEN_DEVICE_FUNC constexpr explicit ternary_evaluator(const XprType& xpr) : m_d(xpr) { EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits::Cost); EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } typedef typename XprType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.arg1Impl.coeff(row, col), m_d.arg2Impl.coeff(row, col), m_d.arg3Impl.coeff(row, col)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_d.func()(m_d.arg1Impl.coeff(index), m_d.arg2Impl.coeff(index), m_d.arg3Impl.coeff(index)); } @@ -975,9 +984,9 @@ struct ternary_evaluator, IndexBased protected: // this helper permits to completely eliminate the functor if it is empty struct Data { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Data(const XprType& xpr) : op(xpr.functor()), arg1Impl(xpr.arg1()), arg2Impl(xpr.arg2()), arg3Impl(xpr.arg3()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TernaryOp& func() const { return op; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const TernaryOp& func() const { return op; } TernaryOp op; evaluator arg1Impl; evaluator arg2Impl; @@ -1015,7 +1024,7 @@ struct evaluator, using Arg3 = typename Helper::Arg3; using XprType = typename Helper::XprType; - EIGEN_DEVICE_FUNC explicit evaluator(const DummyXprType& xpr) + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const DummyXprType& xpr) : Base(XprType(xpr.arg1(), xpr.arg2(), Arg3(xpr.arg3().lhs(), xpr.arg3().rhs()))) {} }; @@ -1027,7 +1036,7 @@ struct evaluator> : public binary_evaluator XprType; typedef binary_evaluator> Base; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {} }; template @@ -1052,18 +1061,18 @@ struct binary_evaluator, IndexBased, IndexBase Alignment = plain_enum_min(evaluator::Alignment, evaluator::Alignment) }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit binary_evaluator(const XprType& xpr) : m_d(xpr) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit binary_evaluator(const XprType& xpr) : m_d(xpr) { EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits::Cost); EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } typedef typename XprType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.lhsImpl.coeff(row, col), m_d.rhsImpl.coeff(row, col)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_d.func()(m_d.lhsImpl.coeff(index), m_d.rhsImpl.coeff(index)); } @@ -1094,9 +1103,9 @@ struct binary_evaluator, IndexBased, IndexBase protected: // this helper permits to completely eliminate the functor if it is empty struct Data { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Data(const XprType& xpr) : op(xpr.functor()), lhsImpl(xpr.lhs()), rhsImpl(xpr.rhs()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const BinaryOp& func() const { return op; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const BinaryOp& func() const { return op; } BinaryOp op; evaluator lhsImpl; evaluator rhsImpl; @@ -1120,7 +1129,7 @@ struct unary_evaluator, IndexBased> Alignment = 0 // FIXME: clarify why alignment is lost for CwiseUnaryView. }; - EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& op) : m_d(op) { + EIGEN_DEVICE_FUNC constexpr explicit unary_evaluator(const XprType& op) : m_d(op) { EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits::Cost); EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } @@ -1128,28 +1137,28 @@ struct unary_evaluator, IndexBased> typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.argImpl.coeff(row, col)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_d.func()(m_d.argImpl.coeff(index)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_d.func()(m_d.argImpl.coeffRef(row, col)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return m_d.func()(m_d.argImpl.coeffRef(index)); } protected: // this helper permits to completely eliminate the functor if it is empty struct Data { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Data(const XprType& xpr) : op(xpr.functor()), argImpl(xpr.nestedExpression()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& func() const { return op; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const UnaryOp& func() const { return op; } UnaryOp op; evaluator argImpl; }; @@ -1177,7 +1186,7 @@ struct mapbase_evaluator : evaluator_base { CoeffReadCost = NumTraits::ReadCost }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit mapbase_evaluator(const XprType& map) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit mapbase_evaluator(const XprType& map) : m_data(const_cast(map.data())), m_innerStride(map.innerStride()), m_outerStride(map.outerStride()) { @@ -1187,19 +1196,21 @@ struct mapbase_evaluator : evaluator_base { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_data[col * colStride() + row * rowStride()]; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_data[index * m_innerStride.value()]; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_data[col * colStride() + row * rowStride()]; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return m_data[index * m_innerStride.value()]; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { + return m_data[index * m_innerStride.value()]; + } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const { @@ -1288,7 +1299,8 @@ struct evaluator> Alignment = int(MapOptions) & int(AlignedMask) }; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& map) : mapbase_evaluator(map) {} + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& map) + : mapbase_evaluator(map) {} }; // -------------------- Ref -------------------- @@ -1303,7 +1315,7 @@ struct evaluator> Alignment = evaluator>::Alignment }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& ref) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& ref) : mapbase_evaluator(ref) {} }; @@ -1357,7 +1369,8 @@ struct evaluator> Alignment = plain_enum_min(evaluator::Alignment, Alignment0) }; typedef block_evaluator block_evaluator_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& block) : block_evaluator_type(block) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& block) + : block_evaluator_type(block) { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } }; @@ -1368,7 +1381,7 @@ struct block_evaluator> { typedef Block XprType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) : unary_evaluator(block) {} }; @@ -1377,7 +1390,7 @@ struct unary_evaluator, IndexBa : evaluator_base> { typedef Block XprType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block) : m_argImpl(block.nestedExpression()), m_startRow(block.startRow()), m_startCol(block.startCol()), @@ -1396,19 +1409,19 @@ struct unary_evaluator, IndexBa bool(evaluator::Flags & LinearAccessBit) }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return linear_coeff_impl(index, bool_constant()); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return linear_coeffRef_impl(index, bool_constant()); } @@ -1473,20 +1486,20 @@ struct unary_evaluator, IndexBa } protected: - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType linear_coeff_impl(Index index, internal::true_type /* ForwardLinearAccess */) const { return m_argImpl.coeff(m_linear_offset.value() + index); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType linear_coeff_impl(Index index, internal::false_type /* not ForwardLinearAccess */) const { return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl(Index index, - internal::true_type /* ForwardLinearAccess */) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl( + Index index, internal::true_type /* ForwardLinearAccess */) { return m_argImpl.coeffRef(m_linear_offset.value() + index); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl( Index index, internal::false_type /* not ForwardLinearAccess */) { return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0); } @@ -1507,7 +1520,7 @@ struct block_evaluator XprType; typedef typename XprType::Scalar Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) : mapbase_evaluator(block) { eigen_internal_assert((internal::is_constant_evaluated() || (std::uintptr_t(block.data()) % plain_enum_max(1, evaluator::Alignment)) == 0) && @@ -1535,13 +1548,13 @@ struct unary_evaluator> Alignment = evaluator::Alignment }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& replicate) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& replicate) : m_arg(replicate.nestedExpression()), m_argImpl(m_arg), m_rows(replicate.nestedExpression().rows()), m_cols(replicate.nestedExpression().cols()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { // try to avoid using modulo; this is a pure optimization strategy const Index actual_row = traits::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value(); const Index actual_col = traits::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value(); @@ -1549,7 +1562,7 @@ struct unary_evaluator> return m_argImpl.coeff(actual_row, actual_col); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { // try to avoid using modulo; this is a pure optimization strategy const Index actual_index = traits::RowsAtCompileTime == 1 ? (ColFactor == 1 ? index : index % m_cols.value()) @@ -1618,15 +1631,19 @@ struct evaluator_wrapper_base : evaluator_base { typedef typename ArgType::Scalar Scalar; typedef typename ArgType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_argImpl.coeff(row, col); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_argImpl.coeff(index); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { + return m_argImpl.coeff(index); + } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_argImpl.coeffRef(row, col); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { + return m_argImpl.coeffRef(row, col); + } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return m_argImpl.coeffRef(index); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return m_argImpl.coeffRef(index); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const { @@ -1678,7 +1695,7 @@ template struct unary_evaluator> : evaluator_wrapper_base> { typedef MatrixWrapper XprType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) : evaluator_wrapper_base>(wrapper.nestedExpression()) {} }; @@ -1686,7 +1703,7 @@ template struct unary_evaluator> : evaluator_wrapper_base> { typedef ArrayWrapper XprType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) : evaluator_wrapper_base>(wrapper.nestedExpression()) {} }; @@ -1726,24 +1743,24 @@ struct unary_evaluator> : evaluator_base> : evaluator_base> : public evaluator Base; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : m_result(xpr.arg()) { + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : m_result(xpr.arg()) { internal::construct_at(this, m_result); } // This constructor is used when nesting an EvalTo evaluator in another evaluator - EIGEN_DEVICE_FUNC evaluator(const ArgType& arg) : m_result(arg) { internal::construct_at(this, m_result); } + EIGEN_DEVICE_FUNC constexpr evaluator(const ArgType& arg) : m_result(arg) { + internal::construct_at(this, m_result); + } protected: PlainObject m_result; diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index f225b6fff..27fd4340f 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -102,8 +102,8 @@ class CwiseBinaryOp : public CwiseBinaryOpImpl&) = default; #endif - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, - const BinaryOp& func = BinaryOp()) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, + const BinaryOp& func = BinaryOp()) : m_lhs(aLhs), m_rhs(aRhs), m_functor(func) { eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()); } @@ -120,11 +120,11 @@ class CwiseBinaryOp : public CwiseBinaryOpImpl::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp) - EIGEN_DEVICE_FUNC CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp()) + EIGEN_DEVICE_FUNC constexpr CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp()) : m_rows(rows), m_cols(cols), m_functor(func) { eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); } - EIGEN_DEVICE_FUNC CwiseNullaryOp(Index size, const NullaryOp& func = NullaryOp()) + EIGEN_DEVICE_FUNC constexpr CwiseNullaryOp(Index size, const NullaryOp& func = NullaryOp()) : CwiseNullaryOp(RowsAtCompileTime == 1 ? 1 : size, RowsAtCompileTime == 1 ? size : 1, func) { EIGEN_STATIC_ASSERT(CwiseNullaryOp::IsVectorAtCompileTime, YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX); } @@ -80,7 +80,7 @@ class CwiseNullaryOp : public internal::dense_xpr_base m_rows; diff --git a/Eigen/src/Core/CwiseTernaryOp.h b/Eigen/src/Core/CwiseTernaryOp.h index 9bb0d4075..87377917d 100644 --- a/Eigen/src/Core/CwiseTernaryOp.h +++ b/Eigen/src/Core/CwiseTernaryOp.h @@ -118,7 +118,7 @@ class CwiseTernaryOp : public CwiseTernaryOpImpl>::RowsAtCompileTime == Dynamic && @@ -130,7 +130,7 @@ class CwiseTernaryOp : public CwiseTernaryOpImpl>::ColsAtCompileTime == Dynamic && @@ -144,13 +144,13 @@ class CwiseTernaryOp : public CwiseTernaryOpImpl::type XprTypeNested; typedef internal::remove_all_t NestedExpression; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp()) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit CwiseUnaryOp(const XprType& xpr, + const UnaryOp& func = UnaryOp()) : m_xpr(xpr), m_functor(func) {} EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_xpr.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_xpr.cols(); } /** \returns the functor representing the unary operation */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& functor() const { return m_functor; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const UnaryOp& functor() const { return m_functor; } /** \returns the nested expression */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all_t& nestedExpression() const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const internal::remove_all_t& nestedExpression() + const { return m_xpr; } /** \returns the nested expression */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_all_t& nestedExpression() { return m_xpr; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE internal::remove_all_t& nestedExpression() { + return m_xpr; + } protected: XprTypeNested m_xpr; diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h index 4e7af39eb..34546e822 100644 --- a/Eigen/src/Core/CwiseUnaryView.h +++ b/Eigen/src/Core/CwiseUnaryView.h @@ -140,7 +140,7 @@ class CwiseUnaryView : public internal::CwiseUnaryViewImpl::non_const_type MatrixTypeNested; typedef internal::remove_all_t NestedExpression; - explicit EIGEN_DEVICE_FUNC inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp()) + explicit EIGEN_DEVICE_FUNC constexpr inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp()) : m_matrix(mat), m_functor(func) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView) @@ -149,13 +149,15 @@ class CwiseUnaryView : public internal::CwiseUnaryViewImpl& nestedExpression() const { return m_matrix; } + EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t& nestedExpression() const { + return m_matrix; + } /** \returns the nested expression */ - EIGEN_DEVICE_FUNC std::remove_reference_t& nestedExpression() { return m_matrix; } + EIGEN_DEVICE_FUNC constexpr std::remove_reference_t& nestedExpression() { return m_matrix; } protected: MatrixTypeNested m_matrix; diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 994e485eb..4331a721a 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -260,21 +260,21 @@ class DenseBase /** Copies \a other into *this. \returns a reference to *this. */ template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator=(const DenseBase& other); /** 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 EIGEN_STRONG_INLINE Derived& operator=(const DenseBase& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator=(const DenseBase& other); template - EIGEN_DEVICE_FUNC Derived& operator=(const EigenBase& other); + EIGEN_DEVICE_FUNC constexpr Derived& operator=(const EigenBase& other); template - EIGEN_DEVICE_FUNC Derived& operator+=(const EigenBase& other); + EIGEN_DEVICE_FUNC constexpr Derived& operator+=(const EigenBase& other); template - EIGEN_DEVICE_FUNC Derived& operator-=(const EigenBase& other); + EIGEN_DEVICE_FUNC constexpr Derived& operator-=(const EigenBase& other); template EIGEN_DEVICE_FUNC Derived& operator=(const ReturnByValue& func); @@ -283,7 +283,7 @@ class DenseBase * Copies \a other into *this without evaluating other. \returns a reference to *this. */ template /** \deprecated */ - EIGEN_DEPRECATED EIGEN_DEVICE_FUNC Derived& lazyAssign(const DenseBase& other); + EIGEN_DEPRECATED EIGEN_DEVICE_FUNC constexpr Derived& lazyAssign(const DenseBase& other); EIGEN_DEVICE_FUNC CommaInitializer operator<<(const Scalar& s); @@ -348,13 +348,13 @@ class DenseBase EIGEN_DEVICE_FUNC Derived& setRandom(); template - EIGEN_DEVICE_FUNC bool isApprox(const DenseBase& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; - EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const RealScalar& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; + EIGEN_DEVICE_FUNC constexpr bool isApprox(const DenseBase& other, + const RealScalar& prec = NumTraits::dummy_precision()) const; + EIGEN_DEVICE_FUNC constexpr bool isMuchSmallerThan( + const RealScalar& other, const RealScalar& prec = NumTraits::dummy_precision()) const; template - EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const DenseBase& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; + EIGEN_DEVICE_FUNC constexpr bool isMuchSmallerThan( + const DenseBase& other, const RealScalar& prec = NumTraits::dummy_precision()) const; EIGEN_DEVICE_FUNC bool isApproxToConstant(const Scalar& value, const RealScalar& prec = NumTraits::dummy_precision()) const; @@ -366,13 +366,13 @@ class DenseBase EIGEN_DEVICE_FUNC inline bool hasNaN() const; EIGEN_DEVICE_FUNC inline bool allFinite() const; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*=(const Scalar& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator*=(const Scalar& other); template ::value, typename = std::enable_if_t> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*=(const RealScalar& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator*=(const RealScalar& other); - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator/=(const Scalar& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator/=(const Scalar& other); template ::value, typename = std::enable_if_t> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator/=(const RealScalar& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator/=(const RealScalar& other); typedef internal::add_const_on_value_type_t::type> EvalReturnType; /** \returns the matrix or vector obtained by evaluating this expression. @@ -409,7 +409,7 @@ class DenseBase call_assignment(derived(), other.derived(), internal::swap_assign_op()); } - EIGEN_DEVICE_FUNC inline const NestByValue nestByValue() const; + EIGEN_DEVICE_FUNC constexpr inline const NestByValue nestByValue() const; EIGEN_DEVICE_FUNC inline const ForceAlignedAccess forceAlignedAccess() const; EIGEN_DEVICE_FUNC inline ForceAlignedAccess forceAlignedAccess(); template @@ -523,25 +523,25 @@ class DenseBase static const RandomReturnType Random(); template - inline EIGEN_DEVICE_FUNC - CwiseTernaryOp::Scalar, - typename DenseBase::Scalar, Scalar>, - ThenDerived, ElseDerived, Derived> - select(const DenseBase& thenMatrix, const DenseBase& elseMatrix) const; + inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp< + internal::scalar_boolean_select_op::Scalar, + typename DenseBase::Scalar, Scalar>, + ThenDerived, ElseDerived, Derived> + select(const DenseBase& thenMatrix, const DenseBase& elseMatrix) const; template - inline EIGEN_DEVICE_FUNC - CwiseTernaryOp::Scalar, - typename DenseBase::Scalar, Scalar>, - ThenDerived, typename DenseBase::ConstantReturnType, Derived> - select(const DenseBase& thenMatrix, const typename DenseBase::Scalar& elseScalar) const; + inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp< + internal::scalar_boolean_select_op::Scalar, + typename DenseBase::Scalar, Scalar>, + ThenDerived, typename DenseBase::ConstantReturnType, Derived> + select(const DenseBase& thenMatrix, const typename DenseBase::Scalar& elseScalar) const; template - inline EIGEN_DEVICE_FUNC - CwiseTernaryOp::Scalar, - typename DenseBase::Scalar, Scalar>, - typename DenseBase::ConstantReturnType, ElseDerived, Derived> - select(const typename DenseBase::Scalar& thenScalar, const DenseBase& elseMatrix) const; + inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp< + internal::scalar_boolean_select_op::Scalar, + typename DenseBase::Scalar, Scalar>, + typename DenseBase::ConstantReturnType, ElseDerived, Derived> + select(const typename DenseBase::Scalar& thenScalar, const DenseBase& elseMatrix) const; template RealScalar lpNorm() const; diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index 8a24ede7d..c52841694 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -67,14 +67,14 @@ class DenseCoeffsBase : public EigenBase { using Base::rows; using Base::size; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner) const { return int(Derived::RowsAtCompileTime) == 1 ? 0 : int(Derived::ColsAtCompileTime) == 1 ? inner : int(Derived::Flags) & RowMajorBit ? outer : inner; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colIndexByOuterInner(Index outer, Index inner) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index colIndexByOuterInner(Index outer, Index inner) const { return int(Derived::ColsAtCompileTime) == 1 ? 0 : int(Derived::RowsAtCompileTime) == 1 ? inner : int(Derived::Flags) & RowMajorBit ? inner @@ -316,7 +316,7 @@ class DenseCoeffsBase : public DenseCoeffsBase(derived()).coeffRef(row, col); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRefByOuterInner(Index outer, Index inner) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRefByOuterInner(Index outer, Index inner) { return coeffRef(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner)); } diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index 654cfc9d0..61a47842e 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -71,14 +71,14 @@ class Diagonal : public internal::dense_xpr_base::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal) - EIGEN_DEVICE_FUNC explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) + EIGEN_DEVICE_FUNC constexpr explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) { eigen_assert(a_index <= m_matrix.cols() && -a_index <= m_matrix.rows()); } EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal) - EIGEN_DEVICE_FUNC inline Index rows() const { + EIGEN_DEVICE_FUNC constexpr inline Index rows() const { return m_index.value() < 0 ? numext::mini(m_matrix.cols(), m_matrix.rows() + m_index.value()) : numext::mini(m_matrix.rows(), m_matrix.cols() - m_index.value()); } @@ -124,11 +124,12 @@ class Diagonal : public internal::dense_xpr_base& nestedExpression() const { + EIGEN_DEVICE_FUNC constexpr inline const internal::remove_all_t& nestedExpression() + const { return m_matrix; } - EIGEN_DEVICE_FUNC inline Index index() const { return m_index.value(); } + EIGEN_DEVICE_FUNC constexpr inline Index index() const { return m_index.value(); } protected: typename internal::ref_selector::non_const_type m_matrix; @@ -157,13 +158,13 @@ class Diagonal : public internal::dense_xpr_base -EIGEN_DEVICE_FUNC inline typename MatrixBase::DiagonalReturnType MatrixBase::diagonal() { +EIGEN_DEVICE_FUNC constexpr typename MatrixBase::DiagonalReturnType MatrixBase::diagonal() { return DiagonalReturnType(derived()); } /** This is the const version of diagonal(). */ template -EIGEN_DEVICE_FUNC inline const typename MatrixBase::ConstDiagonalReturnType MatrixBase::diagonal() +EIGEN_DEVICE_FUNC constexpr const typename MatrixBase::ConstDiagonalReturnType MatrixBase::diagonal() const { return ConstDiagonalReturnType(derived()); } @@ -180,13 +181,14 @@ EIGEN_DEVICE_FUNC inline const typename MatrixBase::ConstDiagonalReturn * * \sa MatrixBase::diagonal(), class Diagonal */ template -EIGEN_DEVICE_FUNC inline Diagonal MatrixBase::diagonal(Index index) { +EIGEN_DEVICE_FUNC constexpr Diagonal MatrixBase::diagonal(Index index) { return Diagonal(derived(), index); } /** This is the const version of diagonal(Index). */ template -EIGEN_DEVICE_FUNC inline const Diagonal MatrixBase::diagonal(Index index) const { +EIGEN_DEVICE_FUNC constexpr const Diagonal MatrixBase::diagonal( + Index index) const { return Diagonal(derived(), index); } @@ -203,14 +205,14 @@ EIGEN_DEVICE_FUNC inline const Diagonal MatrixBase< * \sa MatrixBase::diagonal(), class Diagonal */ template template -EIGEN_DEVICE_FUNC inline Diagonal MatrixBase::diagonal() { +EIGEN_DEVICE_FUNC constexpr Diagonal MatrixBase::diagonal() { return Diagonal(derived()); } /** This is the const version of diagonal(). */ template template -EIGEN_DEVICE_FUNC inline const Diagonal MatrixBase::diagonal() const { +EIGEN_DEVICE_FUNC constexpr const Diagonal MatrixBase::diagonal() const { return Diagonal(derived()); } diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index c49702009..c14d0811d 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -184,21 +184,22 @@ class DiagonalMatrix : public DiagonalBase - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DiagonalMatrix(const Scalar& a0, const Scalar& a1, const Scalar& a2, - const ArgTypes&... args) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE DiagonalMatrix(const Scalar& a0, const Scalar& a1, const Scalar& a2, + const ArgTypes&... args) : m_diagonal(a0, a1, a2, args...) {} /** \brief Constructs a DiagonalMatrix and initializes it by elements given by an initializer list of initializer @@ -221,11 +222,12 @@ class DiagonalMatrix : public DiagonalBase - EIGEN_DEVICE_FUNC inline DiagonalMatrix(const DiagonalBase& other) : m_diagonal(other.diagonal()) {} + EIGEN_DEVICE_FUNC constexpr inline DiagonalMatrix(const DiagonalBase& other) + : m_diagonal(other.diagonal()) {} #ifndef EIGEN_PARSED_BY_DOXYGEN /** copy constructor. prevent a default copy constructor from hiding the other templated constructor */ @@ -234,7 +236,8 @@ class DiagonalMatrix : public DiagonalBase - EIGEN_DEVICE_FUNC explicit inline DiagonalMatrix(const MatrixBase& other) : m_diagonal(other) {} + EIGEN_DEVICE_FUNC constexpr explicit inline DiagonalMatrix(const MatrixBase& other) + : m_diagonal(other) {} /** Copy operator. */ template @@ -325,10 +328,11 @@ class DiagonalWrapper : public DiagonalBase #endif /** Constructor from expression of diagonal coefficients to wrap. */ - EIGEN_DEVICE_FUNC explicit inline DiagonalWrapper(DiagonalVectorType& a_diagonal) : m_diagonal(a_diagonal) {} + EIGEN_DEVICE_FUNC constexpr explicit 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; } + EIGEN_DEVICE_FUNC constexpr const DiagonalVectorType& diagonal() const { return m_diagonal; } protected: typename DiagonalVectorType::Nested m_diagonal; @@ -344,7 +348,7 @@ class DiagonalWrapper : public DiagonalBase * \sa class DiagonalWrapper, class DiagonalMatrix, diagonal(), isDiagonal() **/ template -EIGEN_DEVICE_FUNC inline const DiagonalWrapper MatrixBase::asDiagonal() const { +EIGEN_DEVICE_FUNC constexpr const DiagonalWrapper MatrixBase::asDiagonal() const { return DiagonalWrapper(derived()); } @@ -383,7 +387,7 @@ bool MatrixBase::isDiagonal(const RealScalar& prec) const { /** This is the non-const version of diagonalView() with DiagIndex_ . */ template template -EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBase::diagonalView() { +EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> MatrixBase::diagonalView() { typedef Diagonal DiagType; typedef DiagonalWrapper ReturnType; DiagType diag(this->derived()); @@ -393,7 +397,8 @@ EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBase template -EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBase::diagonalView() const { +EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> MatrixBase::diagonalView() + const { typedef Diagonal DiagType; typedef DiagonalWrapper ReturnType; DiagType diag(this->derived()); @@ -402,7 +407,8 @@ EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBas /** This is the non-const version of diagonalView() with dynamic index. */ template -EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBase::diagonalView(Index index) { +EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> MatrixBase::diagonalView( + Index index) { typedef Diagonal DiagType; typedef DiagonalWrapper ReturnType; DiagType diag(this->derived(), index); @@ -411,7 +417,7 @@ EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBase -EIGEN_DEVICE_FUNC DiagonalWrapper> MatrixBase::diagonalView( +EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> MatrixBase::diagonalView( Index index) const { typedef Diagonal DiagType; typedef DiagonalWrapper ReturnType; diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index b9abf958f..d0a30dd82 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -20,12 +20,14 @@ namespace internal { template ::Scalar> struct squared_norm_impl { using Real = typename NumTraits::Real; - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Real run(const Derived& a) { return a.realView().cwiseAbs2().sum(); } + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Real run(const Derived& a) { + return a.realView().cwiseAbs2().sum(); + } }; template struct squared_norm_impl { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(const Derived& a) { return a.any(); } + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool run(const Derived& a) { return a.any(); } }; } // end namespace internal @@ -43,7 +45,7 @@ struct squared_norm_impl { */ template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ScalarBinaryOpTraits::Scalar, typename internal::traits::Scalar>::ReturnType MatrixBase::dot(const MatrixBase& other) const { @@ -59,7 +61,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE * \sa dot(), norm(), lpNorm() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NumTraits::Scalar>::Real +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NumTraits::Scalar>::Real MatrixBase::squaredNorm() const { return internal::squared_norm_impl::run(derived()); } diff --git a/Eigen/src/Core/EigenBase.h b/Eigen/src/Core/EigenBase.h index c9a6e88e2..dfe4a6404 100644 --- a/Eigen/src/Core/EigenBase.h +++ b/Eigen/src/Core/EigenBase.h @@ -53,7 +53,7 @@ struct EigenBase { EIGEN_DEVICE_FUNC inline constexpr Derived& const_cast_derived() const { return *static_cast(const_cast(this)); } - EIGEN_DEVICE_FUNC inline const Derived& const_derived() const { return *static_cast(this); } + EIGEN_DEVICE_FUNC constexpr inline const Derived& const_derived() const { return *static_cast(this); } /** \returns the number of rows. \sa cols(), RowsAtCompileTime */ EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return derived().rows(); } @@ -65,13 +65,13 @@ struct EigenBase { /** \internal Don't use it, but do the equivalent: \code dst = *this; \endcode */ template - EIGEN_DEVICE_FUNC inline void evalTo(Dest& dst) const { + EIGEN_DEVICE_FUNC constexpr inline void evalTo(Dest& dst) const { derived().evalTo(dst); } /** \internal Don't use it, but do the equivalent: \code dst += *this; \endcode */ template - EIGEN_DEVICE_FUNC inline void addTo(Dest& dst) const { + EIGEN_DEVICE_FUNC constexpr inline void addTo(Dest& dst) const { // This is the default implementation, // derived class can reimplement it in a more optimized way. typename Dest::PlainObject res(rows(), cols()); @@ -81,7 +81,7 @@ struct EigenBase { /** \internal Don't use it, but do the equivalent: \code dst -= *this; \endcode */ template - EIGEN_DEVICE_FUNC inline void subTo(Dest& dst) const { + EIGEN_DEVICE_FUNC constexpr inline void subTo(Dest& dst) const { // This is the default implementation, // derived class can reimplement it in a more optimized way. typename Dest::PlainObject res(rows(), cols()); @@ -91,7 +91,7 @@ struct EigenBase { /** \internal Don't use it, but do the equivalent: \code dst.applyOnTheRight(*this); \endcode */ template - EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const { + EIGEN_DEVICE_FUNC constexpr inline void applyThisOnTheRight(Dest& dst) const { // This is the default implementation, // derived class can reimplement it in a more optimized way. dst = dst * this->derived(); @@ -99,7 +99,7 @@ struct EigenBase { /** \internal Don't use it, but do the equivalent: \code dst.applyOnTheLeft(*this); \endcode */ template - EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const { + EIGEN_DEVICE_FUNC constexpr inline void applyThisOnTheLeft(Dest& dst) const { // This is the default implementation, // derived class can reimplement it in a more optimized way. dst = this->derived() * dst; @@ -125,21 +125,21 @@ struct EigenBase { */ template template -EIGEN_DEVICE_FUNC Derived& DenseBase::operator=(const EigenBase& other) { +EIGEN_DEVICE_FUNC constexpr Derived& DenseBase::operator=(const EigenBase& other) { call_assignment(derived(), other.derived()); return derived(); } template template -EIGEN_DEVICE_FUNC Derived& DenseBase::operator+=(const EigenBase& other) { +EIGEN_DEVICE_FUNC constexpr Derived& DenseBase::operator+=(const EigenBase& other) { call_assignment(derived(), other.derived(), internal::add_assign_op()); return derived(); } template template -EIGEN_DEVICE_FUNC Derived& DenseBase::operator-=(const EigenBase& other) { +EIGEN_DEVICE_FUNC constexpr Derived& DenseBase::operator-=(const EigenBase& other) { call_assignment(derived(), other.derived(), internal::sub_assign_op()); return derived(); } diff --git a/Eigen/src/Core/ForceAlignedAccess.h b/Eigen/src/Core/ForceAlignedAccess.h index cdbb3b8f4..4f69c20f9 100644 --- a/Eigen/src/Core/ForceAlignedAccess.h +++ b/Eigen/src/Core/ForceAlignedAccess.h @@ -39,7 +39,7 @@ class ForceAlignedAccess : public internal::dense_xpr_base::type Base; EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess) - EIGEN_DEVICE_FUNC explicit inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {} + EIGEN_DEVICE_FUNC explicit constexpr ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {} EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); } diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index ed6b4ffea..eaa553c93 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -86,8 +86,8 @@ struct isMuchSmallerThan_scalar_selector { */ template template -EIGEN_DEVICE_FUNC bool DenseBase::isApprox(const DenseBase& other, - const RealScalar& prec) const { +EIGEN_DEVICE_FUNC constexpr bool DenseBase::isApprox(const DenseBase& other, + const RealScalar& prec) const { return internal::isApprox_selector::run(derived(), other.derived(), prec); } @@ -105,8 +105,8 @@ EIGEN_DEVICE_FUNC bool DenseBase::isApprox(const DenseBase&, RealScalar) const */ template -EIGEN_DEVICE_FUNC bool DenseBase::isMuchSmallerThan(const typename NumTraits::Real& other, - const RealScalar& prec) const { +EIGEN_DEVICE_FUNC constexpr bool DenseBase::isMuchSmallerThan(const typename NumTraits::Real& other, + const RealScalar& prec) const { return internal::isMuchSmallerThan_scalar_selector::run(derived(), other, prec); } @@ -122,8 +122,8 @@ EIGEN_DEVICE_FUNC bool DenseBase::isMuchSmallerThan(const typename NumT */ template template -EIGEN_DEVICE_FUNC bool DenseBase::isMuchSmallerThan(const DenseBase& other, - const RealScalar& prec) const { +EIGEN_DEVICE_FUNC constexpr bool DenseBase::isMuchSmallerThan(const DenseBase& other, + const RealScalar& prec) const { return internal::isMuchSmallerThan_object_selector::run(derived(), other.derived(), prec); } diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index df1098e27..c32aac9ac 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -130,12 +130,12 @@ using GlobalUnaryPowReturnType = std::enable_if_t< */ #ifdef EIGEN_PARSED_BY_DOXYGEN template -EIGEN_DEVICE_FUNC inline const GlobalUnaryPowReturnType pow(const Eigen::ArrayBase& x, - const ScalarExponent& exponent); +EIGEN_DEVICE_FUNC constexpr inline const GlobalUnaryPowReturnType pow( + const Eigen::ArrayBase& x, const ScalarExponent& exponent); #else template -EIGEN_DEVICE_FUNC inline const GlobalUnaryPowReturnType pow(const Eigen::ArrayBase& x, - const ScalarExponent& exponent) { +EIGEN_DEVICE_FUNC constexpr inline const GlobalUnaryPowReturnType pow( + const Eigen::ArrayBase& x, const ScalarExponent& exponent) { return GlobalUnaryPowReturnType( x.derived(), internal::scalar_unary_pow_op(exponent)); } diff --git a/Eigen/src/Core/IndexedView.h b/Eigen/src/Core/IndexedView.h index af047c4ee..44d5c020a 100644 --- a/Eigen/src/Core/IndexedView.h +++ b/Eigen/src/Core/IndexedView.h @@ -259,26 +259,27 @@ struct unary_evaluator, IndexBased> Alignment = 0 }; - EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_xpr(xpr) { + EIGEN_DEVICE_FUNC constexpr explicit unary_evaluator(const XprType& xpr) + : m_argImpl(xpr.nestedExpression()), m_xpr(xpr) { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols()); return m_argImpl.coeff(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols()); return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { EIGEN_STATIC_ASSERT_LVALUE(XprType) Index row = XprType::RowsAtCompileTime == 1 ? 0 : index; Index col = XprType::RowsAtCompileTime == 1 ? index : 0; @@ -287,7 +288,7 @@ struct unary_evaluator, IndexBased> return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const { Index row = XprType::RowsAtCompileTime == 1 ? 0 : index; Index col = XprType::RowsAtCompileTime == 1 ? index : 0; eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() && @@ -295,7 +296,7 @@ struct unary_evaluator, IndexBased> return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index index) const { Index row = XprType::RowsAtCompileTime == 1 ? 0 : index; Index col = XprType::RowsAtCompileTime == 1 ? index : 0; eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() && diff --git a/Eigen/src/Core/Inverse.h b/Eigen/src/Core/Inverse.h index 79fc3ab6a..855e3b3e2 100644 --- a/Eigen/src/Core/Inverse.h +++ b/Eigen/src/Core/Inverse.h @@ -49,12 +49,12 @@ class Inverse : public InverseImpl:: typedef typename internal::ref_selector::type Nested; typedef internal::remove_all_t NestedExpression; - explicit EIGEN_DEVICE_FUNC Inverse(const XprType& xpr) : m_xpr(xpr) {} + explicit EIGEN_DEVICE_FUNC constexpr Inverse(const XprType& xpr) : m_xpr(xpr) {} EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_xpr.cols(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_xpr.rows(); } - EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; } + EIGEN_DEVICE_FUNC constexpr const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; } protected: XprTypeNested m_xpr; diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index c740da726..52a8eca53 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -100,7 +100,7 @@ class Map : public MapBase > { typedef typename Base::PointerType PointerType; typedef PointerType PointerArgType; - EIGEN_DEVICE_FUNC inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; } + EIGEN_DEVICE_FUNC constexpr inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; } EIGEN_DEVICE_FUNC constexpr Index innerStride() const { return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; @@ -120,7 +120,7 @@ class Map : public MapBase > { * \param dataPtr pointer to the array to map * \param stride optional Stride object, passing the strides. */ - EIGEN_DEVICE_FUNC explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType()) + EIGEN_DEVICE_FUNC constexpr explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType()) : Base(cast_to_pointer_type(dataPtr)), m_stride(stride) {} /** Constructor in the dynamic-size vector case. @@ -129,7 +129,7 @@ class Map : public MapBase > { * \param size the size of the vector expression * \param stride optional Stride object, passing the strides. */ - EIGEN_DEVICE_FUNC inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType()) + EIGEN_DEVICE_FUNC constexpr inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType()) : Base(cast_to_pointer_type(dataPtr), size), m_stride(stride) {} /** Constructor in the dynamic-size matrix case. @@ -139,7 +139,8 @@ class Map : public MapBase > { * \param cols the number of columns of the matrix expression * \param stride optional Stride object, passing the strides. */ - EIGEN_DEVICE_FUNC inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType()) + EIGEN_DEVICE_FUNC constexpr inline Map(PointerArgType dataPtr, Index rows, Index cols, + const StrideType& stride = StrideType()) : Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 5e3d746bc..3e117253a 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -97,23 +97,23 @@ class MapBase : public internal::dense_xpr_basem_data[colId * colStride() + rowId * rowStride()]; } /** \copydoc PlainObjectBase::coeffRef(Index) const */ - EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { + EIGEN_DEVICE_FUNC constexpr inline const Scalar& coeffRef(Index index) const { EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) return this->m_data[index * innerStride()]; } @@ -132,14 +132,14 @@ class MapBase : public internal::dense_xpr_base(); } /** \internal Constructor for dynamically sized vectors */ - EIGEN_DEVICE_FUNC inline MapBase(PointerType dataPtr, Index vecSize) + EIGEN_DEVICE_FUNC constexpr inline MapBase(PointerType dataPtr, Index vecSize) : m_data(dataPtr), m_rows(RowsAtCompileTime == Dynamic ? vecSize : Index(RowsAtCompileTime)), m_cols(ColsAtCompileTime == Dynamic ? vecSize : Index(ColsAtCompileTime)) { @@ -150,7 +150,7 @@ class MapBase : public internal::dense_xpr_base= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols))); @@ -238,11 +238,11 @@ class MapBase : public MapBasem_data; } // no const-cast here so non-const-correct code will give a compile error - EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col) { + EIGEN_DEVICE_FUNC constexpr inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col) { return this->m_data[col * colStride() + row * rowStride()]; } - EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue& coeffRef(Index index) { + EIGEN_DEVICE_FUNC constexpr inline ScalarWithConstIfNotLvalue& coeffRef(Index index) { EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) return this->m_data[index * innerStride()]; } @@ -258,9 +258,9 @@ class MapBase : public MapBase(this->m_data + index * innerStride(), val); } - EIGEN_DEVICE_FUNC explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {} - EIGEN_DEVICE_FUNC inline MapBase(PointerType dataPtr, Index vecSize) : Base(dataPtr, vecSize) {} - EIGEN_DEVICE_FUNC inline MapBase(PointerType dataPtr, Index rows, Index cols) : Base(dataPtr, rows, cols) {} + EIGEN_DEVICE_FUNC constexpr explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {} + EIGEN_DEVICE_FUNC constexpr inline MapBase(PointerType dataPtr, Index vecSize) : Base(dataPtr, vecSize) {} + EIGEN_DEVICE_FUNC constexpr inline MapBase(PointerType dataPtr, Index rows, Index cols) : Base(dataPtr, rows, cols) {} EIGEN_DEVICE_FUNC Derived& operator=(const MapBase& other) { ReadOnlyMapBase::Base::operator=(other); diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index b810f4083..4e7597ced 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -74,7 +74,7 @@ struct global_math_functions_filtering_base< template ::IsComplex> struct real_default_impl { typedef typename NumTraits::Real RealScalar; - EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { return x; } + EIGEN_DEVICE_FUNC static constexpr RealScalar run(const Scalar& x) { return x; } }; template @@ -222,7 +222,7 @@ namespace internal { template ::IsComplex> struct conj_default_impl { - EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { return x; } + EIGEN_DEVICE_FUNC static constexpr Scalar run(const Scalar& x) { return x; } }; template @@ -287,7 +287,7 @@ struct sqrt_impl { // Complex sqrt defined in MathFunctionsImpl.h. template -EIGEN_DEVICE_FUNC ComplexT complex_sqrt(const ComplexT& a_x); +EIGEN_DEVICE_FUNC constexpr ComplexT complex_sqrt(const ComplexT& a_x); // Custom implementation is faster than `std::sqrt`, works on // GPU, and correctly handles special cases (unlike MSVC). @@ -307,7 +307,7 @@ struct rsqrt_impl; // Complex rsqrt defined in MathFunctionsImpl.h. template -EIGEN_DEVICE_FUNC ComplexT complex_rsqrt(const ComplexT& a_x); +EIGEN_DEVICE_FUNC constexpr ComplexT complex_rsqrt(const ComplexT& a_x); template struct rsqrt_impl> { @@ -504,7 +504,7 @@ struct expm1_retval { // Complex log defined in MathFunctionsImpl.h. template -EIGEN_DEVICE_FUNC ComplexT complex_log(const ComplexT& z); +EIGEN_DEVICE_FUNC constexpr ComplexT complex_log(const ComplexT& z); template struct log_impl { @@ -1023,13 +1023,13 @@ namespace numext { #if (!defined(EIGEN_GPUCC) || defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC)) template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) { +EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) { EIGEN_USING_STD(min) return min EIGEN_NOT_A_MACRO(x, y); } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) { +EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) { EIGEN_USING_STD(max) return max EIGEN_NOT_A_MACRO(x, y); } diff --git a/Eigen/src/Core/MathFunctionsImpl.h b/Eigen/src/Core/MathFunctionsImpl.h index 43d9d646a..b8760e02e 100644 --- a/Eigen/src/Core/MathFunctionsImpl.h +++ b/Eigen/src/Core/MathFunctionsImpl.h @@ -148,7 +148,8 @@ struct generic_sqrt_newton_step { }; template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RealScalar positive_real_hypot(const RealScalar& x, const RealScalar& y) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE RealScalar positive_real_hypot(const RealScalar& x, + const RealScalar& y) { // IEEE IEC 6059 special cases. if ((numext::isinf)(x) || (numext::isinf)(y)) return NumTraits::infinity(); if ((numext::isnan)(x) || (numext::isnan)(y)) return NumTraits::quiet_NaN(); @@ -173,7 +174,7 @@ struct hypot_impl { // Generic complex sqrt implementation that correctly handles corner cases // according to https://en.cppreference.com/w/cpp/numeric/complex/sqrt template -EIGEN_DEVICE_FUNC ComplexT complex_sqrt(const ComplexT& z) { +EIGEN_DEVICE_FUNC constexpr ComplexT complex_sqrt(const ComplexT& z) { // Computes the principal sqrt of the input. // // For a complex square root of the number x + i*y. We want to find real @@ -209,7 +210,7 @@ EIGEN_DEVICE_FUNC ComplexT complex_sqrt(const ComplexT& z) { // Generic complex rsqrt implementation. template -EIGEN_DEVICE_FUNC ComplexT complex_rsqrt(const ComplexT& z) { +EIGEN_DEVICE_FUNC constexpr ComplexT complex_rsqrt(const ComplexT& z) { // Computes the principal reciprocal sqrt of the input. // // For a complex reciprocal square root of the number z = x + i*y. We want to @@ -248,7 +249,7 @@ EIGEN_DEVICE_FUNC ComplexT complex_rsqrt(const ComplexT& z) { } template -EIGEN_DEVICE_FUNC ComplexT complex_log(const ComplexT& z) { +EIGEN_DEVICE_FUNC constexpr ComplexT complex_log(const ComplexT& z) { // Computes complex log. using T = typename NumTraits::Real; T a = numext::abs(z); diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 845b07f58..ca8f622ea 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -316,12 +316,12 @@ class Matrix : public PlainObjectBase - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Matrix(const T& x) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit Matrix(const T& x) { Base::template _init1(x); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y) { Base::template _init2(x, y); } @@ -367,7 +367,7 @@ class Matrix : public PlainObjectBase&) */ template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const EigenBase& other) : Base(other.derived()) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Matrix(const EigenBase& other) + : Base(other.derived()) {} EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept { return 1; } EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return this->innerSize(); } diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 1fedfdace..ff1a2c232 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -99,7 +99,7 @@ class MatrixBase : public DenseBase { /** \returns the size of the main diagonal, which is min(rows(),cols()). * \sa rows(), cols(), SizeAtCompileTime. */ - EIGEN_DEVICE_FUNC inline Index diagonalSize() const { return (numext::mini)(rows(), cols()); } + EIGEN_DEVICE_FUNC constexpr Index diagonalSize() const { return (numext::mini)(rows(), cols()); } typedef typename Base::PlainObject PlainObject; @@ -136,19 +136,19 @@ class MatrixBase : public DenseBase { /** 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 EIGEN_STRONG_INLINE Derived& operator=(const MatrixBase& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator=(const MatrixBase& other); // We cannot inherit here via Base::operator= since it is causing // trouble with MSVC. template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase& other); + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& operator=(const DenseBase& other); template - EIGEN_DEVICE_FUNC Derived& operator=(const EigenBase& other); + EIGEN_DEVICE_FUNC constexpr Derived& operator=(const EigenBase& other); template - EIGEN_DEVICE_FUNC Derived& operator=(const ReturnByValue& other); + EIGEN_DEVICE_FUNC constexpr Derived& operator=(const ReturnByValue& other); template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator+=(const MatrixBase& other); @@ -180,11 +180,11 @@ class MatrixBase : public DenseBase { const SkewSymmetricBase& skew) const; template - EIGEN_DEVICE_FUNC typename ScalarBinaryOpTraits::Scalar, - typename internal::traits::Scalar>::ReturnType + EIGEN_DEVICE_FUNC constexpr typename ScalarBinaryOpTraits::Scalar, + typename internal::traits::Scalar>::ReturnType dot(const MatrixBase& other) const; - EIGEN_DEVICE_FUNC RealScalar squaredNorm() const; + EIGEN_DEVICE_FUNC constexpr RealScalar squaredNorm() const; EIGEN_DEVICE_FUNC RealScalar norm() const; RealScalar stableNorm() const; RealScalar blueNorm() const; @@ -194,23 +194,23 @@ class MatrixBase : public DenseBase { EIGEN_DEVICE_FUNC void normalize(); EIGEN_DEVICE_FUNC void stableNormalize(); - EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const; + EIGEN_DEVICE_FUNC constexpr const AdjointReturnType adjoint() const; EIGEN_DEVICE_FUNC void adjointInPlace(); typedef Diagonal DiagonalReturnType; - EIGEN_DEVICE_FUNC DiagonalReturnType diagonal(); + EIGEN_DEVICE_FUNC constexpr DiagonalReturnType diagonal(); typedef Diagonal ConstDiagonalReturnType; - EIGEN_DEVICE_FUNC const ConstDiagonalReturnType diagonal() const; + EIGEN_DEVICE_FUNC constexpr const ConstDiagonalReturnType diagonal() const; template - EIGEN_DEVICE_FUNC Diagonal diagonal(); + EIGEN_DEVICE_FUNC constexpr Diagonal diagonal(); template - EIGEN_DEVICE_FUNC const Diagonal diagonal() const; + EIGEN_DEVICE_FUNC constexpr const Diagonal diagonal() const; - EIGEN_DEVICE_FUNC Diagonal diagonal(Index index); - EIGEN_DEVICE_FUNC const Diagonal diagonal(Index index) const; + EIGEN_DEVICE_FUNC constexpr Diagonal diagonal(Index index); + EIGEN_DEVICE_FUNC constexpr const Diagonal diagonal(Index index) const; template struct TriangularViewReturnType { @@ -222,9 +222,9 @@ class MatrixBase : public DenseBase { }; template - EIGEN_DEVICE_FUNC typename TriangularViewReturnType::Type triangularView(); + EIGEN_DEVICE_FUNC constexpr typename TriangularViewReturnType::Type triangularView(); template - EIGEN_DEVICE_FUNC typename ConstTriangularViewReturnType::Type triangularView() const; + EIGEN_DEVICE_FUNC constexpr typename ConstTriangularViewReturnType::Type triangularView() const; template struct SelfAdjointViewReturnType { @@ -236,9 +236,9 @@ class MatrixBase : public DenseBase { }; template - EIGEN_DEVICE_FUNC typename SelfAdjointViewReturnType::Type selfadjointView(); + EIGEN_DEVICE_FUNC constexpr typename SelfAdjointViewReturnType::Type selfadjointView(); template - EIGEN_DEVICE_FUNC typename ConstSelfAdjointViewReturnType::Type selfadjointView() const; + EIGEN_DEVICE_FUNC constexpr typename ConstSelfAdjointViewReturnType::Type selfadjointView() const; const SparseView sparseView( const Scalar& m_reference = Scalar(0), @@ -252,9 +252,9 @@ class MatrixBase : public DenseBase { EIGEN_DEVICE_FUNC static const BasisReturnType UnitZ(); EIGEN_DEVICE_FUNC static const BasisReturnType UnitW(); - EIGEN_DEVICE_FUNC const DiagonalWrapper asDiagonal() const; + EIGEN_DEVICE_FUNC constexpr const DiagonalWrapper asDiagonal() const; const PermutationWrapper asPermutation() const; - EIGEN_DEVICE_FUNC const SkewSymmetricWrapper asSkewSymmetric() const; + EIGEN_DEVICE_FUNC constexpr const SkewSymmetricWrapper asSkewSymmetric() const; EIGEN_DEVICE_FUNC Derived& setIdentity(); EIGEN_DEVICE_FUNC Derived& setIdentity(Index rows, Index cols); @@ -276,14 +276,14 @@ class MatrixBase : public DenseBase { /* diagonalView */ template - EIGEN_DEVICE_FUNC DiagonalWrapper> diagonalView(); + EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> diagonalView(); template - EIGEN_DEVICE_FUNC DiagonalWrapper> diagonalView() const; + EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> diagonalView() const; - EIGEN_DEVICE_FUNC DiagonalWrapper> diagonalView(Index index); + EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> diagonalView(Index index); - EIGEN_DEVICE_FUNC DiagonalWrapper> diagonalView(Index index) const; + EIGEN_DEVICE_FUNC constexpr DiagonalWrapper> diagonalView(Index index) const; /** \returns true if each coefficients of \c *this and \a other are all exactly equal. * \warning When using floating point scalar values you probably should rather use a @@ -307,14 +307,14 @@ class MatrixBase : public DenseBase { // TODO forceAlignedAccess is temporarily disabled // Need to find a nicer workaround. - inline const Derived& forceAlignedAccess() const { return derived(); } - inline Derived& forceAlignedAccess() { return derived(); } + constexpr const Derived& forceAlignedAccess() const { return derived(); } + constexpr Derived& forceAlignedAccess() { return derived(); } template - inline const Derived& forceAlignedAccessIf() const { + constexpr const Derived& forceAlignedAccessIf() const { return derived(); } template - inline Derived& forceAlignedAccessIf() { + constexpr Derived& forceAlignedAccessIf() { return derived(); } @@ -323,15 +323,17 @@ class MatrixBase : public DenseBase { template EIGEN_DEVICE_FUNC RealScalar lpNorm() const; - EIGEN_DEVICE_FUNC MatrixBase& matrix() { return *this; } - EIGEN_DEVICE_FUNC const MatrixBase& matrix() const { return *this; } + EIGEN_DEVICE_FUNC constexpr MatrixBase& matrix() { return *this; } + EIGEN_DEVICE_FUNC constexpr const MatrixBase& matrix() const { return *this; } /** \returns an \link Eigen::ArrayBase Array \endlink expression of this matrix * \sa ArrayBase::matrix() */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper array() { return ArrayWrapper(derived()); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE ArrayWrapper array() { + return ArrayWrapper(derived()); + } /** \returns a const \link Eigen::ArrayBase Array \endlink expression of this matrix * \sa ArrayBase::matrix() */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArrayWrapper array() const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const ArrayWrapper array() const { return ArrayWrapper(derived()); } diff --git a/Eigen/src/Core/NestByValue.h b/Eigen/src/Core/NestByValue.h index c2c32c1c7..f18559ba1 100644 --- a/Eigen/src/Core/NestByValue.h +++ b/Eigen/src/Core/NestByValue.h @@ -43,20 +43,26 @@ class NestByValue : public internal::dense_xpr_base EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) - EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} + EIGEN_DEVICE_FUNC constexpr explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); } - EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; } + EIGEN_DEVICE_FUNC constexpr operator const ExpressionType&() const { return m_expression; } - EIGEN_DEVICE_FUNC const ExpressionType& nestedExpression() const { return m_expression; } + EIGEN_DEVICE_FUNC constexpr const ExpressionType& nestedExpression() const { return m_expression; } - EIGEN_DEVICE_FUNC std::enable_if_t data() const { return m_expression.data(); } + EIGEN_DEVICE_FUNC constexpr std::enable_if_t data() const { + return m_expression.data(); + } - EIGEN_DEVICE_FUNC std::enable_if_t innerStride() const { return m_expression.innerStride(); } + EIGEN_DEVICE_FUNC constexpr std::enable_if_t innerStride() const { + return m_expression.innerStride(); + } - EIGEN_DEVICE_FUNC std::enable_if_t outerStride() const { return m_expression.outerStride(); } + EIGEN_DEVICE_FUNC constexpr std::enable_if_t outerStride() const { + return m_expression.outerStride(); + } protected: const ExpressionType m_expression; @@ -65,7 +71,7 @@ class NestByValue : public internal::dense_xpr_base /** \returns an expression of the temporary version of *this. */ template -EIGEN_DEVICE_FUNC inline const NestByValue DenseBase::nestByValue() const { +EIGEN_DEVICE_FUNC constexpr inline const NestByValue DenseBase::nestByValue() const { return NestByValue(derived()); } @@ -76,7 +82,7 @@ template struct evaluator > : public evaluator { typedef evaluator Base; - EIGEN_DEVICE_FUNC explicit evaluator(const NestByValue& xpr) : Base(xpr.nestedExpression()) {} + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const NestByValue& xpr) : Base(xpr.nestedExpression()) {} }; } // namespace internal diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h index b6c720910..6a882014b 100644 --- a/Eigen/src/Core/NoAlias.h +++ b/Eigen/src/Core/NoAlias.h @@ -35,7 +35,7 @@ class NoAlias { public: typedef typename ExpressionType::Scalar Scalar; - EIGEN_DEVICE_FUNC explicit NoAlias(ExpressionType& expression) : m_expression(expression) {} + EIGEN_DEVICE_FUNC constexpr explicit NoAlias(ExpressionType& expression) : m_expression(expression) {} template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase& other) { @@ -58,7 +58,7 @@ class NoAlias { return m_expression; } - EIGEN_DEVICE_FUNC ExpressionType& expression() const { return m_expression; } + EIGEN_DEVICE_FUNC constexpr ExpressionType& expression() const { return m_expression; } protected: ExpressionType& m_expression; diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 77e44ca3d..1544a5821 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -159,8 +159,8 @@ class PlainObjectBase : public internal::dense_xpr_base::type { INVALID_MATRIX_TEMPLATE_PARAMETERS) EIGEN_STATIC_ASSERT(((Options & (DontAlign | RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS) - EIGEN_DEVICE_FUNC Base& base() { return *static_cast(this); } - EIGEN_DEVICE_FUNC const Base& base() const { return *static_cast(this); } + EIGEN_DEVICE_FUNC constexpr Base& base() { return *static_cast(this); } + EIGEN_DEVICE_FUNC constexpr const Base& base() const { return *static_cast(this); } EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_storage.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_storage.cols(); } @@ -339,7 +339,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type { * remain row-vectors and vectors remain vectors. */ template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resizeLike(const EigenBase& _other) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resizeLike(const EigenBase& _other) { const OtherDerived& other = _other.derived(); #ifndef EIGEN_NO_DEBUG internal::check_rows_cols_for_overflow::run( @@ -518,14 +518,14 @@ class PlainObjectBase : public internal::dense_xpr_base::type { /** \sa PlainObjectBase::operator=(const EigenBase&) */ template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase& other) : m_storage() { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase& other) : m_storage() { resizeLike(other); _set_noalias(other); } /** \sa PlainObjectBase::operator=(const EigenBase&) */ template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase& other) : m_storage() { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase& other) : m_storage() { resizeLike(other); *this = other.derived(); } @@ -731,23 +731,23 @@ class PlainObjectBase : public internal::dense_xpr_base::type { } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, - std::enable_if_t* = 0) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, + std::enable_if_t* = 0) { EIGEN_STATIC_ASSERT(internal::is_valid_index_type::value && internal::is_valid_index_type::value, T0 AND T1 MUST BE INTEGER TYPES) resize(rows, cols); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1, - std::enable_if_t* = 0) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1, + std::enable_if_t* = 0) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2) m_storage.data()[0] = Scalar(val0); m_storage.data()[1] = Scalar(val1); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2( const Index& val0, const Index& val1, std::enable_if_t<(!internal::is_same::value) && (internal::is_same::value) && (internal::is_same::value) && Base::SizeAtCompileTime == 2, @@ -760,7 +760,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type { // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array, // then the argument is meant to be the size of the object. template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1( Index size, std::enable_if_t<(Base::SizeAtCompileTime != 1 || !internal::is_convertible::value) && ((!internal::is_same::XprKind, ArrayXpr>::value || @@ -776,7 +776,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type { // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar // type can be implicitly converted) template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1( const Scalar& val0, std::enable_if_t::value, T>* = 0) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1) @@ -786,7 +786,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type { // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar // type match the index type) template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1( const Index& val0, std::enable_if_t<(!internal::is_same::value) && (internal::is_same::value) && Base::SizeAtCompileTime == 1 && internal::is_convertible::value, @@ -797,42 +797,42 @@ class PlainObjectBase : public internal::dense_xpr_base::type { // Initialize a fixed size matrix from a pointer to raw data template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Scalar* data) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar* data) { this->_set_noalias(ConstMapType(data)); } // Initialize an arbitrary matrix from a dense expression template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const DenseBase& other) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const DenseBase& other) { this->_set_noalias(other); } // Initialize an arbitrary matrix from an object convertible to the Derived type. template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Derived& other) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Derived& other) { this->_set_noalias(other); } // Initialize an arbitrary matrix from a generic Eigen expression template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const EigenBase& other) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const EigenBase& other) { this->derived() = other; } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const ReturnByValue& other) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const ReturnByValue& other) { resize(other.rows(), other.cols()); other.evalTo(this->derived()); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const RotationBase& r) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const RotationBase& r) { this->derived() = r; } // For fixed-size Array template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1( const Scalar& val0, std::enable_if_t::value && @@ -843,7 +843,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type { // For fixed-size Array template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1( + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1( const Index& val0, std::enable_if_t<(!internal::is_same::value) && (internal::is_same::value) && Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 && diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index c4f5650d6..bc8b9dad3 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -219,7 +219,7 @@ class Product using TransposeReturnType = typename internal::product_transpose_helper::TransposeType; using AdjointReturnType = typename internal::product_transpose_helper::AdjointType; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { eigen_assert(lhs.cols() == rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); } @@ -227,8 +227,8 @@ class Product EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_lhs.rows(); } EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_rhs.cols(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const LhsNestedCleaned& lhs() const { return m_lhs; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const RhsNestedCleaned& rhs() const { return m_rhs; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const LhsNestedCleaned& lhs() const { return m_lhs; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const RhsNestedCleaned& rhs() const { return m_rhs; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TransposeReturnType transpose() const { return internal::product_transpose_helper::run_transpose(*this); diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index cbff424c1..ae860e272 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -237,17 +237,17 @@ template struct generic_product_impl { using impl = default_inner_product_impl; template - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { dst.coeffRef(0, 0) = impl::run(lhs, rhs); } template - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { dst.coeffRef(0, 0) += impl::run(lhs, rhs); } template - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { dst.coeffRef(0, 0) -= impl::run(lhs, rhs); } }; @@ -592,7 +592,7 @@ struct product_evaluator, ProductTag, DenseShape, (int(InnerSize) % packet_traits::size == 0) }; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index row, Index col) const { return (m_lhs.row(row).transpose().cwiseProduct(m_rhs.col(col))).sum(); } @@ -600,7 +600,7 @@ struct product_evaluator, ProductTag, DenseShape, * which is why we don't set the LinearAccessBit. * TODO: this seems possible when the result is a vector */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index index) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index index) const { const Index row = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime == 1) ? 0 : index; const Index col = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime == 1) ? index : 0; return (m_lhs.row(row).transpose().cwiseProduct(m_rhs.col(col))).sum(); @@ -705,8 +705,8 @@ struct etor_product_packet_impl struct etor_product_packet_impl { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, - Index /*innerDim*/, Packet& res) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, + Index /*innerDim*/, Packet& res) { res = pmul(pset1(lhs.coeff(row, Index(0))), rhs.template packet(Index(0), col)); } static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run_segment(Index row, Index col, const Lhs& lhs, const Rhs& rhs, @@ -719,8 +719,8 @@ struct etor_product_packet_impl { template struct etor_product_packet_impl { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, - Index /*innerDim*/, Packet& res) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, + Index /*innerDim*/, Packet& res) { res = pmul(lhs.template packet(row, Index(0)), pset1(rhs.coeff(Index(0), col))); } static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run_segment(Index row, Index col, const Lhs& lhs, const Rhs& rhs, @@ -901,7 +901,7 @@ struct diagonal_product_evaluator_base : evaluator_base { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index idx) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar coeff(Index idx) const { if (AsScalarProduct) return m_diagImpl.coeff(0) * m_matImpl.coeff(idx); else @@ -971,9 +971,9 @@ struct product_evaluator, ProductTag, DiagonalSha static constexpr int StorageOrder = Base::StorageOrder_; using IsRowMajor_t = bool_constant; - EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr) : Base(xpr.rhs(), xpr.lhs().diagonal()) {} + EIGEN_DEVICE_FUNC constexpr explicit product_evaluator(const XprType& xpr) : Base(xpr.rhs(), xpr.lhs().diagonal()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const { return m_diagImpl.coeff(row) * m_matImpl.coeff(row, col); } @@ -1025,9 +1025,9 @@ struct product_evaluator, ProductTag, DenseShape, static constexpr int StorageOrder = Base::StorageOrder_; using IsColMajor_t = bool_constant; - EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr) : Base(xpr.lhs(), xpr.rhs().diagonal()) {} + EIGEN_DEVICE_FUNC constexpr explicit product_evaluator(const XprType& xpr) : Base(xpr.lhs(), xpr.rhs().diagonal()) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const { return m_matImpl.coeff(row, col) * m_diagImpl.coeff(col); } diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 7111604a1..fefb4c908 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -101,7 +101,7 @@ struct redux_novec_unroller { typedef typename Evaluator::Scalar Scalar; - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func& func) { + EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func& func) { return func(redux_novec_unroller::run(eval, func), redux_novec_unroller::run(eval, func)); } @@ -114,7 +114,7 @@ struct redux_novec_unroller { typedef typename Evaluator::Scalar Scalar; - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func&) { + EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func&) { return eval.coeffByOuterInner(outer, inner); } }; @@ -125,7 +125,7 @@ struct redux_novec_unroller { template struct redux_novec_unroller { typedef typename Evaluator::Scalar Scalar; - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Evaluator&, const Func&) { return Scalar(); } + EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Scalar run(const Evaluator&, const Func&) { return Scalar(); } }; template @@ -134,7 +134,7 @@ struct redux_novec_linear_unroller { typedef typename Evaluator::Scalar Scalar; - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func& func) { + EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func& func) { return func(redux_novec_linear_unroller::run(eval, func), redux_novec_linear_unroller::run(eval, func)); } @@ -144,7 +144,7 @@ template struct redux_novec_linear_unroller { typedef typename Evaluator::Scalar Scalar; - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func&) { + EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval, const Func&) { return eval.coeff(Start); } }; @@ -155,7 +155,7 @@ struct redux_novec_linear_unroller { template struct redux_novec_linear_unroller { typedef typename Evaluator::Scalar Scalar; - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Evaluator&, const Func&) { return Scalar(); } + EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Scalar run(const Evaluator&, const Func&) { return Scalar(); } }; /*** vectorization ***/ diff --git a/Eigen/src/Core/Ref.h b/Eigen/src/Core/Ref.h index a2dc50489..c8454620d 100644 --- a/Eigen/src/Core/Ref.h +++ b/Eigen/src/Core/Ref.h @@ -265,7 +265,7 @@ class Ref : public RefBase > { private: typedef internal::traits Traits; template - EIGEN_DEVICE_FUNC inline Ref( + EIGEN_DEVICE_FUNC constexpr inline Ref( const PlainObjectBase& expr, std::enable_if_t::MatchAtCompileTime), Derived>* = 0); @@ -275,7 +275,7 @@ class Ref : public RefBase > { #ifndef EIGEN_PARSED_BY_DOXYGEN template - EIGEN_DEVICE_FUNC inline Ref( + EIGEN_DEVICE_FUNC constexpr inline Ref( PlainObjectBase& expr, std::enable_if_t::MatchAtCompileTime), Derived>* = 0) { EIGEN_STATIC_ASSERT(bool(Traits::template match::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH); @@ -285,7 +285,7 @@ class Ref : public RefBase > { eigen_assert(success); } template - EIGEN_DEVICE_FUNC inline Ref( + EIGEN_DEVICE_FUNC constexpr inline Ref( const DenseBase& expr, std::enable_if_t::MatchAtCompileTime), Derived>* = 0) #else @@ -327,8 +327,9 @@ class Ref EIGEN_DENSE_PUBLIC_INTERFACE(Ref) template - EIGEN_DEVICE_FUNC inline Ref(const DenseBase& expr, - std::enable_if_t::ScalarTypeMatch), Derived>* = 0) { + EIGEN_DEVICE_FUNC constexpr inline Ref( + const DenseBase& expr, + std::enable_if_t::ScalarTypeMatch), Derived>* = 0) { // std::cout << match_helper::HasDirectAccess << "," << match_helper::OuterStrideMatch << "," // << match_helper::InnerStrideMatch << "\n"; std::cout << int(StrideType::OuterStrideAtCompileTime) // << " - " << int(Derived::OuterStrideAtCompileTime) << "\n"; std::cout << @@ -338,11 +339,11 @@ class Ref construct(expr.derived(), typename Traits::template match::type()); } - EIGEN_DEVICE_FUNC inline Ref(const Ref& other) : Base(other) { + EIGEN_DEVICE_FUNC constexpr inline Ref(const Ref& other) : Base(other) { // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy } - EIGEN_DEVICE_FUNC inline Ref(Ref&& other) { + EIGEN_DEVICE_FUNC constexpr inline Ref(Ref&& other) { if (other.data() == other.m_object.data()) { m_object = std::move(other.m_object); Base::construct(m_object); @@ -351,7 +352,7 @@ class Ref } template - EIGEN_DEVICE_FUNC inline Ref(const RefBase& other) { + EIGEN_DEVICE_FUNC constexpr inline Ref(const RefBase& other) { EIGEN_STATIC_ASSERT(Traits::template match::type::value || may_map_m_object_successfully, STORAGE_LAYOUT_DOES_NOT_MATCH); construct(other.derived(), typename Traits::template match::type()); diff --git a/Eigen/src/Core/Replicate.h b/Eigen/src/Core/Replicate.h index 30a17db67..9bdc725c7 100644 --- a/Eigen/src/Core/Replicate.h +++ b/Eigen/src/Core/Replicate.h @@ -71,7 +71,7 @@ class Replicate : public internal::dense_xpr_base NestedExpression; template - EIGEN_DEVICE_FUNC inline explicit Replicate(const OriginalMatrixType& matrix) + EIGEN_DEVICE_FUNC constexpr inline explicit Replicate(const OriginalMatrixType& matrix) : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor) { EIGEN_STATIC_ASSERT((internal::is_same, OriginalMatrixType>::value), THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) @@ -79,7 +79,7 @@ class Replicate : public internal::dense_xpr_base - EIGEN_DEVICE_FUNC inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor) + EIGEN_DEVICE_FUNC constexpr inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor) : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor) { EIGEN_STATIC_ASSERT((internal::is_same, OriginalMatrixType>::value), THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) @@ -88,7 +88,7 @@ class Replicate : public internal::dense_xpr_base public: typedef Impl Base; EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ReshapedImpl) - EIGEN_DEVICE_FUNC inline ReshapedImpl(XprType& xpr) : Impl(xpr) {} - EIGEN_DEVICE_FUNC inline ReshapedImpl(XprType& xpr, Index reshapeRows, Index reshapeCols) + EIGEN_DEVICE_FUNC constexpr inline ReshapedImpl(XprType& xpr) : Impl(xpr) {} + EIGEN_DEVICE_FUNC constexpr inline ReshapedImpl(XprType& xpr, Index reshapeRows, Index reshapeCols) : Impl(xpr, reshapeRows, reshapeCols) {} }; @@ -161,15 +161,15 @@ class ReshapedImpl_dense /** Fixed-size constructor */ - EIGEN_DEVICE_FUNC inline ReshapedImpl_dense(XprType& xpr) : m_xpr(xpr), m_rows(Rows), m_cols(Cols) {} + EIGEN_DEVICE_FUNC constexpr inline ReshapedImpl_dense(XprType& xpr) : m_xpr(xpr), m_rows(Rows), m_cols(Cols) {} /** Dynamic-size constructor */ - EIGEN_DEVICE_FUNC inline ReshapedImpl_dense(XprType& xpr, Index nRows, Index nCols) + EIGEN_DEVICE_FUNC constexpr inline ReshapedImpl_dense(XprType& xpr, Index nRows, Index nCols) : m_xpr(xpr), m_rows(nRows), m_cols(nCols) {} - EIGEN_DEVICE_FUNC Index rows() const { return m_rows; } - EIGEN_DEVICE_FUNC Index cols() const { return m_cols; } + EIGEN_DEVICE_FUNC constexpr Index rows() const { return m_rows; } + EIGEN_DEVICE_FUNC constexpr Index cols() const { return m_cols; } #ifdef EIGEN_PARSED_BY_DOXYGEN /** \sa MapBase::data() */ @@ -179,10 +179,10 @@ class ReshapedImpl_dense #endif /** \returns the nested expression */ - EIGEN_DEVICE_FUNC const internal::remove_all_t& nestedExpression() const { return m_xpr; } + EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t& nestedExpression() const { return m_xpr; } /** \returns the nested expression */ - EIGEN_DEVICE_FUNC std::remove_reference_t& nestedExpression() { return m_xpr; } + EIGEN_DEVICE_FUNC constexpr std::remove_reference_t& nestedExpression() { return m_xpr; } protected: MatrixTypeNested m_xpr; @@ -203,16 +203,16 @@ class ReshapedImpl_dense : public MapBase& nestedExpression() const { return m_xpr; } + EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t& nestedExpression() const { return m_xpr; } - EIGEN_DEVICE_FUNC XprType& nestedExpression() { return m_xpr; } + EIGEN_DEVICE_FUNC constexpr XprType& nestedExpression() { return m_xpr; } /** \sa MapBase::innerStride() */ EIGEN_DEVICE_FUNC constexpr Index innerStride() const { return m_xpr.innerStride(); } @@ -265,7 +265,7 @@ struct evaluator > Alignment = evaluator::Alignment }; typedef reshaped_evaluator reshaped_evaluator_type; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : reshaped_evaluator_type(xpr) { + EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : reshaped_evaluator_type(xpr) { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } }; @@ -283,7 +283,8 @@ struct reshaped_evaluator RowCol; - EIGEN_DEVICE_FUNC inline RowCol index_remap(Index rowId, Index colId) const { + EIGEN_DEVICE_FUNC constexpr inline RowCol index_remap(Index rowId, Index colId) const { if (Order == ColMajor) { const Index nth_elem_idx = colId * m_xpr.rows() + rowId; return RowCol(nth_elem_idx % m_xpr.nestedExpression().rows(), nth_elem_idx / m_xpr.nestedExpression().rows()); @@ -302,34 +303,34 @@ struct reshaped_evaluator XprType; typedef typename XprType::Scalar Scalar; - EIGEN_DEVICE_FUNC explicit reshaped_evaluator(const XprType& xpr) + EIGEN_DEVICE_FUNC constexpr explicit reshaped_evaluator(const XprType& xpr) : mapbase_evaluator(xpr) { // TODO: for the 3.4 release, this should be turned to an internal assertion, but let's keep it as is for the beta // lifetime diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h index d11ba1670..a4af8d115 100644 --- a/Eigen/src/Core/Reverse.h +++ b/Eigen/src/Core/Reverse.h @@ -83,7 +83,7 @@ class Reverse : public internal::dense_xpr_base > typedef internal::reverse_packet_cond reverse_packet; public: - EIGEN_DEVICE_FUNC explicit inline Reverse(const MatrixType& matrix) : m_matrix(matrix) {} + EIGEN_DEVICE_FUNC constexpr explicit inline Reverse(const MatrixType& matrix) : m_matrix(matrix) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Reverse) @@ -92,7 +92,7 @@ class Reverse : public internal::dense_xpr_base > EIGEN_DEVICE_FUNC inline Index innerStride() const { return -m_matrix.innerStride(); } - EIGEN_DEVICE_FUNC const internal::remove_all_t& nestedExpression() const { + EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t& nestedExpression() const { return m_matrix; } diff --git a/Eigen/src/Core/Select.h b/Eigen/src/Core/Select.h index 61a67c2f7..6ad290f23 100644 --- a/Eigen/src/Core/Select.h +++ b/Eigen/src/Core/Select.h @@ -45,7 +45,7 @@ using Select = CwiseTernaryOp template -inline EIGEN_DEVICE_FUNC CwiseTernaryOp< +inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp< internal::scalar_boolean_select_op::Scalar, typename DenseBase::Scalar, typename DenseBase::Scalar>, ThenDerived, ElseDerived, Derived> @@ -59,7 +59,7 @@ DenseBase::select(const DenseBase& thenMatrix, const Dense */ template template -inline EIGEN_DEVICE_FUNC CwiseTernaryOp< +inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp< internal::scalar_boolean_select_op::Scalar, typename DenseBase::Scalar, typename DenseBase::Scalar>, ThenDerived, typename DenseBase::ConstantReturnType, Derived> @@ -76,7 +76,7 @@ DenseBase::select(const DenseBase& thenMatrix, */ template template -inline EIGEN_DEVICE_FUNC CwiseTernaryOp< +inline EIGEN_DEVICE_FUNC constexpr CwiseTernaryOp< internal::scalar_boolean_select_op::Scalar, typename DenseBase::Scalar, typename DenseBase::Scalar>, typename DenseBase::ConstantReturnType, ElseDerived, Derived> diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index b8c9e75d6..62d072946 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -302,7 +302,7 @@ class triangular_dense_assignment_kernel template -EIGEN_DEVICE_FUNC typename MatrixBase::template ConstSelfAdjointViewReturnType::Type +EIGEN_DEVICE_FUNC constexpr typename MatrixBase::template ConstSelfAdjointViewReturnType::Type MatrixBase::selfadjointView() const { return typename ConstSelfAdjointViewReturnType::Type(derived()); } @@ -319,7 +319,7 @@ MatrixBase::selfadjointView() const { */ template template -EIGEN_DEVICE_FUNC typename MatrixBase::template SelfAdjointViewReturnType::Type +EIGEN_DEVICE_FUNC constexpr typename MatrixBase::template SelfAdjointViewReturnType::Type MatrixBase::selfadjointView() { return typename SelfAdjointViewReturnType::Type(derived()); } diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index 1bc03737e..a887ad2ce 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -16,7 +16,7 @@ namespace Eigen { template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) { using ConstantExpr = typename internal::plain_constant_type::type; using Op = internal::mul_assign_op; internal::call_assignment(derived(), ConstantExpr(rows(), cols(), other), Op()); @@ -25,13 +25,13 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(co template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const RealScalar& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const RealScalar& other) { realView() *= other; return derived(); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) { using ConstantExpr = typename internal::plain_constant_type::type; using Op = internal::div_assign_op; internal::call_assignment(derived(), ConstantExpr(rows(), cols(), other), Op()); @@ -40,7 +40,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(co template template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const RealScalar& other) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const RealScalar& other) { realView() /= other; return derived(); } diff --git a/Eigen/src/Core/SkewSymmetricMatrix3.h b/Eigen/src/Core/SkewSymmetricMatrix3.h index a2bd9c47c..a6ad1437a 100644 --- a/Eigen/src/Core/SkewSymmetricMatrix3.h +++ b/Eigen/src/Core/SkewSymmetricMatrix3.h @@ -308,7 +308,7 @@ class SkewSymmetricWrapper : public SkewSymmetricBase -EIGEN_DEVICE_FUNC inline const SkewSymmetricWrapper MatrixBase::asSkewSymmetric() const { +EIGEN_DEVICE_FUNC constexpr const SkewSymmetricWrapper MatrixBase::asSkewSymmetric() const { return SkewSymmetricWrapper(derived()); } diff --git a/Eigen/src/Core/Solve.h b/Eigen/src/Core/Solve.h index aa5141000..030b93460 100644 --- a/Eigen/src/Core/Solve.h +++ b/Eigen/src/Core/Solve.h @@ -69,8 +69,8 @@ class Solve : public SolveImpl eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); } /** Constructor allowing to pass the strides at runtime */ - EIGEN_DEVICE_FUNC Stride(Index outerStride, Index innerStride) : m_outer(outerStride), m_inner(innerStride) {} + EIGEN_DEVICE_FUNC constexpr Stride(Index outerStride, Index innerStride) + : m_outer(outerStride), m_inner(innerStride) {} /** Copy constructor */ - EIGEN_DEVICE_FUNC Stride(const Stride& other) : m_outer(other.outer()), m_inner(other.inner()) {} + EIGEN_DEVICE_FUNC constexpr Stride(const Stride& other) : m_outer(other.outer()), m_inner(other.inner()) {} /** Copy assignment operator */ - EIGEN_DEVICE_FUNC Stride& operator=(const Stride& other) { + EIGEN_DEVICE_FUNC constexpr Stride& operator=(const Stride& other) { m_outer.setValue(other.outer()); m_inner.setValue(other.inner()); return *this; @@ -94,8 +95,8 @@ class InnerStride : public Stride<0, Value> { typedef Stride<0, Value> Base; public: - EIGEN_DEVICE_FUNC InnerStride() : Base() {} - EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code + EIGEN_DEVICE_FUNC constexpr InnerStride() : Base() {} + EIGEN_DEVICE_FUNC constexpr InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code }; /** \brief Convenience specialization of Stride to specify only an outer stride @@ -105,8 +106,8 @@ class OuterStride : public Stride { typedef Stride Base; public: - EIGEN_DEVICE_FUNC OuterStride() : Base() {} - EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v, 0) {} // FIXME making this explicit could break valid code + EIGEN_DEVICE_FUNC constexpr OuterStride() : Base() {} + EIGEN_DEVICE_FUNC constexpr OuterStride(Index v) : Base(v, 0) {} // FIXME making this explicit could break valid code }; } // end namespace Eigen diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 5d419b19f..6dc571ea6 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -36,9 +36,10 @@ class generic_dense_assignment_kernel Functor; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, - const SrcEvaluatorTypeT &src, - const Functor &func, DstXprType &dstExpr) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, + const SrcEvaluatorTypeT &src, + const Functor &func, + DstXprType &dstExpr) : Base(dst, src, func, dstExpr) {} template diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index c69efc14a..2077c925d 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -61,7 +61,7 @@ class Transpose : public TransposeImpl NestedExpression; - EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Transpose(MatrixType& matrix) : m_matrix(matrix) {} + EIGEN_DEVICE_FUNC constexpr explicit EIGEN_STRONG_INLINE Transpose(MatrixType& matrix) : m_matrix(matrix) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose) @@ -69,12 +69,13 @@ class Transpose : public TransposeImpl& nestedExpression() const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const internal::remove_all_t& nestedExpression() + const { return m_matrix; } /** \returns the nested expression */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::remove_reference_t& nestedExpression() { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE std::remove_reference_t& nestedExpression() { return m_matrix; } @@ -114,8 +115,12 @@ class TransposeImpl : public internal::TransposeImpl_base) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(TransposeImpl) - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index innerStride() const { return derived().nestedExpression().innerStride(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outerStride() const { return derived().nestedExpression().outerStride(); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index innerStride() const { + return derived().nestedExpression().innerStride(); + } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index outerStride() const { + return derived().nestedExpression().outerStride(); + } typedef std::conditional_t::value, Scalar, const Scalar> ScalarWithConstIfNotLvalue; @@ -190,7 +195,7 @@ DenseBase::transpose() const { * * \sa adjointInPlace(), transpose(), conjugate(), class Transpose, class internal::scalar_conjugate_op */ template -EIGEN_DEVICE_FUNC inline const typename MatrixBase::AdjointReturnType MatrixBase::adjoint() const { +EIGEN_DEVICE_FUNC constexpr const typename MatrixBase::AdjointReturnType MatrixBase::adjoint() const { return AdjointReturnType(this->transpose()); } diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 76da9e983..e219e51e3 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -568,7 +568,7 @@ EIGEN_DEVICE_FUNC void TriangularBase::evalTo(MatrixBase& */ template template -EIGEN_DEVICE_FUNC typename MatrixBase::template TriangularViewReturnType::Type +EIGEN_DEVICE_FUNC constexpr typename MatrixBase::template TriangularViewReturnType::Type MatrixBase::triangularView() { return typename TriangularViewReturnType::Type(derived()); } @@ -576,7 +576,7 @@ MatrixBase::triangularView() { /** This is the const version of MatrixBase::triangularView() */ template template -EIGEN_DEVICE_FUNC typename MatrixBase::template ConstTriangularViewReturnType::Type +EIGEN_DEVICE_FUNC constexpr typename MatrixBase::template ConstTriangularViewReturnType::Type MatrixBase::triangularView() const { return typename ConstTriangularViewReturnType::Type(derived()); } diff --git a/Eigen/src/Core/VectorBlock.h b/Eigen/src/Core/VectorBlock.h index 5ac13eb8e..1277e26f7 100644 --- a/Eigen/src/Core/VectorBlock.h +++ b/Eigen/src/Core/VectorBlock.h @@ -68,13 +68,13 @@ class VectorBlock : public Block::Flags /** Dynamic-size constructor */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE VectorBlock(VectorType& vector, Index start, Index size) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE VectorBlock(VectorType& vector, Index start, Index size) : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start, IsColVector ? size : 1, IsColVector ? 1 : size) { } /** Fixed-size constructor */ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE VectorBlock(VectorType& vector, Index start) + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE VectorBlock(VectorType& vector, Index start) : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start) {} }; diff --git a/Eigen/src/Core/functors/AssignmentFunctors.h b/Eigen/src/Core/functors/AssignmentFunctors.h index c8f1e4161..8f7ad13e9 100644 --- a/Eigen/src/Core/functors/AssignmentFunctors.h +++ b/Eigen/src/Core/functors/AssignmentFunctors.h @@ -138,7 +138,7 @@ struct functor_traits> : div_assign_op struct swap_assign_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void assignCoeff(Scalar& a, const Scalar& b) const { #ifdef EIGEN_GPUCC // FIXME: check whether cuda::swap exists. Scalar t = b; diff --git a/Eigen/src/Core/functors/BinaryFunctors.h b/Eigen/src/Core/functors/BinaryFunctors.h index 1be48992d..bbaab1192 100644 --- a/Eigen/src/Core/functors/BinaryFunctors.h +++ b/Eigen/src/Core/functors/BinaryFunctors.h @@ -36,7 +36,7 @@ struct scalar_sum_op : binary_op_base { #ifdef EIGEN_SCALAR_BINARY_OP_PLUGIN scalar_sum_op(){EIGEN_SCALAR_BINARY_OP_PLUGIN} #endif - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a + b; } @@ -60,7 +60,8 @@ struct functor_traits> { }; template <> -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool scalar_sum_op::operator()(const bool& a, const bool& b) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool scalar_sum_op::operator()(const bool& a, + const bool& b) const { return a || b; } @@ -75,7 +76,7 @@ struct scalar_product_op : binary_op_base { #ifdef EIGEN_SCALAR_BINARY_OP_PLUGIN scalar_product_op(){EIGEN_SCALAR_BINARY_OP_PLUGIN} #endif - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a * b; } @@ -99,8 +100,8 @@ struct functor_traits> { }; template <> -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool scalar_product_op::operator()(const bool& a, - const bool& b) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool scalar_product_op::operator()(const bool& a, + const bool& b) const { return a && b; } @@ -116,7 +117,7 @@ struct scalar_conj_product_op : binary_op_base { typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return conj_helper().pmul(a, b); } @@ -141,7 +142,7 @@ struct functor_traits> { template struct scalar_min_op : binary_op_base { typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return internal::pmin(a, b); } template @@ -170,7 +171,7 @@ struct functor_traits> { template struct scalar_max_op : binary_op_base { typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return internal::pmax(a, b); } template @@ -210,7 +211,7 @@ struct functor_traits struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a == b ? result_type(1) : result_type(0); } template @@ -223,7 +224,7 @@ struct scalar_cmp_op : binary template struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a < b ? result_type(1) : result_type(0); } template @@ -236,7 +237,7 @@ struct scalar_cmp_op : binary template struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a <= b ? result_type(1) : result_type(0); } template @@ -249,7 +250,7 @@ struct scalar_cmp_op : binary template struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a > b ? result_type(1) : result_type(0); } template @@ -262,7 +263,7 @@ struct scalar_cmp_op : binary template struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a >= b ? result_type(1) : result_type(0); } template @@ -275,7 +276,7 @@ struct scalar_cmp_op : binary template struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return !(a <= b || b <= a) ? result_type(1) : result_type(0); } template @@ -288,7 +289,7 @@ struct scalar_cmp_op : bin template struct scalar_cmp_op : binary_op_base { using result_type = std::conditional_t; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a != b ? result_type(1) : result_type(0); } template @@ -305,7 +306,7 @@ struct scalar_cmp_op : binar */ template struct scalar_hypot_op : binary_op_base { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& x, const Scalar& y) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& x, const Scalar& y) const { // This functor is used by hypotNorm only for which it is faster to first apply abs // on all coefficients prior to reduction through hypot. // This way we avoid calling abs on positive and real entries, and this also permits @@ -337,7 +338,7 @@ struct scalar_pow_op : binary_op_base { } #endif - EIGEN_DEVICE_FUNC inline result_type operator()(const Scalar& a, const Exponent& b) const { + EIGEN_DEVICE_FUNC constexpr inline result_type operator()(const Scalar& a, const Exponent& b) const { return numext::pow(a, b); } @@ -368,7 +369,7 @@ struct scalar_difference_op : binary_op_base { #ifdef EIGEN_SCALAR_BINARY_OP_PLUGIN scalar_difference_op(){EIGEN_SCALAR_BINARY_OP_PLUGIN} #endif - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a - b; } @@ -388,13 +389,13 @@ struct functor_traits> { template ::type>::IsInteger> struct maybe_raise_div_by_zero { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Packet x) { EIGEN_UNUSED_VARIABLE(x); } + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void run(Packet x) { EIGEN_UNUSED_VARIABLE(x); } }; #ifndef EIGEN_GPU_COMPILE_PHASE template struct maybe_raise_div_by_zero { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Packet x) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void run(Packet x) { if (EIGEN_PREDICT_FALSE(predux_any(pcmp_eq(x, pzero(x))))) { // Use volatile variables to force a division by zero, which will // result in the default platform behaviour (usually SIGFPE). @@ -417,7 +418,7 @@ struct scalar_quotient_op : binary_op_base { #ifdef EIGEN_SCALAR_BINARY_OP_PLUGIN scalar_quotient_op(){EIGEN_SCALAR_BINARY_OP_PLUGIN} #endif - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return a / b; } @@ -446,7 +447,7 @@ struct scalar_boolean_and_op { using result_type = Scalar; // `false` any value `a` that satisfies `a == Scalar(0)` // `true` is the complement of `false` - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { return (a != Scalar(0)) && (b != Scalar(0)) ? Scalar(1) : Scalar(0); } template @@ -474,7 +475,7 @@ struct scalar_boolean_or_op { using result_type = Scalar; // `false` any value `a` that satisfies `a == Scalar(0)` // `true` is the complement of `false` - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { return (a != Scalar(0)) || (b != Scalar(0)) ? Scalar(1) : Scalar(0); } template @@ -501,7 +502,7 @@ struct scalar_boolean_xor_op { using result_type = Scalar; // `false` any value `a` that satisfies `a == Scalar(0)` // `true` is the complement of `false` - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { return (a != Scalar(0)) != (b != Scalar(0)) ? Scalar(1) : Scalar(0); } template @@ -523,19 +524,19 @@ template ::IsComplex> struct bitwise_binary_impl { static constexpr size_t Size = sizeof(Scalar); using uint_t = typename numext::get_integer_by_size::unsigned_type; - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_and(const Scalar& a, const Scalar& b) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_and(const Scalar& a, const Scalar& b) { uint_t a_as_uint = numext::bit_cast(a); uint_t b_as_uint = numext::bit_cast(b); uint_t result = a_as_uint & b_as_uint; return numext::bit_cast(result); } - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_or(const Scalar& a, const Scalar& b) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_or(const Scalar& a, const Scalar& b) { uint_t a_as_uint = numext::bit_cast(a); uint_t b_as_uint = numext::bit_cast(b); uint_t result = a_as_uint | b_as_uint; return numext::bit_cast(result); } - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_xor(const Scalar& a, const Scalar& b) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_xor(const Scalar& a, const Scalar& b) { uint_t a_as_uint = numext::bit_cast(a); uint_t b_as_uint = numext::bit_cast(b); uint_t result = a_as_uint ^ b_as_uint; @@ -546,17 +547,17 @@ struct bitwise_binary_impl { template struct bitwise_binary_impl { using Real = typename NumTraits::Real; - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_and(const Scalar& a, const Scalar& b) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_and(const Scalar& a, const Scalar& b) { Real real_result = bitwise_binary_impl::run_and(numext::real(a), numext::real(b)); Real imag_result = bitwise_binary_impl::run_and(numext::imag(a), numext::imag(b)); return Scalar(real_result, imag_result); } - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_or(const Scalar& a, const Scalar& b) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_or(const Scalar& a, const Scalar& b) { Real real_result = bitwise_binary_impl::run_or(numext::real(a), numext::real(b)); Real imag_result = bitwise_binary_impl::run_or(numext::imag(a), numext::imag(b)); return Scalar(real_result, imag_result); } - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_xor(const Scalar& a, const Scalar& b) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_xor(const Scalar& a, const Scalar& b) { Real real_result = bitwise_binary_impl::run_xor(numext::real(a), numext::real(b)); Real imag_result = bitwise_binary_impl::run_xor(numext::imag(a), numext::imag(b)); return Scalar(real_result, imag_result); @@ -574,7 +575,7 @@ struct scalar_bitwise_and_op { BITWISE OPERATIONS MAY ONLY BE PERFORMED ON PLAIN DATA TYPES) EIGEN_STATIC_ASSERT((!internal::is_same::value), DONT USE BITWISE OPS ON BOOLEAN TYPES) using result_type = Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { return bitwise_binary_impl::run_and(a, b); } template @@ -598,7 +599,7 @@ struct scalar_bitwise_or_op { BITWISE OPERATIONS MAY ONLY BE PERFORMED ON PLAIN DATA TYPES) EIGEN_STATIC_ASSERT((!internal::is_same::value), DONT USE BITWISE OPS ON BOOLEAN TYPES) using result_type = Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { return bitwise_binary_impl::run_or(a, b); } template @@ -622,7 +623,7 @@ struct scalar_bitwise_xor_op { BITWISE OPERATIONS MAY ONLY BE PERFORMED ON PLAIN DATA TYPES) EIGEN_STATIC_ASSERT((!internal::is_same::value), DONT USE BITWISE OPS ON BOOLEAN TYPES) using result_type = Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a, const Scalar& b) const { return bitwise_binary_impl::run_xor(a, b); } template @@ -646,7 +647,7 @@ struct scalar_absolute_difference_op : binary_op_base { #ifdef EIGEN_SCALAR_BINARY_OP_PLUGIN scalar_absolute_difference_op(){EIGEN_SCALAR_BINARY_OP_PLUGIN} #endif - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const LhsScalar& a, const RhsScalar& b) const { return numext::absdiff(a, b); } @@ -671,7 +672,7 @@ struct scalar_atan2_op { is_same::value && !NumTraits::IsInteger && !NumTraits::IsComplex; EIGEN_STATIC_ASSERT(Enable, "LhsScalar and RhsScalar must be the same non-integer, non-complex type") - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& y, const Scalar& x) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& y, const Scalar& x) const { return numext::atan2(y, x); } template @@ -702,9 +703,9 @@ struct bind1st_op : BinaryOp { typedef typename BinaryOp::second_argument_type second_argument_type; typedef typename BinaryOp::result_type result_type; - EIGEN_DEVICE_FUNC explicit bind1st_op(const first_argument_type& val) : m_value(val) {} + EIGEN_DEVICE_FUNC constexpr explicit bind1st_op(const first_argument_type& val) : m_value(val) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const second_argument_type& b) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const second_argument_type& b) const { return BinaryOp::operator()(m_value, b); } @@ -724,9 +725,9 @@ struct bind2nd_op : BinaryOp { typedef typename BinaryOp::second_argument_type second_argument_type; typedef typename BinaryOp::result_type result_type; - EIGEN_DEVICE_FUNC explicit bind2nd_op(const second_argument_type& val) : m_value(val) {} + EIGEN_DEVICE_FUNC constexpr explicit bind2nd_op(const second_argument_type& val) : m_value(val) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const first_argument_type& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const first_argument_type& a) const { return BinaryOp::operator()(a, m_value); } diff --git a/Eigen/src/Core/functors/NullaryFunctors.h b/Eigen/src/Core/functors/NullaryFunctors.h index dc394d625..d8fc78a6c 100644 --- a/Eigen/src/Core/functors/NullaryFunctors.h +++ b/Eigen/src/Core/functors/NullaryFunctors.h @@ -19,8 +19,8 @@ namespace internal { template struct scalar_constant_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()() const { return m_other; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()() const { return m_other; } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetOp() const { return internal::pset1(m_other); @@ -39,7 +39,7 @@ struct functor_traits> { template struct scalar_zero_op { EIGEN_DEVICE_FUNC scalar_zero_op() = default; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()() const { return Scalar(0); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()() const { return Scalar(0); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetOp() const { return internal::pzero(PacketType()); @@ -51,7 +51,7 @@ struct functor_traits> : functor_traits struct scalar_identity_op { template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(IndexType row, IndexType col) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(IndexType row, IndexType col) const { return row == col ? Scalar(1) : Scalar(0); } }; @@ -67,7 +67,7 @@ template struct linspaced_op_impl { typedef typename NumTraits::Real RealScalar; - EIGEN_DEVICE_FUNC linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) + EIGEN_DEVICE_FUNC constexpr linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) : m_low(low), m_high(high), m_size1(num_steps == 1 ? 1 : num_steps - 1), @@ -75,7 +75,7 @@ struct linspaced_op_impl { m_flip(numext::abs(high) < numext::abs(low)) {} template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { if (m_flip) return (i == 0) ? m_low : Scalar(m_high - RealScalar(m_size1 - i) * m_step); else @@ -111,7 +111,7 @@ struct linspaced_op_impl { template struct linspaced_op_impl { - EIGEN_DEVICE_FUNC linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) + EIGEN_DEVICE_FUNC constexpr linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) : m_low(low), m_multiplier((high - low) / convert_index(num_steps <= 1 ? 1 : num_steps - 1)), m_divisor(convert_index((high >= low ? num_steps : -num_steps) + (high - low)) / @@ -119,7 +119,7 @@ struct linspaced_op_impl { m_use_divisor(num_steps > 1 && (numext::abs(high - low) + 1) < num_steps) {} template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { if (m_use_divisor) return m_low + convert_index(i) / m_divisor; else @@ -151,11 +151,11 @@ struct functor_traits> { }; template struct linspaced_op { - EIGEN_DEVICE_FUNC linspaced_op(const Scalar& low, const Scalar& high, Index num_steps) + EIGEN_DEVICE_FUNC constexpr linspaced_op(const Scalar& low, const Scalar& high, Index num_steps) : impl((num_steps == 1 ? high : low), high, num_steps) {} template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { return impl(i); } @@ -173,9 +173,9 @@ template struct equalspaced_op { typedef typename NumTraits::Real RealScalar; - EIGEN_DEVICE_FUNC equalspaced_op(const Scalar& start, const Scalar& step) : m_start(start), m_step(step) {} + EIGEN_DEVICE_FUNC constexpr equalspaced_op(const Scalar& start, const Scalar& step) : m_start(start), m_step(step) {} template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(IndexType i) const { return m_start + m_step * static_cast(i); } template diff --git a/Eigen/src/Core/functors/TernaryFunctors.h b/Eigen/src/Core/functors/TernaryFunctors.h index 82095f1d2..9a4ea48a6 100644 --- a/Eigen/src/Core/functors/TernaryFunctors.h +++ b/Eigen/src/Core/functors/TernaryFunctors.h @@ -26,8 +26,8 @@ struct scalar_boolean_select_op { EIGEN_STATIC_ASSERT(ThenElseAreSame, THEN AND ELSE MUST BE SAME TYPE) using Scalar = ThenScalar; using result_type = Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const ThenScalar& a, const ElseScalar& b, - const ConditionScalar& cond) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const ThenScalar& a, const ElseScalar& b, + const ConditionScalar& cond) const { return cond == ConditionScalar(0) ? b : a; } template diff --git a/Eigen/src/Core/functors/UnaryFunctors.h b/Eigen/src/Core/functors/UnaryFunctors.h index 996d9154c..99cda3d1e 100644 --- a/Eigen/src/Core/functors/UnaryFunctors.h +++ b/Eigen/src/Core/functors/UnaryFunctors.h @@ -24,7 +24,7 @@ namespace internal { */ template struct scalar_opposite_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::negate(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::negate(a); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return internal::pnegate(a); @@ -43,7 +43,9 @@ struct functor_traits> { template struct scalar_abs_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { return numext::abs(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { + return numext::abs(a); + } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return internal::pabs(a); @@ -71,7 +73,7 @@ template struct abs_knowing_score { typedef typename NumTraits::Real result_type; template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a, const Score&) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a, const Score&) const { return numext::abs(a); } }; @@ -79,7 +81,7 @@ template struct abs_knowing_score::Score_is_abs> { typedef typename NumTraits::Real result_type; template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scal&, const result_type& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scal&, const result_type& a) const { return a; } }; @@ -92,7 +94,9 @@ struct abs_knowing_score::Score_i template struct scalar_abs2_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { return numext::abs2(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { + return numext::abs2(a); + } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return internal::pmul(a, a); @@ -113,7 +117,7 @@ struct functor_traits> { */ template struct scalar_conjugate_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::conj(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::conj(a); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return internal::pconj(a); @@ -143,7 +147,9 @@ struct functor_traits> { template struct scalar_arg_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { return numext::arg(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { + return numext::arg(a); + } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return internal::parg(a); @@ -165,7 +171,9 @@ struct functor_traits> { template struct scalar_carg_op { using result_type = Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return Scalar(numext::arg(a)); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + return Scalar(numext::arg(a)); + } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return pcarg(a); @@ -185,7 +193,9 @@ struct functor_traits> { template struct scalar_cast_op { typedef NewType result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NewType operator()(const Scalar& a) const { return cast(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE NewType operator()(const Scalar& a) const { + return cast(a); + } }; template @@ -218,7 +228,7 @@ struct functor_traits> { */ template struct scalar_shift_right_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::arithmetic_shift_right(a); } template @@ -238,7 +248,7 @@ struct functor_traits> { */ template struct scalar_shift_left_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::logical_shift_left(a); } template @@ -259,7 +269,9 @@ struct functor_traits> { template struct scalar_real_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { return numext::real(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { + return numext::real(a); + } }; template struct functor_traits> { @@ -274,7 +286,9 @@ struct functor_traits> { template struct scalar_imag_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { return numext::imag(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { + return numext::imag(a); + } }; template struct functor_traits> { @@ -289,10 +303,12 @@ struct functor_traits> { template struct scalar_real_ref_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type& operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const result_type& operator()(const Scalar& a) const { + return numext::real_ref(a); + } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type& operator()(Scalar& a) const { return numext::real_ref(a); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type& operator()(Scalar& a) const { return numext::real_ref(a); } }; template struct functor_traits> { @@ -307,8 +323,10 @@ struct functor_traits> { template struct scalar_imag_ref_op { typedef typename NumTraits::Real result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type& operator()(Scalar& a) const { return numext::imag_ref(a); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type& operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type& operator()(Scalar& a) const { + return numext::imag_ref(a); + } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const result_type& operator()(const Scalar& a) const { return numext::imag_ref(a); } }; @@ -325,7 +343,7 @@ struct functor_traits> { */ template struct scalar_exp_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return internal::pexp(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return internal::pexp(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexp(a); @@ -357,7 +375,7 @@ struct functor_traits> { template struct scalar_exp2_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return internal::pexp2(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return internal::pexp2(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexp2(a); @@ -379,7 +397,7 @@ struct functor_traits> { */ template struct scalar_expm1_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::expm1(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::expm1(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexpm1(a); @@ -401,7 +419,7 @@ struct functor_traits> { */ template struct scalar_log_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::log(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::log(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog(a); @@ -433,7 +451,7 @@ struct functor_traits> { */ template struct scalar_log1p_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::log1p(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::log1p(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog1p(a); @@ -455,7 +473,9 @@ struct functor_traits> { */ template struct scalar_log10_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { EIGEN_USING_STD(log10) return log10(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { + EIGEN_USING_STD(log10) return log10(a); + } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog10(a); @@ -475,7 +495,7 @@ struct functor_traits> { template struct scalar_log2_op { using RealScalar = typename NumTraits::Real; - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return Scalar(RealScalar(EIGEN_LOG2E)) * numext::log(a); } template @@ -494,7 +514,7 @@ struct functor_traits> { */ template struct scalar_sqrt_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::sqrt(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::sqrt(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); @@ -536,7 +556,7 @@ struct functor_traits> { */ template struct scalar_cbrt_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::cbrt(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::cbrt(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcbrt(a); @@ -554,7 +574,7 @@ struct functor_traits> { */ template struct scalar_rsqrt_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::rsqrt(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::rsqrt(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::prsqrt(a); @@ -572,7 +592,7 @@ struct functor_traits> { */ template struct scalar_cos_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::cos(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::cos(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcos(a); @@ -589,7 +609,7 @@ struct functor_traits> { */ template struct scalar_sin_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::sin(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::sin(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psin(a); @@ -606,7 +626,7 @@ struct functor_traits> { */ template struct scalar_tan_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::tan(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::tan(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::ptan(a); @@ -623,7 +643,7 @@ struct functor_traits> { */ template struct scalar_acos_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::acos(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::acos(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pacos(a); @@ -640,7 +660,7 @@ struct functor_traits> { */ template struct scalar_asin_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::asin(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::asin(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pasin(a); @@ -657,7 +677,7 @@ struct functor_traits> { */ template struct scalar_atan_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::atan(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::atan(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::patan(a); @@ -674,7 +694,7 @@ struct functor_traits> { */ template struct scalar_tanh_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::tanh(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::tanh(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& x) const { return ptanh(x); @@ -709,7 +729,7 @@ struct functor_traits> { */ template struct scalar_atanh_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::atanh(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::atanh(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& x) const { return patanh(x); @@ -727,7 +747,7 @@ struct functor_traits> { */ template struct scalar_sinh_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::sinh(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::sinh(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psinh(a); @@ -744,7 +764,7 @@ struct functor_traits> { */ template struct scalar_asinh_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::asinh(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::asinh(a); } }; template @@ -758,7 +778,7 @@ struct functor_traits> { */ template struct scalar_cosh_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::cosh(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::cosh(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcosh(a); @@ -775,7 +795,7 @@ struct functor_traits> { */ template struct scalar_acosh_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::acosh(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::acosh(a); } }; template @@ -789,7 +809,7 @@ struct functor_traits> { */ template struct scalar_inverse_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return Scalar(1) / a; } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return Scalar(1) / a; } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::preciprocal(a); @@ -813,7 +833,7 @@ struct functor_traits> { */ template struct scalar_square_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return a * a; } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return a * a; } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pmul(a, a); @@ -844,7 +864,7 @@ struct functor_traits> { */ template struct scalar_cube_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return a * a * a; } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return a * a * a; } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pmul(a, pmul(a, a)); @@ -875,7 +895,7 @@ struct functor_traits> { */ template struct scalar_round_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::round(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::round(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pround(a); @@ -895,7 +915,7 @@ struct functor_traits> { */ template struct scalar_floor_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::floor(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::floor(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pfloor(a); @@ -915,7 +935,7 @@ struct functor_traits> { */ template struct scalar_rint_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::rint(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::rint(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::print(a); @@ -935,7 +955,7 @@ struct functor_traits> { */ template struct scalar_ceil_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::ceil(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::ceil(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pceil(a); @@ -955,7 +975,7 @@ struct functor_traits> { */ template struct scalar_trunc_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::trunc(a); } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return numext::trunc(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::ptrunc(a); @@ -975,7 +995,7 @@ struct functor_traits> { */ template struct scalar_isnan_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool operator()(const Scalar& a) const { #if defined(SYCL_DEVICE_ONLY) return numext::isnan(a); #else @@ -986,7 +1006,7 @@ struct scalar_isnan_op { template struct scalar_isnan_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { #if defined(SYCL_DEVICE_ONLY) return (numext::isnan(a) ? ptrue(a) : pzero(a)); #else @@ -1010,7 +1030,7 @@ struct functor_traits> { */ template struct scalar_isinf_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool operator()(const Scalar& a) const { #if defined(SYCL_DEVICE_ONLY) return numext::isinf(a); #else @@ -1021,7 +1041,7 @@ struct scalar_isinf_op { template struct scalar_isinf_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { #if defined(SYCL_DEVICE_ONLY) return (numext::isinf(a) ? ptrue(a) : pzero(a)); #else @@ -1044,7 +1064,7 @@ struct functor_traits> { */ template struct scalar_isfinite_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool operator()(const Scalar& a) const { #if defined(SYCL_DEVICE_ONLY) return numext::isfinite(a); #else @@ -1055,7 +1075,7 @@ struct scalar_isfinite_op { template struct scalar_isfinite_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { #if defined(SYCL_DEVICE_ONLY) return (numext::isfinite(a) ? ptrue(a) : pzero(a)); #else @@ -1083,7 +1103,7 @@ struct scalar_boolean_not_op { using result_type = Scalar; // `false` any value `a` that satisfies `a == Scalar(0)` // `true` is the complement of `false` - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return a == Scalar(0) ? Scalar(1) : Scalar(0); } template @@ -1102,7 +1122,7 @@ template ::IsComplex> struct bitwise_unary_impl { static constexpr size_t Size = sizeof(Scalar); using uint_t = typename numext::get_integer_by_size::unsigned_type; - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_not(const Scalar& a) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_not(const Scalar& a) { uint_t a_as_uint = numext::bit_cast(a); uint_t result = ~a_as_uint; return numext::bit_cast(result); @@ -1112,7 +1132,7 @@ struct bitwise_unary_impl { template struct bitwise_unary_impl { using Real = typename NumTraits::Real; - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_not(const Scalar& a) { + static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar run_not(const Scalar& a) { Real real_result = bitwise_unary_impl::run_not(numext::real(a)); Real imag_result = bitwise_unary_impl::run_not(numext::imag(a)); return Scalar(real_result, imag_result); @@ -1130,7 +1150,7 @@ struct scalar_bitwise_not_op { BITWISE OPERATIONS MAY ONLY BE PERFORMED ON PLAIN DATA TYPES) EIGEN_STATIC_ASSERT((!internal::is_same::value), DONT USE BITWISE OPS ON BOOLEAN TYPES) using result_type = Scalar; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return bitwise_unary_impl::run_not(a); } template @@ -1149,7 +1169,7 @@ struct functor_traits> { */ template struct scalar_sign_op { - EIGEN_DEVICE_FUNC inline Scalar operator()(const Scalar& a) const { return numext::sign(a); } + EIGEN_DEVICE_FUNC constexpr inline Scalar operator()(const Scalar& a) const { return numext::sign(a); } template EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { @@ -1184,7 +1204,7 @@ struct scalar_logistic_op_impl { // Complex-valud implementation. template struct scalar_logistic_op_impl::IsComplex>> { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(const T& x) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE T operator()(const T& x) const { const T e = numext::exp(x); return (numext::isinf)(numext::real(e)) ? T(1) : e / (e + T(1)); } @@ -1311,8 +1331,9 @@ struct scalar_unary_pow_op { internal::has_ReturnType>::value>::type PromotedExponent; typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_unary_pow_op(const ExponentScalar& exponent) : m_exponent(exponent) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE scalar_unary_pow_op(const ExponentScalar& exponent) + : m_exponent(exponent) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const { EIGEN_USING_STD(pow); return static_cast(pow(a, m_exponent)); } @@ -1350,7 +1371,7 @@ struct scalar_unary_pow_op { check_is_representable(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { EIGEN_USING_STD(pow); return static_cast(pow(a, m_exponent)); } @@ -1366,9 +1387,10 @@ struct scalar_unary_pow_op { template struct scalar_unary_pow_op { - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_unary_pow_op(const ExponentScalar& exponent) : m_exponent(exponent) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE scalar_unary_pow_op(const ExponentScalar& exponent) + : m_exponent(exponent) {} // TODO: error handling logic for complex^real_integer - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const { return unary_pow_impl::run(a, m_exponent); } template diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index 19d9917d7..2e1ca91b2 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -43,12 +43,12 @@ struct general_matrix_vector_product; template struct get_factor { - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE To run(const From& x) { return To(x); } + EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE To run(const From& x) { return To(x); } }; template struct get_factor::Real> { - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE typename NumTraits::Real run(const Scalar& x) { + EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE typename NumTraits::Real run(const Scalar& x) { return numext::real(x); } }; @@ -56,9 +56,9 @@ struct get_factor::Real> { template class BlasVectorMapper { public: - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BlasVectorMapper(Scalar* data) : m_data(data) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE BlasVectorMapper(Scalar* data) : m_data(data) {} - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar operator()(Index i) const { return m_data[i]; } + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE Scalar operator()(Index i) const { return m_data[i]; } template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet load(Index i) const { return ploadt(m_data + i); @@ -79,14 +79,14 @@ class BlasLinearMapper; template class BlasLinearMapper { public: - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BlasLinearMapper(Scalar* data, Index incr = 1) : m_data(data) { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE BlasLinearMapper(Scalar* data, Index incr = 1) : m_data(data) { EIGEN_ONLY_USED_FOR_DEBUG(incr); eigen_assert(incr == 1); } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void prefetch(Index i) const { internal::prefetch(&operator()(i)); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar& operator()(Index i) const { return m_data[i]; } + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE Scalar& operator()(Index i) const { return m_data[i]; } template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE PacketType loadPacket(Index i) const { @@ -178,27 +178,27 @@ class blas_data_mapper { typedef blas_data_mapper SubMapper; typedef BlasVectorMapper VectorMapper; - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE blas_data_mapper(Scalar* data, Index stride, Index incr = 1) + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE blas_data_mapper(Scalar* data, Index stride, Index incr = 1) : m_data(data), m_stride(stride) { EIGEN_ONLY_USED_FOR_DEBUG(incr); eigen_assert(incr == 1); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE SubMapper getSubMapper(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE SubMapper getSubMapper(Index i, Index j) const { return SubMapper(&operator()(i, j), m_stride); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE LinearMapper getLinearMapper(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE LinearMapper getLinearMapper(Index i, Index j) const { return LinearMapper(&operator()(i, j)); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE VectorMapper getVectorMapper(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE VectorMapper getVectorMapper(Index i, Index j) const { return VectorMapper(&operator()(i, j)); } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void prefetch(Index i, Index j) const { internal::prefetch(&operator()(i, j)); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar& operator()(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE Scalar& operator()(Index i, Index j) const { return m_data[StorageOrder == RowMajor ? j + i * m_stride : i + j * m_stride]; } @@ -239,8 +239,8 @@ class blas_data_mapper { return pgather(&operator()(i, j), m_stride); } - EIGEN_DEVICE_FUNC const Index stride() const { return m_stride; } - EIGEN_DEVICE_FUNC const Index incr() const { return 1; } + EIGEN_DEVICE_FUNC constexpr const Index stride() const { return m_stride; } + EIGEN_DEVICE_FUNC constexpr const Index incr() const { return 1; } EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_data; } EIGEN_DEVICE_FUNC Index firstAligned(Index size) const { @@ -268,11 +268,14 @@ class blas_data_mapper { template class BlasLinearMapper { public: - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BlasLinearMapper(Scalar* data, Index incr) : m_data(data), m_incr(incr) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE BlasLinearMapper(Scalar* data, Index incr) + : m_data(data), m_incr(incr) {} EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void prefetch(int i) const { internal::prefetch(&operator()(i)); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar& operator()(Index i) const { return m_data[i * m_incr.value()]; } + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE Scalar& operator()(Index i) const { + return m_data[i * m_incr.value()]; + } template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE PacketType loadPacket(Index i) const { @@ -306,20 +309,20 @@ class blas_data_mapper { typedef BlasLinearMapper LinearMapper; typedef blas_data_mapper SubMapper; - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE blas_data_mapper(Scalar* data, Index stride, Index incr) + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE blas_data_mapper(Scalar* data, Index stride, Index incr) : m_data(data), m_stride(stride), m_incr(incr) {} - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE SubMapper getSubMapper(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE SubMapper getSubMapper(Index i, Index j) const { return SubMapper(&operator()(i, j), m_stride, m_incr.value()); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE LinearMapper getLinearMapper(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE LinearMapper getLinearMapper(Index i, Index j) const { return LinearMapper(&operator()(i, j), m_incr.value()); } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void prefetch(Index i, Index j) const { internal::prefetch(&operator()(i, j)); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar& operator()(Index i, Index j) const { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE Scalar& operator()(Index i, Index j) const { return m_data[StorageOrder == RowMajor ? j * m_incr.value() + i * m_stride : i * m_incr.value() + j * m_stride]; } @@ -428,8 +431,8 @@ class blas_data_mapper { spb.store(this, i, j, block); } - EIGEN_DEVICE_FUNC const Index stride() const { return m_stride; } - EIGEN_DEVICE_FUNC const Index incr() const { return m_incr.value(); } + EIGEN_DEVICE_FUNC constexpr const Index stride() const { return m_stride; } + EIGEN_DEVICE_FUNC constexpr const Index incr() const { return m_incr.value(); } EIGEN_DEVICE_FUNC constexpr Scalar* data() const { return m_data; } protected: @@ -567,18 +570,18 @@ struct blas_traits : blas_traits {}; template ::HasUsableDirectAccess> struct extract_data_selector { - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static const typename T::Scalar* run(const T& m) { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE static const typename T::Scalar* run(const T& m) { return blas_traits::extract(m).data(); } }; template struct extract_data_selector { - EIGEN_DEVICE_FUNC static typename T::Scalar* run(const T&) { return 0; } + EIGEN_DEVICE_FUNC constexpr static typename T::Scalar* run(const T&) { return 0; } }; template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const typename T::Scalar* extract_data(const T& m) { +EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE const typename T::Scalar* extract_data(const T& m) { return extract_data_selector::run(m); } @@ -588,30 +591,31 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const typename T::Scalar* extract_data(con */ template struct combine_scalar_factors_impl { - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static ResScalar run(const Lhs& lhs, const Rhs& rhs) { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE static ResScalar run(const Lhs& lhs, const Rhs& rhs) { return blas_traits::extractScalarFactor(lhs) * blas_traits::extractScalarFactor(rhs); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static ResScalar run(const ResScalar& alpha, const Lhs& lhs, const Rhs& rhs) { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE static ResScalar run(const ResScalar& alpha, const Lhs& lhs, + const Rhs& rhs) { return alpha * blas_traits::extractScalarFactor(lhs) * blas_traits::extractScalarFactor(rhs); } }; template struct combine_scalar_factors_impl { - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static bool run(const Lhs& lhs, const Rhs& rhs) { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE static bool run(const Lhs& lhs, const Rhs& rhs) { return blas_traits::extractScalarFactor(lhs) && blas_traits::extractScalarFactor(rhs); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static bool run(const bool& alpha, const Lhs& lhs, const Rhs& rhs) { + EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE static bool run(const bool& alpha, const Lhs& lhs, const Rhs& rhs) { return alpha && blas_traits::extractScalarFactor(lhs) && blas_traits::extractScalarFactor(rhs); } }; template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const ResScalar& alpha, const Lhs& lhs, - const Rhs& rhs) { +EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const ResScalar& alpha, const Lhs& lhs, + const Rhs& rhs) { return combine_scalar_factors_impl::run(alpha, lhs, rhs); } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const Lhs& lhs, const Rhs& rhs) { +EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE ResScalar combine_scalar_factors(const Lhs& lhs, const Rhs& rhs) { return combine_scalar_factors_impl::run(lhs, rhs); } diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 8aba62b75..f7e8b70c4 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -22,21 +22,21 @@ namespace Eigen { * * Changing the value of Dynamic breaks the ABI, as Dynamic is often used as a template parameter for Matrix. */ -const int Dynamic = -1; +constexpr int Dynamic = -1; /** This value means that a signed quantity (e.g., a signed index) is not known at compile-time, and that instead its * value has to be specified at runtime. */ -const int DynamicIndex = 0xffffff; +constexpr int DynamicIndex = 0xffffff; /** This value means that the requested value is not defined. */ -const int Undefined = 0xfffffe; +constexpr int Undefined = 0xfffffe; /** This value means +Infinity; it is currently used only as the p parameter to MatrixBase::lpNorm(). * The value Infinity there means the L-infinity norm. */ -const int Infinity = -1; +constexpr int Infinity = -1; /** This value means that the cost to evaluate an expression coefficient is either very expensive or * cannot be known at compile time. @@ -45,7 +45,7 @@ const int Infinity = -1; * and very very expensive expressions. It thus must also be large enough to make sure unrolling won't happen and that * sub expressions will be evaluated, but not too large to avoid overflow. */ -const int HugeCost = 10000; +constexpr int HugeCost = 10000; /** \defgroup flags Flags * \ingroup Core_Module @@ -67,16 +67,16 @@ const int HugeCost = 10000; * For an expression, this determines the storage order of * the matrix created by evaluation of that expression. * \sa \blank \ref TopicStorageOrders */ -const unsigned int RowMajorBit = 0x1; +constexpr unsigned int RowMajorBit = 0x1; /** \ingroup flags * means the expression should be evaluated by the calling expression */ -const unsigned int EvalBeforeNestingBit = 0x2; +constexpr unsigned int EvalBeforeNestingBit = 0x2; /** \ingroup flags * \deprecated * means the expression should be evaluated before any assignment */ -EIGEN_DEPRECATED const unsigned int EvalBeforeAssigningBit = 0x4; // FIXME deprecated +EIGEN_DEPRECATED constexpr unsigned int EvalBeforeAssigningBit = 0x4; // FIXME deprecated /** \ingroup flags * @@ -94,7 +94,7 @@ EIGEN_DEPRECATED const unsigned int EvalBeforeAssigningBit = 0x4; // FIXME depr * \note This bit can be set regardless of whether vectorization is actually enabled. * To check for actual vectorizability, see \a ActualPacketAccessBit. */ -const unsigned int PacketAccessBit = 0x8; +constexpr unsigned int PacketAccessBit = 0x8; #ifdef EIGEN_VECTORIZE /** \ingroup flags @@ -105,9 +105,9 @@ const unsigned int PacketAccessBit = 0x8; * If vectorization is not enabled (EIGEN_VECTORIZE is not defined) this constant * is set to the value 0. */ -const unsigned int ActualPacketAccessBit = PacketAccessBit; +constexpr unsigned int ActualPacketAccessBit = PacketAccessBit; #else -const unsigned int ActualPacketAccessBit = 0x0; +constexpr unsigned int ActualPacketAccessBit = 0x0; #endif /** \ingroup flags @@ -130,7 +130,7 @@ const unsigned int ActualPacketAccessBit = 0x0; * Product is a vector expression. Thus, vector Product expressions allow index-based coefficient access but * not index-based packet access, so they don't have the LinearAccessBit. */ -const unsigned int LinearAccessBit = 0x10; +constexpr unsigned int LinearAccessBit = 0x10; /** \ingroup flags * @@ -145,7 +145,7 @@ const unsigned int LinearAccessBit = 0x10; * Expressions having LvalueBit also have their coeff() method returning a const reference instead of returning a new * value. */ -const unsigned int LvalueBit = 0x20; +constexpr unsigned int LvalueBit = 0x20; /** \ingroup flags * @@ -156,7 +156,7 @@ const unsigned int LvalueBit = 0x20; * * See the comment on LvalueBit for an explanation of how LvalueBit and DirectAccessBit are mutually orthogonal. */ -const unsigned int DirectAccessBit = 0x40; +constexpr unsigned int DirectAccessBit = 0x40; /** \deprecated \ingroup flags * @@ -168,9 +168,9 @@ const unsigned int DirectAccessBit = 0x40; * expression.packet(0); * \endcode */ -EIGEN_DEPRECATED const unsigned int AlignedBit = 0x80; +EIGEN_DEPRECATED constexpr unsigned int AlignedBit = 0x80; -const unsigned int NestByRefBit = 0x100; +constexpr unsigned int NestByRefBit = 0x100; /** \ingroup flags * @@ -179,7 +179,7 @@ const unsigned int NestByRefBit = 0x100; * The precise choice will be decided at evaluation time or when * combined with other expressions. * \sa \blank \ref RowMajorBit, \ref TopicStorageOrders */ -const unsigned int NoPreferredStorageOrderBit = 0x200; +constexpr unsigned int NoPreferredStorageOrderBit = 0x200; /** \ingroup flags * @@ -192,10 +192,10 @@ const unsigned int NoPreferredStorageOrderBit = 0x200; inline const Index* innerNonZeroPtr() const; \endcode */ -const unsigned int CompressedAccessBit = 0x400; +constexpr unsigned int CompressedAccessBit = 0x400; // list of flags that are inherited by default -const unsigned int HereditaryBits = RowMajorBit | EvalBeforeNestingBit; +constexpr unsigned int HereditaryBits = RowMajorBit | EvalBeforeNestingBit; /** \defgroup enums Enumerations * \ingroup Core_Module diff --git a/Eigen/src/Core/util/IntegralConstant.h b/Eigen/src/Core/util/IntegralConstant.h index 53fabd595..f79fea88f 100644 --- a/Eigen/src/Core/util/IntegralConstant.h +++ b/Eigen/src/Core/util/IntegralConstant.h @@ -144,8 +144,8 @@ template class VariableAndFixedInt { public: static const int value = N; - operator int() const { return m_value; } - VariableAndFixedInt(int val) { m_value = val; } + constexpr operator int() const { return m_value; } + constexpr VariableAndFixedInt(int val) : m_value(val) {} protected: int m_value; @@ -172,7 +172,7 @@ struct get_fixed_value, Default> { }; template -EIGEN_DEVICE_FUNC Index get_runtime_value(const T &x) { +EIGEN_DEVICE_FUNC constexpr Index get_runtime_value(const T &x) { return x; } diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 7288cee77..8e5443087 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -1276,7 +1276,7 @@ EIGEN_DEVICE_FUNC constexpr void ignore_unused_variable(const T&) {} #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD, OPNAME) \ template \ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE( \ + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE( \ Derived, OtherDerived, OPNAME)(METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { \ return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, OPNAME)(derived(), other.derived()); \ } @@ -1297,7 +1297,7 @@ EIGEN_DEVICE_FUNC constexpr void ignore_unused_variable(const T&) {} #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD, OPNAME) \ template \ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE( \ + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE( \ Derived, \ typename internal::promote_scalar_arg::type, \ @@ -1311,7 +1311,7 @@ EIGEN_DEVICE_FUNC constexpr void ignore_unused_variable(const T&) {} #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD, OPNAME) \ template \ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE friend const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE( \ + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE friend const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE( \ typename internal::promote_scalar_arg::type, \ Derived, OPNAME)(METHOD)(const T& scalar, const StorageBaseType& matrix) { \ @@ -1356,10 +1356,10 @@ EIGEN_DEVICE_FUNC constexpr void ignore_unused_variable(const T&) {} namespace Eigen { namespace internal { -EIGEN_DEVICE_FUNC inline bool all() { return true; } +EIGEN_DEVICE_FUNC constexpr bool all() { return true; } template -EIGEN_DEVICE_FUNC bool all(T t, Ts... ts) { +EIGEN_DEVICE_FUNC constexpr bool all(T t, Ts... ts) { return t && all(ts...); } diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 1be5b5923..ececab817 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -444,14 +444,14 @@ namespace numext { #if defined(EIGEN_GPU_COMPILE_PHASE) template -EIGEN_DEVICE_FUNC void swap(T& a, T& b) { +EIGEN_DEVICE_FUNC constexpr void swap(T& a, T& b) { T tmp = b; b = a; a = tmp; } #else template -EIGEN_STRONG_INLINE void swap(T& a, T& b) { +constexpr EIGEN_STRONG_INLINE void swap(T& a, T& b) { std::swap(a, b); } #endif @@ -462,7 +462,7 @@ using std::numeric_limits; template ::IsInteger, bool XIsSigned = NumTraits::IsSigned, bool YIsInteger = NumTraits::IsInteger, bool YIsSigned = NumTraits::IsSigned> struct equal_strict_impl { - static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { return x == y; } + static constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { return x == y; } }; template struct equal_strict_impl { @@ -470,7 +470,7 @@ struct equal_strict_impl { // Y is a signed integer // if Y is non-negative, it may be represented exactly as its unsigned counterpart. using UnsignedY = typename internal::make_unsigned::type; - static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { + static constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { return y < Y(0) ? false : (x == static_cast(y)); } }; @@ -478,7 +478,7 @@ template struct equal_strict_impl { // X is a signed integer // Y is an unsigned integer - static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { + static constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { return equal_strict_impl::run(y, x); } }; @@ -486,18 +486,18 @@ struct equal_strict_impl { // The aim of the following functions is to bypass -Wfloat-equal warnings // when we really want a strict equality comparison on floating points. template -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const X& x, const Y& y) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const X& x, const Y& y) { return equal_strict_impl::run(x, y); } #if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC)) template <> -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const float& x, const float& y) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const float& x, const float& y) { return std::equal_to()(x, y); } template <> -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const double& x, const double& y) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const double& x, const double& y) { return std::equal_to()(x, y); } #endif @@ -507,7 +507,7 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const double& x, const d * Use this to to bypass -Wfloat-equal warnings when exact zero is what needs to be tested. */ template -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X& x) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X& x) { return equal_strict(x, typename NumTraits::Literal{0}); } @@ -516,23 +516,23 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X& x) { * Use this to to bypass -Wfloat-equal warnings when exact one is what needs to be tested. */ template -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_one(const X& x) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_one(const X& x) { return equal_strict(x, typename NumTraits::Literal{1}); } template -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const X& x, const Y& y) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const X& x, const Y& y) { return !equal_strict_impl::run(x, y); } #if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC)) template <> -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const float& x, const float& y) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const float& x, const float& y) { return std::not_equal_to()(x, y); } template <> -EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const double& x, const double& y) { +constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool not_equal_strict(const double& x, const double& y) { return std::not_equal_to()(x, y); } #endif @@ -543,11 +543,11 @@ namespace internal { template struct is_identically_zero_impl { - static inline bool run(const Scalar& s) { return numext::is_exactly_zero(s); } + static constexpr bool run(const Scalar& s) { return numext::is_exactly_zero(s); } }; template -EIGEN_STRONG_INLINE bool is_identically_zero(const Scalar& s) { +constexpr EIGEN_STRONG_INLINE bool is_identically_zero(const Scalar& s) { return is_identically_zero_impl::run(s); } diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 63290638b..df3d72498 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -152,7 +152,7 @@ struct promote_index_type { template class variable_if_dynamic { public: - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamic(T v) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); eigen_assert(v == T(Value)); } @@ -169,9 +169,9 @@ class variable_if_dynamic { T m_value; public: - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamic(T value = 0) noexcept : m_value(value) {} - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T value() const { return m_value; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE operator T() const { return m_value; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit variable_if_dynamic(T value = 0) noexcept : m_value(value) {} + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE T value() const { return m_value; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE operator T() const { return m_value; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T value) { m_value = value; } }; @@ -180,12 +180,12 @@ class variable_if_dynamic { template class variable_if_dynamicindex { public: - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamicindex(T v) { + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit variable_if_dynamicindex(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); eigen_assert(v == T(Value)); } EIGEN_DEVICE_FUNC static constexpr T value() { return T(Value); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T) {} + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void setValue(T) {} }; template @@ -194,8 +194,8 @@ class variable_if_dynamicindex { EIGEN_DEVICE_FUNC variable_if_dynamicindex() { eigen_assert(false); } public: - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamicindex(T value) : m_value(value) {} - EIGEN_DEVICE_FUNC T EIGEN_STRONG_INLINE value() const { return m_value; } + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit variable_if_dynamicindex(T value) : m_value(value) {} + EIGEN_DEVICE_FUNC constexpr T EIGEN_STRONG_INLINE value() const { return m_value; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T value) { m_value = value; } }; diff --git a/Eigen/src/plugins/ArrayCwiseBinaryOps.inc b/Eigen/src/plugins/ArrayCwiseBinaryOps.inc index c7922c29c..ae240f13c 100644 --- a/Eigen/src/plugins/ArrayCwiseBinaryOps.inc +++ b/Eigen/src/plugins/ArrayCwiseBinaryOps.inc @@ -4,8 +4,8 @@ * \sa MatrixBase::cwiseProduct */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product) operator*( - const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product) +operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product)(derived(), other.derived()); } @@ -14,7 +14,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Deriv * \sa MatrixBase::cwiseQuotient */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp< +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_quotient_op, const Derived, const OtherDerived> operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { return CwiseBinaryOp, const Derived, @@ -29,7 +29,7 @@ operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { * \sa max() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> #ifdef EIGEN_PARSED_BY_DOXYGEN min @@ -46,7 +46,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa max() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const CwiseNullaryOp, PlainObject> > #ifdef EIGEN_PARSED_BY_DOXYGEN @@ -66,7 +66,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa min() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> #ifdef EIGEN_PARSED_BY_DOXYGEN max @@ -83,7 +83,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa min() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const CwiseNullaryOp, PlainObject> > #ifdef EIGEN_PARSED_BY_DOXYGEN @@ -105,7 +105,7 @@ EIGEN_MAKE_CWISE_BINARY_OP(absolute_difference, absolute_difference) * * \sa absolute_difference() */ -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const CwiseNullaryOp, PlainObject> > #ifdef EIGEN_PARSED_BY_DOXYGEN @@ -136,7 +136,7 @@ EIGEN_MAKE_CWISE_BINARY_OP(atan2, atan2) // TODO: code generating macros could be moved to Macros.h and could include generation of documentation #define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \ template \ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const \ + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const \ CwiseBinaryOp, \ const Derived, const OtherDerived> \ OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { \ @@ -149,24 +149,24 @@ EIGEN_MAKE_CWISE_BINARY_OP(atan2, atan2) typedef CwiseBinaryOp, \ const CwiseNullaryOp, PlainObject>, const Derived> \ RCmp##COMPARATOR##ReturnType; \ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp##COMPARATOR##ReturnType OP(const Scalar &s) const { \ + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Cmp##COMPARATOR##ReturnType OP(const Scalar &s) const { \ return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \ } \ - EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp##COMPARATOR##ReturnType OP( \ + EIGEN_DEVICE_FUNC constexpr friend EIGEN_STRONG_INLINE const RCmp##COMPARATOR##ReturnType OP( \ const Scalar &s, const EIGEN_CURRENT_STORAGE_BASE_CLASS &d) { \ return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \ } #define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \ template \ - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const \ + EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const \ CwiseBinaryOp, \ const OtherDerived, const Derived> \ OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { \ return CwiseBinaryOp, \ const OtherDerived, const Derived>(other.derived(), derived()); \ } \ - EIGEN_DEVICE_FUNC inline const RCmp##RCOMPARATOR##ReturnType OP(const Scalar &s) const { \ + EIGEN_DEVICE_FUNC constexpr inline const RCmp##RCOMPARATOR##ReturnType OP(const Scalar &s) const { \ return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \ } \ friend inline const Cmp##RCOMPARATOR##ReturnType OP(const Scalar &s, const Derived &d) { \ diff --git a/Eigen/src/plugins/ArrayCwiseUnaryOps.inc b/Eigen/src/plugins/ArrayCwiseUnaryOps.inc index 753aeb4fb..c06dc418d 100644 --- a/Eigen/src/plugins/ArrayCwiseUnaryOps.inc +++ b/Eigen/src/plugins/ArrayCwiseUnaryOps.inc @@ -49,7 +49,7 @@ typedef CwiseUnaryOp, const Derived> * * \sa Math functions, abs2() */ -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const { return AbsReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const AbsReturnType abs() const { return AbsReturnType(derived()); } /** \returns an expression of the coefficient-wise phase angle of \c *this * @@ -58,9 +58,9 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const { return A * * \sa abs() */ -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const { return ArgReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const ArgReturnType arg() const { return ArgReturnType(derived()); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CArgReturnType carg() const { return CArgReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CArgReturnType carg() const { return CArgReturnType(derived()); } /** \returns an expression of the coefficient-wise squared absolute value of \c *this * @@ -69,7 +69,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CArgReturnType carg() const { return * * \sa Math functions, abs(), square() */ -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const { return Abs2ReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const { return Abs2ReturnType(derived()); } /** \returns an expression of the coefficient-wise exponential of *this. * @@ -82,7 +82,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const { return * \sa Math functions, exp2(), pow(), log(), sin(), * cos() */ -EIGEN_DEVICE_FUNC inline const ExpReturnType exp() const { return ExpReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const ExpReturnType exp() const { return ExpReturnType(derived()); } /** \returns an expression of the coefficient-wise exponential of *this. * @@ -91,7 +91,7 @@ EIGEN_DEVICE_FUNC inline const ExpReturnType exp() const { return ExpReturnType( * \sa Math functions, exp(), pow(), log(), sin(), * cos() */ -EIGEN_DEVICE_FUNC inline const Exp2ReturnType exp2() const { return Exp2ReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const Exp2ReturnType exp2() const { return Exp2ReturnType(derived()); } /** \returns an expression of the coefficient-wise exponential of *this minus 1. * @@ -100,7 +100,7 @@ EIGEN_DEVICE_FUNC inline const Exp2ReturnType exp2() const { return Exp2ReturnTy * * \sa Math functions, exp() */ -EIGEN_DEVICE_FUNC inline const Expm1ReturnType expm1() const { return Expm1ReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const Expm1ReturnType expm1() const { return Expm1ReturnType(derived()); } /** \returns an expression of the coefficient-wise logarithm of *this. * @@ -112,7 +112,7 @@ EIGEN_DEVICE_FUNC inline const Expm1ReturnType expm1() const { return Expm1Retur * * \sa Math functions, log() */ -EIGEN_DEVICE_FUNC inline const LogReturnType log() const { return LogReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const LogReturnType log() const { return LogReturnType(derived()); } /** \returns an expression of the coefficient-wise logarithm of 1 plus \c *this. * @@ -121,7 +121,7 @@ EIGEN_DEVICE_FUNC inline const LogReturnType log() const { return LogReturnType( * * \sa Math functions, log() */ -EIGEN_DEVICE_FUNC inline const Log1pReturnType log1p() const { return Log1pReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const Log1pReturnType log1p() const { return Log1pReturnType(derived()); } /** \returns an expression of the coefficient-wise base-10 logarithm of *this. * @@ -132,14 +132,14 @@ EIGEN_DEVICE_FUNC inline const Log1pReturnType log1p() const { return Log1pRetur * * \sa Math functions, log() */ -EIGEN_DEVICE_FUNC inline const Log10ReturnType log10() const { return Log10ReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const Log10ReturnType log10() const { return Log10ReturnType(derived()); } /** \returns an expression of the coefficient-wise base-2 logarithm of *this. * * This function computes the coefficient-wise base-2 logarithm. * */ -EIGEN_DEVICE_FUNC inline const Log2ReturnType log2() const { return Log2ReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const Log2ReturnType log2() const { return Log2ReturnType(derived()); } /** \returns an expression of the coefficient-wise square root of *this. * @@ -151,7 +151,7 @@ EIGEN_DEVICE_FUNC inline const Log2ReturnType log2() const { return Log2ReturnTy * * \sa Math functions, pow(), square(), cbrt() */ -EIGEN_DEVICE_FUNC inline const SqrtReturnType sqrt() const { return SqrtReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const SqrtReturnType sqrt() const { return SqrtReturnType(derived()); } /** \returns an expression of the coefficient-wise cube root of *this. * @@ -162,7 +162,7 @@ EIGEN_DEVICE_FUNC inline const SqrtReturnType sqrt() const { return SqrtReturnTy * * \sa Math functions, sqrt(), pow(), square() */ -EIGEN_DEVICE_FUNC inline const CbrtReturnType cbrt() const { return CbrtReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CbrtReturnType cbrt() const { return CbrtReturnType(derived()); } /** \returns an expression of the coefficient-wise inverse square root of *this. * @@ -173,7 +173,7 @@ EIGEN_DEVICE_FUNC inline const CbrtReturnType cbrt() const { return CbrtReturnTy * * \sa pow(), square() */ -EIGEN_DEVICE_FUNC inline const RsqrtReturnType rsqrt() const { return RsqrtReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const RsqrtReturnType rsqrt() const { return RsqrtReturnType(derived()); } /** \returns an expression of the coefficient-wise signum of *this. * @@ -184,7 +184,7 @@ EIGEN_DEVICE_FUNC inline const RsqrtReturnType rsqrt() const { return RsqrtRetur * * \sa pow(), square() */ -EIGEN_DEVICE_FUNC inline const SignReturnType sign() const { return SignReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const SignReturnType sign() const { return SignReturnType(derived()); } /** \returns an expression of the coefficient-wise cosine of *this. * @@ -196,7 +196,7 @@ EIGEN_DEVICE_FUNC inline const SignReturnType sign() const { return SignReturnTy * * \sa Math functions, sin(), acos() */ -EIGEN_DEVICE_FUNC inline const CosReturnType cos() const { return CosReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CosReturnType cos() const { return CosReturnType(derived()); } /** \returns an expression of the coefficient-wise sine of *this. * @@ -208,7 +208,7 @@ EIGEN_DEVICE_FUNC inline const CosReturnType cos() const { return CosReturnType( * * \sa Math functions, cos(), asin() */ -EIGEN_DEVICE_FUNC inline const SinReturnType sin() const { return SinReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const SinReturnType sin() const { return SinReturnType(derived()); } /** \returns an expression of the coefficient-wise tan of *this. * @@ -217,7 +217,7 @@ EIGEN_DEVICE_FUNC inline const SinReturnType sin() const { return SinReturnType( * * \sa Math functions, cos(), sin() */ -EIGEN_DEVICE_FUNC inline const TanReturnType tan() const { return TanReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const TanReturnType tan() const { return TanReturnType(derived()); } /** \returns an expression of the coefficient-wise arc tan of *this. * @@ -226,7 +226,7 @@ EIGEN_DEVICE_FUNC inline const TanReturnType tan() const { return TanReturnType( * * \sa Math functions, tan(), asin(), acos() */ -EIGEN_DEVICE_FUNC inline const AtanReturnType atan() const { return AtanReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const AtanReturnType atan() const { return AtanReturnType(derived()); } /** \returns an expression of the coefficient-wise arc cosine of *this. * @@ -235,7 +235,7 @@ EIGEN_DEVICE_FUNC inline const AtanReturnType atan() const { return AtanReturnTy * * \sa Math functions, cos(), asin() */ -EIGEN_DEVICE_FUNC inline const AcosReturnType acos() const { return AcosReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const AcosReturnType acos() const { return AcosReturnType(derived()); } /** \returns an expression of the coefficient-wise arc sine of *this. * @@ -244,7 +244,7 @@ EIGEN_DEVICE_FUNC inline const AcosReturnType acos() const { return AcosReturnTy * * \sa Math functions, sin(), acos() */ -EIGEN_DEVICE_FUNC inline const AsinReturnType asin() const { return AsinReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const AsinReturnType asin() const { return AsinReturnType(derived()); } /** \returns an expression of the coefficient-wise hyperbolic tan of *this. * @@ -253,7 +253,7 @@ EIGEN_DEVICE_FUNC inline const AsinReturnType asin() const { return AsinReturnTy * * \sa Math functions, tan(), sinh(), cosh() */ -EIGEN_DEVICE_FUNC inline const TanhReturnType tanh() const { return TanhReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const TanhReturnType tanh() const { return TanhReturnType(derived()); } /** \returns an expression of the coefficient-wise hyperbolic sin of *this. * @@ -262,7 +262,7 @@ EIGEN_DEVICE_FUNC inline const TanhReturnType tanh() const { return TanhReturnTy * * \sa Math functions, sin(), tanh(), cosh() */ -EIGEN_DEVICE_FUNC inline const SinhReturnType sinh() const { return SinhReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const SinhReturnType sinh() const { return SinhReturnType(derived()); } /** \returns an expression of the coefficient-wise hyperbolic cos of *this. * @@ -271,29 +271,29 @@ EIGEN_DEVICE_FUNC inline const SinhReturnType sinh() const { return SinhReturnTy * * \sa Math functions, tanh(), sinh(), cosh() */ -EIGEN_DEVICE_FUNC inline const CoshReturnType cosh() const { return CoshReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CoshReturnType cosh() const { return CoshReturnType(derived()); } /** \returns an expression of the coefficient-wise inverse hyperbolic tan of *this. * * \sa Math functions, atanh(), asinh(), acosh() */ -EIGEN_DEVICE_FUNC inline const AtanhReturnType atanh() const { return AtanhReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const AtanhReturnType atanh() const { return AtanhReturnType(derived()); } /** \returns an expression of the coefficient-wise inverse hyperbolic sin of *this. * * \sa Math functions, atanh(), asinh(), acosh() */ -EIGEN_DEVICE_FUNC inline const AsinhReturnType asinh() const { return AsinhReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const AsinhReturnType asinh() const { return AsinhReturnType(derived()); } /** \returns an expression of the coefficient-wise inverse hyperbolic cos of *this. * * \sa Math functions, atanh(), asinh(), acosh() */ -EIGEN_DEVICE_FUNC inline const AcoshReturnType acosh() const { return AcoshReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const AcoshReturnType acosh() const { return AcoshReturnType(derived()); } /** \returns an expression of the coefficient-wise logistic of *this. */ -EIGEN_DEVICE_FUNC inline const LogisticReturnType logistic() const { return LogisticReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const LogisticReturnType logistic() const { return LogisticReturnType(derived()); } /** \returns an expression of the coefficient-wise inverse of *this. * @@ -302,7 +302,7 @@ EIGEN_DEVICE_FUNC inline const LogisticReturnType logistic() const { return Logi * * \sa operator/(), operator*() */ -EIGEN_DEVICE_FUNC inline const InverseReturnType inverse() const { return InverseReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const InverseReturnType inverse() const { return InverseReturnType(derived()); } /** \returns an expression of the coefficient-wise square of *this. * @@ -311,7 +311,7 @@ EIGEN_DEVICE_FUNC inline const InverseReturnType inverse() const { return Invers * * \sa Math functions, abs2(), cube(), pow() */ -EIGEN_DEVICE_FUNC inline const SquareReturnType square() const { return SquareReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const SquareReturnType square() const { return SquareReturnType(derived()); } /** \returns an expression of the coefficient-wise cube of *this. * @@ -320,7 +320,7 @@ EIGEN_DEVICE_FUNC inline const SquareReturnType square() const { return SquareRe * * \sa Math functions, square(), pow() */ -EIGEN_DEVICE_FUNC inline const CubeReturnType cube() const { return CubeReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CubeReturnType cube() const { return CubeReturnType(derived()); } /** \returns an expression of the coefficient-wise rint of *this. * @@ -329,7 +329,7 @@ EIGEN_DEVICE_FUNC inline const CubeReturnType cube() const { return CubeReturnTy * * \sa Math functions, ceil(), floor() */ -EIGEN_DEVICE_FUNC inline const RintReturnType rint() const { return RintReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const RintReturnType rint() const { return RintReturnType(derived()); } /** \returns an expression of the coefficient-wise round of *this. * @@ -338,7 +338,7 @@ EIGEN_DEVICE_FUNC inline const RintReturnType rint() const { return RintReturnTy * * \sa Math functions, ceil(), floor() */ -EIGEN_DEVICE_FUNC inline const RoundReturnType round() const { return RoundReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const RoundReturnType round() const { return RoundReturnType(derived()); } /** \returns an expression of the coefficient-wise floor of *this. * @@ -347,7 +347,7 @@ EIGEN_DEVICE_FUNC inline const RoundReturnType round() const { return RoundRetur * * \sa Math functions, ceil(), round() */ -EIGEN_DEVICE_FUNC inline const FloorReturnType floor() const { return FloorReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const FloorReturnType floor() const { return FloorReturnType(derived()); } /** \returns an expression of the coefficient-wise ceil of *this. * @@ -356,7 +356,7 @@ EIGEN_DEVICE_FUNC inline const FloorReturnType floor() const { return FloorRetur * * \sa Math functions, floor(), round() */ -EIGEN_DEVICE_FUNC inline const CeilReturnType ceil() const { return CeilReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CeilReturnType ceil() const { return CeilReturnType(derived()); } /** \returns an expression of the coefficient-wise truncation of *this. * @@ -365,7 +365,7 @@ EIGEN_DEVICE_FUNC inline const CeilReturnType ceil() const { return CeilReturnTy * * \sa Math functions, floor(), round() */ -EIGEN_DEVICE_FUNC inline const TruncReturnType trunc() const { return TruncReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const TruncReturnType trunc() const { return TruncReturnType(derived()); } template struct ShiftRightXpr { @@ -380,7 +380,7 @@ struct ShiftRightXpr { * \sa shiftLeft() */ template -EIGEN_DEVICE_FUNC typename ShiftRightXpr::Type shiftRight() const { +EIGEN_DEVICE_FUNC constexpr typename ShiftRightXpr::Type shiftRight() const { return typename ShiftRightXpr::Type(derived()); } @@ -397,7 +397,7 @@ struct ShiftLeftXpr { * \sa shiftRight() */ template -EIGEN_DEVICE_FUNC typename ShiftLeftXpr::Type shiftLeft() const { +EIGEN_DEVICE_FUNC constexpr typename ShiftLeftXpr::Type shiftLeft() const { return typename ShiftLeftXpr::Type(derived()); } @@ -408,7 +408,7 @@ EIGEN_DEVICE_FUNC typename ShiftLeftXpr::Type shiftLeft() const { * * \sa isfinite(), isinf() */ -EIGEN_DEVICE_FUNC inline const IsNaNReturnType isNaN() const { return IsNaNReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const IsNaNReturnType isNaN() const { return IsNaNReturnType(derived()); } /** \returns an expression of the coefficient-wise isinf of *this. * @@ -417,7 +417,7 @@ EIGEN_DEVICE_FUNC inline const IsNaNReturnType isNaN() const { return IsNaNRetur * * \sa isnan(), isfinite() */ -EIGEN_DEVICE_FUNC inline const IsInfReturnType isInf() const { return IsInfReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const IsInfReturnType isInf() const { return IsInfReturnType(derived()); } /** \returns an expression of the coefficient-wise isfinite of *this. * @@ -426,8 +426,8 @@ EIGEN_DEVICE_FUNC inline const IsInfReturnType isInf() const { return IsInfRetur * * \sa isnan(), isinf() */ -EIGEN_DEVICE_FUNC inline const IsFiniteReturnType isFinite() const { return IsFiniteReturnType(derived()); } -EIGEN_DEVICE_FUNC inline const IsFiniteTypedReturnType isFiniteTyped() const { +EIGEN_DEVICE_FUNC constexpr inline const IsFiniteReturnType isFinite() const { return IsFiniteReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const IsFiniteTypedReturnType isFiniteTyped() const { return IsFiniteTypedReturnType(derived()); } @@ -438,11 +438,15 @@ EIGEN_DEVICE_FUNC inline const IsFiniteTypedReturnType isFiniteTyped() const { * * \sa operator!=() */ -EIGEN_DEVICE_FUNC inline const BooleanNotReturnType operator!() const { return BooleanNotReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const BooleanNotReturnType operator!() const { + return BooleanNotReturnType(derived()); +} /** \returns an expression of the bitwise ~ operator of *this */ -EIGEN_DEVICE_FUNC inline const BitwiseNotReturnType operator~() const { return BitwiseNotReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const BitwiseNotReturnType operator~() const { + return BitwiseNotReturnType(derived()); +} // --- SpecialFunctions module --- @@ -462,7 +466,7 @@ typedef CwiseUnaryOp, const Derived> NdtriRetu * * \sa Math functions, digamma() */ -EIGEN_DEVICE_FUNC inline const LgammaReturnType lgamma() const { return LgammaReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const LgammaReturnType lgamma() const { return LgammaReturnType(derived()); } /** \returns an expression of the coefficient-wise digamma (psi, derivative of lgamma). * @@ -475,7 +479,7 @@ EIGEN_DEVICE_FUNC inline const LgammaReturnType lgamma() const { return LgammaRe * \sa Math functions, Eigen::digamma(), * Eigen::polygamma(), lgamma() */ -EIGEN_DEVICE_FUNC inline const DigammaReturnType digamma() const { return DigammaReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const DigammaReturnType digamma() const { return DigammaReturnType(derived()); } /** \cpp11 \returns an expression of the coefficient-wise Gauss error * function of *this. @@ -488,7 +492,7 @@ EIGEN_DEVICE_FUNC inline const DigammaReturnType digamma() const { return Digamm * * \sa Math functions, erfc() */ -EIGEN_DEVICE_FUNC inline const ErfReturnType erf() const { return ErfReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const ErfReturnType erf() const { return ErfReturnType(derived()); } /** \cpp11 \returns an expression of the coefficient-wise Complementary error * function of *this. @@ -501,7 +505,7 @@ EIGEN_DEVICE_FUNC inline const ErfReturnType erf() const { return ErfReturnType( * * \sa Math functions, erf() */ -EIGEN_DEVICE_FUNC inline const ErfcReturnType erfc() const { return ErfcReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const ErfcReturnType erfc() const { return ErfcReturnType(derived()); } /** \returns an expression of the coefficient-wise inverse of the CDF of the Normal distribution function * function of *this. @@ -516,7 +520,7 @@ EIGEN_DEVICE_FUNC inline const ErfcReturnType erfc() const { return ErfcReturnTy * * \sa Math functions */ -EIGEN_DEVICE_FUNC inline const NdtriReturnType ndtri() const { return NdtriReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const NdtriReturnType ndtri() const { return NdtriReturnType(derived()); } template using UnaryPowReturnType = @@ -538,7 +542,7 @@ using UnaryPowReturnType = * \sa ArrayBase::pow(ArrayBase), square(), cube(), exp(), log() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryPowReturnType pow( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const UnaryPowReturnType pow( const ScalarExponent& exponent) const { return UnaryPowReturnType(derived(), internal::scalar_unary_pow_op(exponent)); } diff --git a/Eigen/src/plugins/BlockMethods.inc b/Eigen/src/plugins/BlockMethods.inc index da2ac3f29..57e347e6e 100644 --- a/Eigen/src/plugins/BlockMethods.inc +++ b/Eigen/src/plugins/BlockMethods.inc @@ -111,7 +111,7 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa class Block, fix, fix(int) /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -128,7 +128,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of block(Index,Index,NRowsType,NColsType) template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -163,7 +163,7 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -181,7 +181,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of topRightCorner(NRowsType, NColsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -213,13 +213,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa class Block, block(Index,Index) /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topRightCorner() { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topRightCorner() { return typename FixedBlockXpr::Type(derived(), 0, cols() - CCols); } /// This is the const version of topRightCorner(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topRightCorner() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topRightCorner() + const { return typename ConstFixedBlockXpr::Type(derived(), 0, cols() - CCols); } @@ -243,14 +244,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topRightCorner(Index cRows, - Index cCols) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topRightCorner(Index cRows, + Index cCols) { return typename FixedBlockXpr::Type(derived(), 0, cols() - cCols, cRows, cCols); } /// This is the const version of topRightCorner(Index, Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topRightCorner( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topRightCorner( Index cRows, Index cCols) const { return typename ConstFixedBlockXpr::Type(derived(), 0, cols() - cCols, cRows, cCols); } @@ -274,7 +275,7 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -290,7 +291,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of topLeftCorner(Index, Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -318,13 +319,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topLeftCorner() { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topLeftCorner() { return typename FixedBlockXpr::Type(derived(), 0, 0); } /// This is the const version of topLeftCorner(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topLeftCorner() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topLeftCorner() + const { return typename ConstFixedBlockXpr::Type(derived(), 0, 0); } @@ -348,14 +350,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topLeftCorner(Index cRows, - Index cCols) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type topLeftCorner(Index cRows, + Index cCols) { return typename FixedBlockXpr::Type(derived(), 0, 0, cRows, cCols); } /// This is the const version of topLeftCorner(Index, Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topLeftCorner( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type topLeftCorner( Index cRows, Index cCols) const { return typename ConstFixedBlockXpr::Type(derived(), 0, 0, cRows, cCols); } @@ -379,7 +381,7 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -395,7 +397,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of bottomRightCorner(NRowsType, NColsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -423,13 +425,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type bottomRightCorner() { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type bottomRightCorner() { return typename FixedBlockXpr::Type(derived(), rows() - CRows, cols() - CCols); } /// This is the const version of bottomRightCorner(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type bottomRightCorner() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type +bottomRightCorner() const { return typename ConstFixedBlockXpr::Type(derived(), rows() - CRows, cols() - CCols); } @@ -453,14 +456,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type bottomRightCorner(Index cRows, - Index cCols) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type bottomRightCorner( + Index cRows, Index cCols) { return typename FixedBlockXpr::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols); } /// This is the const version of bottomRightCorner(Index, Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type bottomRightCorner( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type bottomRightCorner( Index cRows, Index cCols) const { return typename ConstFixedBlockXpr::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols); } @@ -484,7 +487,7 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -503,7 +506,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of bottomLeftCorner(NRowsType, NColsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename ConstFixedBlockXpr::value, internal::get_fixed_value::value>::Type @@ -530,13 +533,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type bottomLeftCorner() { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type bottomLeftCorner() { return typename FixedBlockXpr::Type(derived(), rows() - CRows, 0); } /// This is the const version of bottomLeftCorner(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type bottomLeftCorner() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type bottomLeftCorner() + const { return typename ConstFixedBlockXpr::Type(derived(), rows() - CRows, 0); } @@ -588,7 +592,7 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NRowsBlockXpr::value>::Type #else @@ -601,7 +605,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of topRows(NRowsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNRowsBlockXpr::value>::Type #else @@ -628,13 +632,13 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NRowsBlockXpr::Type topRows(Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NRowsBlockXpr::Type topRows(Index n = N) { return typename NRowsBlockXpr::Type(derived(), 0, 0, n, cols()); } /// This is the const version of topRows(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstNRowsBlockXpr::Type topRows(Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstNRowsBlockXpr::Type topRows(Index n = N) const { return typename ConstNRowsBlockXpr::Type(derived(), 0, 0, n, cols()); } @@ -655,7 +659,7 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NRowsBlockXpr::value>::Type #else @@ -668,7 +672,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of bottomRows(NRowsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNRowsBlockXpr::value>::Type #else @@ -695,13 +699,13 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NRowsBlockXpr::Type bottomRows(Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NRowsBlockXpr::Type bottomRows(Index n = N) { return typename NRowsBlockXpr::Type(derived(), rows() - n, 0, n, cols()); } /// This is the const version of bottomRows(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstNRowsBlockXpr::Type bottomRows(Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstNRowsBlockXpr::Type bottomRows(Index n = N) const { return typename ConstNRowsBlockXpr::Type(derived(), rows() - n, 0, n, cols()); } @@ -723,7 +727,7 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NRowsBlockXpr::value>::Type #else @@ -736,7 +740,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of middleRows(Index,NRowsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNRowsBlockXpr::value>::Type #else @@ -764,14 +768,15 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NRowsBlockXpr::Type middleRows(Index startRow, Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NRowsBlockXpr::Type middleRows(Index startRow, + Index n = N) { return typename NRowsBlockXpr::Type(derived(), startRow, 0, n, cols()); } /// This is the const version of middleRows(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstNRowsBlockXpr::Type middleRows(Index startRow, - Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstNRowsBlockXpr::Type middleRows(Index startRow, + Index n = N) const { return typename ConstNRowsBlockXpr::Type(derived(), startRow, 0, n, cols()); } @@ -792,7 +797,7 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NColsBlockXpr::value>::Type #else @@ -805,7 +810,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of leftCols(NColsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNColsBlockXpr::value>::Type #else @@ -832,13 +837,13 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NColsBlockXpr::Type leftCols(Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NColsBlockXpr::Type leftCols(Index n = N) { return typename NColsBlockXpr::Type(derived(), 0, 0, rows(), n); } /// This is the const version of leftCols(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstNColsBlockXpr::Type leftCols(Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstNColsBlockXpr::Type leftCols(Index n = N) const { return typename ConstNColsBlockXpr::Type(derived(), 0, 0, rows(), n); } @@ -859,7 +864,7 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NColsBlockXpr::value>::Type #else @@ -872,7 +877,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of rightCols(NColsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNColsBlockXpr::value>::Type #else @@ -899,13 +904,13 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NColsBlockXpr::Type rightCols(Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NColsBlockXpr::Type rightCols(Index n = N) { return typename NColsBlockXpr::Type(derived(), 0, cols() - n, rows(), n); } /// This is the const version of rightCols(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstNColsBlockXpr::Type rightCols(Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstNColsBlockXpr::Type rightCols(Index n = N) const { return typename ConstNColsBlockXpr::Type(derived(), 0, cols() - n, rows(), n); } @@ -927,7 +932,7 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NColsBlockXpr::value>::Type #else @@ -940,7 +945,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of middleCols(Index,NColsType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNColsBlockXpr::value>::Type #else @@ -968,14 +973,15 @@ EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column - major) /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NColsBlockXpr::Type middleCols(Index startCol, Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NColsBlockXpr::Type middleCols(Index startCol, + Index n = N) { return typename NColsBlockXpr::Type(derived(), 0, startCol, rows(), n); } /// This is the const version of middleCols(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstNColsBlockXpr::Type middleCols(Index startCol, - Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstNColsBlockXpr::Type middleCols(Index startCol, + Index n = N) const { return typename ConstNColsBlockXpr::Type(derived(), 0, startCol, rows(), n); } @@ -1004,13 +1010,14 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type block(Index startRow, Index startCol) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type block(Index startRow, + Index startCol) { return typename FixedBlockXpr::Type(derived(), startRow, startCol); } /// This is the const version of block<>(Index, Index). */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type block( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type block( Index startRow, Index startCol) const { return typename ConstFixedBlockXpr::Type(derived(), startRow, startCol); } @@ -1047,15 +1054,16 @@ EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr::Type block(Index startRow, Index startCol, - Index blockRows, - Index blockCols) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedBlockXpr::Type block(Index startRow, + Index startCol, + Index blockRows, + Index blockCols) { return typename FixedBlockXpr::Type(derived(), startRow, startCol, blockRows, blockCols); } /// This is the const version of block<>(Index, Index, Index, Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type block( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr::Type block( Index startRow, Index startCol, Index blockRows, Index blockCols) const { return typename ConstFixedBlockXpr::Type(derived(), startRow, startCol, blockRows, blockCols); } @@ -1068,10 +1076,10 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr, fix(int), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedSegmentReturnType::value>::Type #else @@ -1122,7 +1130,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of segment(Index,NType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedSegmentReturnType::value>::Type #else @@ -1155,7 +1163,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// \sa class Block, block(Index,Index) /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedSegmentReturnType::value>::Type #else @@ -1169,7 +1177,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of head(NType). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedSegmentReturnType::value>::Type #else @@ -1202,7 +1210,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// \sa class Block, block(Index,Index) /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedSegmentReturnType::value>::Type #else @@ -1216,7 +1224,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// This is the const version of tail(Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedSegmentReturnType::value>::Type #else @@ -1245,15 +1253,16 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE /// \sa segment(Index,NType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedSegmentReturnType::Type segment(Index start, Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedSegmentReturnType::Type segment(Index start, + Index n = N) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename FixedSegmentReturnType::Type(derived(), start, n); } /// This is the const version of segment(Index). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::Type segment(Index start, - Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::Type segment( + Index start, Index n = N) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename ConstFixedSegmentReturnType::Type(derived(), start, n); } @@ -1274,14 +1283,14 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::T /// \sa head(NType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedSegmentReturnType::Type head(Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedSegmentReturnType::Type head(Index n = N) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename FixedSegmentReturnType::Type(derived(), 0, n); } /// This is the const version of head(). template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::Type head(Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::Type head(Index n = N) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename ConstFixedSegmentReturnType::Type(derived(), 0, n); } @@ -1302,14 +1311,14 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::T /// \sa tail(NType), class Block /// template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedSegmentReturnType::Type tail(Index n = N) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename FixedSegmentReturnType::Type tail(Index n = N) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename FixedSegmentReturnType::Type(derived(), size() - n, n); } /// This is the const version of tail. template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::Type tail(Index n = N) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::Type tail(Index n = N) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename ConstFixedSegmentReturnType::Type(derived(), size() - n, n); } @@ -1317,21 +1326,21 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename ConstFixedSegmentReturnType::T /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this /// is col-major (resp. row-major). /// -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE InnerVectorReturnType innerVector(Index outer) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE InnerVectorReturnType innerVector(Index outer) { return InnerVectorReturnType(derived(), outer); } /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this /// is col-major (resp. row-major). Read-only. /// -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ConstInnerVectorReturnType innerVector(Index outer) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const ConstInnerVectorReturnType innerVector(Index outer) const { return ConstInnerVectorReturnType(derived(), outer); } /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this /// is col-major (resp. row-major). /// -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize) { return Block(derived(), IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart, IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize); } @@ -1339,8 +1348,8 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE InnerVectorsReturnType innerVectors(Index /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this /// is col-major (resp. row-major). Read-only. /// -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ConstInnerVectorsReturnType innerVectors(Index outerStart, - Index outerSize) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const ConstInnerVectorsReturnType innerVectors(Index outerStart, + Index outerSize) const { return Block(derived(), IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart, IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize); @@ -1350,14 +1359,15 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ConstInnerVectorsReturnType innerVec * \sa subVectors() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::conditional_t subVector(Index i) { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE std::conditional_t subVector( + Index i) { return std::conditional_t(derived(), i); } /** This is the const version of subVector(Index) */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::conditional_t subVector( - Index i) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE std::conditional_t +subVector(Index i) const { return std::conditional_t(derived(), i); } diff --git a/Eigen/src/plugins/CommonCwiseBinaryOps.inc b/Eigen/src/plugins/CommonCwiseBinaryOps.inc index f1ba30109..d5127e35c 100644 --- a/Eigen/src/plugins/CommonCwiseBinaryOps.inc +++ b/Eigen/src/plugins/CommonCwiseBinaryOps.inc @@ -38,8 +38,9 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator+, sum) * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp binaryExpr( - const EIGEN_CURRENT_STORAGE_BASE_CLASS& other, const CustomBinaryOp& func = CustomBinaryOp()) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp +binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other, + const CustomBinaryOp& func = CustomBinaryOp()) const { return CwiseBinaryOp(derived(), other.derived(), func); } @@ -63,7 +64,8 @@ EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(operator/, quotient) * \sa operator||(), select() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryOp, const Derived, const OtherDerived> +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryOp, const Derived, + const OtherDerived> operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), other.derived()); @@ -77,7 +79,8 @@ operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { * \sa operator&&(), select() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryOp, const Derived, const OtherDerived> +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryOp, const Derived, + const OtherDerived> operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), other.derived()); @@ -88,7 +91,8 @@ operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { * \sa operator|(), operator^() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryOp, const Derived, const OtherDerived> +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryOp, const Derived, + const OtherDerived> operator&(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), other.derived()); @@ -99,7 +103,8 @@ operator&(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { * \sa operator&(), operator^() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryOp, const Derived, const OtherDerived> +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryOp, const Derived, + const OtherDerived> operator|(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), other.derived()); @@ -109,7 +114,8 @@ operator|(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { * \sa operator&(), operator|() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryOp, const Derived, const OtherDerived> +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryOp, const Derived, + const OtherDerived> operator^(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), other.derived()); diff --git a/Eigen/src/plugins/CommonCwiseUnaryOps.inc b/Eigen/src/plugins/CommonCwiseUnaryOps.inc index 64f364884..bf8a9406f 100644 --- a/Eigen/src/plugins/CommonCwiseUnaryOps.inc +++ b/Eigen/src/plugins/CommonCwiseUnaryOps.inc @@ -37,7 +37,7 @@ typedef CwiseUnaryOp, const Derived> Negati /// EIGEN_DOC_UNARY_ADDONS(operator-, opposite) /// -EIGEN_DEVICE_FUNC inline const NegativeReturnType operator-() const { return NegativeReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const NegativeReturnType operator-() const { return NegativeReturnType(derived()); } template struct CastXpr { @@ -55,7 +55,7 @@ EIGEN_DOC_UNARY_ADDONS(cast, conversion function) /// \sa class CwiseUnaryOp /// template -EIGEN_DEVICE_FUNC typename CastXpr::Type cast() const { +EIGEN_DEVICE_FUNC constexpr typename CastXpr::Type cast() const { return typename CastXpr::Type(derived()); } @@ -64,7 +64,7 @@ EIGEN_DEVICE_FUNC typename CastXpr::Type cast() const { EIGEN_DOC_UNARY_ADDONS(conjugate, complex conjugate) /// /// \sa Math functions, MatrixBase::adjoint() -EIGEN_DEVICE_FUNC inline ConjugateReturnType conjugate() const { return ConjugateReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline ConjugateReturnType conjugate() const { return ConjugateReturnType(derived()); } /// \returns an expression of the complex conjugate of \c *this if Cond==true, returns derived() otherwise. /// @@ -72,7 +72,7 @@ EIGEN_DOC_UNARY_ADDONS(conjugate, complex conjugate) /// /// \sa conjugate() template -EIGEN_DEVICE_FUNC inline std::conditional_t conjugateIf() const { +EIGEN_DEVICE_FUNC constexpr inline std::conditional_t conjugateIf() const { typedef std::conditional_t ReturnType; return ReturnType(derived()); } @@ -82,14 +82,14 @@ EIGEN_DEVICE_FUNC inline std::conditional_t -EIGEN_DEVICE_FUNC inline const CwiseUnaryOp unaryExpr( +EIGEN_DEVICE_FUNC constexpr inline const CwiseUnaryOp unaryExpr( const CustomUnaryOp& func = CustomUnaryOp()) const { return CwiseUnaryOp(derived(), func); } @@ -132,7 +132,7 @@ EIGEN_DOC_UNARY_ADDONS(unaryViewExpr, unary function) /// \sa unaryExpr, binaryExpr class CwiseUnaryOp /// template -EIGEN_DEVICE_FUNC inline const CwiseUnaryView unaryViewExpr( +EIGEN_DEVICE_FUNC constexpr inline const CwiseUnaryView unaryViewExpr( const CustomViewOp& func = CustomViewOp()) const { return CwiseUnaryView(derived(), func); } @@ -147,7 +147,7 @@ EIGEN_DOC_UNARY_ADDONS(unaryViewExpr, unary function) /// \sa unaryExpr, binaryExpr class CwiseUnaryOp /// template -EIGEN_DEVICE_FUNC inline CwiseUnaryView unaryViewExpr( +EIGEN_DEVICE_FUNC constexpr inline CwiseUnaryView unaryViewExpr( const CustomViewOp& func = CustomViewOp()) { return CwiseUnaryView(derived(), func); } @@ -157,11 +157,11 @@ EIGEN_DEVICE_FUNC inline CwiseUnaryView unaryViewExpr( EIGEN_DOC_UNARY_ADDONS(real, real part function) /// /// \sa imag() -EIGEN_DEVICE_FUNC inline NonConstRealReturnType real() { return NonConstRealReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline NonConstRealReturnType real() { return NonConstRealReturnType(derived()); } /// \returns a non const expression of the imaginary part of \c *this. /// EIGEN_DOC_UNARY_ADDONS(imag, imaginary part function) /// /// \sa real() -EIGEN_DEVICE_FUNC inline NonConstImagReturnType imag() { return NonConstImagReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline NonConstImagReturnType imag() { return NonConstImagReturnType(derived()); } diff --git a/Eigen/src/plugins/MatrixCwiseBinaryOps.inc b/Eigen/src/plugins/MatrixCwiseBinaryOps.inc index fae92d8d9..8e0da06e3 100644 --- a/Eigen/src/plugins/MatrixCwiseBinaryOps.inc +++ b/Eigen/src/plugins/MatrixCwiseBinaryOps.inc @@ -18,7 +18,7 @@ * \sa class CwiseBinaryOp, cwiseAbs2 */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product) +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product) cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived, OtherDerived, product)(derived(), other.derived()); } @@ -55,7 +55,7 @@ using CwiseBinaryGreaterOrEqualReturnType = * \sa cwiseNotEqual(), isApprox(), isMuchSmallerThan() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryEqualReturnType cwiseEqual( +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryEqualReturnType cwiseEqual( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryEqualReturnType(derived(), other.derived()); } @@ -73,35 +73,35 @@ EIGEN_DEVICE_FUNC inline const CwiseBinaryEqualReturnType cwiseEqu * \sa cwiseEqual(), isApprox(), isMuchSmallerThan() */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryNotEqualReturnType cwiseNotEqual( +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryNotEqualReturnType cwiseNotEqual( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryNotEqualReturnType(derived(), other.derived()); } /** \returns an expression of the coefficient-wise < operator of *this and \a other */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryLessReturnType cwiseLess( +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryLessReturnType cwiseLess( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryLessReturnType(derived(), other.derived()); } /** \returns an expression of the coefficient-wise > operator of *this and \a other */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryGreaterReturnType cwiseGreater( +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryGreaterReturnType cwiseGreater( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryGreaterReturnType(derived(), other.derived()); } /** \returns an expression of the coefficient-wise <= operator of *this and \a other */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryLessOrEqualReturnType cwiseLessOrEqual( +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryLessOrEqualReturnType cwiseLessOrEqual( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryLessOrEqualReturnType(derived(), other.derived()); } /** \returns an expression of the coefficient-wise >= operator of *this and \a other */ template -EIGEN_DEVICE_FUNC inline const CwiseBinaryGreaterOrEqualReturnType cwiseGreaterOrEqual( +EIGEN_DEVICE_FUNC constexpr inline const CwiseBinaryGreaterOrEqualReturnType cwiseGreaterOrEqual( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryGreaterOrEqualReturnType(derived(), other.derived()); } @@ -114,7 +114,7 @@ EIGEN_DEVICE_FUNC inline const CwiseBinaryGreaterOrEqualReturnType * \sa class CwiseBinaryOp, max() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>( @@ -126,7 +126,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa class CwiseBinaryOp, min() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const ConstantReturnType> cwiseMin(const Scalar& other) const { return cwiseMin(Derived::Constant(rows(), cols(), other)); @@ -140,7 +140,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa class CwiseBinaryOp, min() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>( @@ -152,7 +152,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa class CwiseBinaryOp, min() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const ConstantReturnType> cwiseMax(const Scalar& other) const { return cwiseMax(Derived::Constant(rows(), cols(), other)); @@ -166,7 +166,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const * \sa class CwiseBinaryOp, cwiseProduct(), cwiseInverse() */ template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> cwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), @@ -195,7 +195,7 @@ using CwiseScalarGreaterOrEqualReturnType = * * \sa cwiseEqual(const MatrixBase &) const */ -EIGEN_DEVICE_FUNC inline const CwiseScalarEqualReturnType cwiseEqual(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr inline const CwiseScalarEqualReturnType cwiseEqual(const Scalar& s) const { return CwiseScalarEqualReturnType(derived(), Derived::Constant(rows(), cols(), s)); } @@ -208,27 +208,28 @@ EIGEN_DEVICE_FUNC inline const CwiseScalarEqualReturnType cwiseEqual(const Scala * * \sa cwiseEqual(const MatrixBase &) const */ -EIGEN_DEVICE_FUNC inline const CwiseScalarNotEqualReturnType cwiseNotEqual(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr inline const CwiseScalarNotEqualReturnType cwiseNotEqual(const Scalar& s) const { return CwiseScalarNotEqualReturnType(derived(), Derived::Constant(rows(), cols(), s)); } /** \returns an expression of the coefficient-wise < operator of \c *this and a scalar \a s */ -EIGEN_DEVICE_FUNC inline const CwiseScalarLessReturnType cwiseLess(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr inline const CwiseScalarLessReturnType cwiseLess(const Scalar& s) const { return CwiseScalarLessReturnType(derived(), Derived::Constant(rows(), cols(), s)); } /** \returns an expression of the coefficient-wise > operator of \c *this and a scalar \a s */ -EIGEN_DEVICE_FUNC inline const CwiseScalarGreaterReturnType cwiseGreater(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr inline const CwiseScalarGreaterReturnType cwiseGreater(const Scalar& s) const { return CwiseScalarGreaterReturnType(derived(), Derived::Constant(rows(), cols(), s)); } /** \returns an expression of the coefficient-wise <= operator of \c *this and a scalar \a s */ -EIGEN_DEVICE_FUNC inline const CwiseScalarLessOrEqualReturnType cwiseLessOrEqual(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr inline const CwiseScalarLessOrEqualReturnType cwiseLessOrEqual(const Scalar& s) const { return CwiseScalarLessOrEqualReturnType(derived(), Derived::Constant(rows(), cols(), s)); } /** \returns an expression of the coefficient-wise >= operator of \c *this and a scalar \a s */ -EIGEN_DEVICE_FUNC inline const CwiseScalarGreaterOrEqualReturnType cwiseGreaterOrEqual(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr inline const CwiseScalarGreaterOrEqualReturnType cwiseGreaterOrEqual( + const Scalar& s) const { return CwiseScalarGreaterOrEqualReturnType(derived(), Derived::Constant(rows(), cols(), s)); } @@ -252,37 +253,37 @@ using CwiseBinaryTypedGreaterOrEqualReturnType = CwiseBinaryOp, const Derived, const OtherDerived>; template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedEqualReturnType cwiseTypedEqual( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryTypedEqualReturnType cwiseTypedEqual( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryTypedEqualReturnType(derived(), other.derived()); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedNotEqualReturnType cwiseTypedNotEqual( - const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryTypedNotEqualReturnType +cwiseTypedNotEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryTypedNotEqualReturnType(derived(), other.derived()); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedLessReturnType cwiseTypedLess( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryTypedLessReturnType cwiseTypedLess( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryTypedLessReturnType(derived(), other.derived()); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedGreaterReturnType cwiseTypedGreater( +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryTypedGreaterReturnType cwiseTypedGreater( const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryTypedGreaterReturnType(derived(), other.derived()); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedLessOrEqualReturnType cwiseTypedLessOrEqual( - const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryTypedLessOrEqualReturnType +cwiseTypedLessOrEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryTypedLessOrEqualReturnType(derived(), other.derived()); } template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryTypedGreaterOrEqualReturnType +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseBinaryTypedGreaterOrEqualReturnType cwiseTypedGreaterOrEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) const { return CwiseBinaryTypedGreaterOrEqualReturnType(derived(), other.derived()); } @@ -303,29 +304,32 @@ using CwiseScalarTypedGreaterOrEqualReturnType = CwiseBinaryOp, const Derived, const ConstantReturnType>; -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedEqualReturnType cwiseTypedEqual(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseScalarTypedEqualReturnType +cwiseTypedEqual(const Scalar& s) const { return CwiseScalarTypedEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s)); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedNotEqualReturnType +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseScalarTypedNotEqualReturnType cwiseTypedNotEqual(const Scalar& s) const { return CwiseScalarTypedNotEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s)); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedLessReturnType cwiseTypedLess(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseScalarTypedLessReturnType +cwiseTypedLess(const Scalar& s) const { return CwiseScalarTypedLessReturnType(derived(), ConstantReturnType(rows(), cols(), s)); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedGreaterReturnType cwiseTypedGreater(const Scalar& s) const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseScalarTypedGreaterReturnType +cwiseTypedGreater(const Scalar& s) const { return CwiseScalarTypedGreaterReturnType(derived(), ConstantReturnType(rows(), cols(), s)); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedLessOrEqualReturnType +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseScalarTypedLessOrEqualReturnType cwiseTypedLessOrEqual(const Scalar& s) const { return CwiseScalarTypedLessOrEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s)); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseScalarTypedGreaterOrEqualReturnType +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseScalarTypedGreaterOrEqualReturnType cwiseTypedGreaterOrEqual(const Scalar& s) const { return CwiseScalarTypedGreaterOrEqualReturnType(derived(), ConstantReturnType(rows(), cols(), s)); } diff --git a/Eigen/src/plugins/MatrixCwiseUnaryOps.inc b/Eigen/src/plugins/MatrixCwiseUnaryOps.inc index ffaf5aab2..a57548c01 100644 --- a/Eigen/src/plugins/MatrixCwiseUnaryOps.inc +++ b/Eigen/src/plugins/MatrixCwiseUnaryOps.inc @@ -30,7 +30,7 @@ EIGEN_DOC_UNARY_ADDONS(cwiseAbs, absolute value) /// /// \sa cwiseAbs2() /// -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbsReturnType cwiseAbs() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseAbsReturnType cwiseAbs() const { return CwiseAbsReturnType(derived()); } @@ -43,7 +43,7 @@ EIGEN_DOC_UNARY_ADDONS(cwiseAbs2, squared absolute value) /// /// \sa cwiseAbs() /// -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const { return CwiseAbs2ReturnType(derived()); } @@ -56,7 +56,9 @@ EIGEN_DOC_UNARY_ADDONS(cwiseSqrt, square - root) /// /// \sa cwisePow(), cwiseSquare(), cwiseCbrt() /// -EIGEN_DEVICE_FUNC inline const CwiseSqrtReturnType cwiseSqrt() const { return CwiseSqrtReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CwiseSqrtReturnType cwiseSqrt() const { + return CwiseSqrtReturnType(derived()); +} /// \returns an expression of the coefficient-wise cube root of *this. /// @@ -64,7 +66,9 @@ EIGEN_DOC_UNARY_ADDONS(cwiseCbrt, cube - root) /// /// \sa cwiseSqrt(), cwiseSquare(), cwisePow() /// -EIGEN_DEVICE_FUNC inline const CwiseCbrtReturnType cwiseCbrt() const { return CwiseCbrtReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CwiseCbrtReturnType cwiseCbrt() const { + return CwiseCbrtReturnType(derived()); +} /// \returns an expression of the coefficient-wise square of *this. /// @@ -72,7 +76,9 @@ EIGEN_DOC_UNARY_ADDONS(cwiseSquare, square) /// /// \sa cwisePow(), cwiseSqrt(), cwiseCbrt() /// -EIGEN_DEVICE_FUNC inline const CwiseSquareReturnType cwiseSquare() const { return CwiseSquareReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CwiseSquareReturnType cwiseSquare() const { + return CwiseSquareReturnType(derived()); +} /// \returns an expression of the coefficient-wise signum of *this. /// @@ -81,7 +87,9 @@ EIGEN_DEVICE_FUNC inline const CwiseSquareReturnType cwiseSquare() const { retur /// EIGEN_DOC_UNARY_ADDONS(cwiseSign, sign function) /// -EIGEN_DEVICE_FUNC inline const CwiseSignReturnType cwiseSign() const { return CwiseSignReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CwiseSignReturnType cwiseSign() const { + return CwiseSignReturnType(derived()); +} /// \returns an expression of the coefficient-wise inverse of *this. /// @@ -92,7 +100,9 @@ EIGEN_DOC_UNARY_ADDONS(cwiseInverse, inverse) /// /// \sa cwiseProduct() /// -EIGEN_DEVICE_FUNC inline const CwiseInverseReturnType cwiseInverse() const { return CwiseInverseReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CwiseInverseReturnType cwiseInverse() const { + return CwiseInverseReturnType(derived()); +} /// \returns an expression of the coefficient-wise phase angle of \c *this /// @@ -101,9 +111,9 @@ EIGEN_DEVICE_FUNC inline const CwiseInverseReturnType cwiseInverse() const { ret /// EIGEN_DOC_UNARY_ADDONS(cwiseArg, arg) -EIGEN_DEVICE_FUNC inline const CwiseArgReturnType cwiseArg() const { return CwiseArgReturnType(derived()); } +EIGEN_DEVICE_FUNC constexpr inline const CwiseArgReturnType cwiseArg() const { return CwiseArgReturnType(derived()); } -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseCArgReturnType cwiseCArg() const { +EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CwiseCArgReturnType cwiseCArg() const { return CwiseCArgReturnType(derived()); } @@ -113,6 +123,7 @@ using CwisePowReturnType = CwiseUnaryOp, const Derived>>; template -EIGEN_DEVICE_FUNC inline const CwisePowReturnType cwisePow(const ScalarExponent& exponent) const { +EIGEN_DEVICE_FUNC constexpr inline const CwisePowReturnType cwisePow( + const ScalarExponent& exponent) const { return CwisePowReturnType(derived(), internal::scalar_unary_pow_op(exponent)); } diff --git a/Eigen/src/plugins/ReshapedMethods.inc b/Eigen/src/plugins/ReshapedMethods.inc index c1f90e729..1e3a19636 100644 --- a/Eigen/src/plugins/ReshapedMethods.inc +++ b/Eigen/src/plugins/ReshapedMethods.inc @@ -27,11 +27,11 @@ /// \sa class Reshaped, fix, fix(int) /// template -EIGEN_DEVICE_FUNC inline Reshaped reshaped(NRowsType nRows, NColsType nCols); +EIGEN_DEVICE_FUNC constexpr inline Reshaped reshaped(NRowsType nRows, NColsType nCols); /// This is the const version of reshaped(NRowsType,NColsType). template -EIGEN_DEVICE_FUNC inline const Reshaped reshaped(NRowsType nRows, NColsType nCols) const; +EIGEN_DEVICE_FUNC constexpr inline const Reshaped reshaped(NRowsType nRows, NColsType nCols) const; /// \returns an expression of \c *this with columns (or rows) stacked to a linear column vector /// @@ -56,11 +56,11 @@ EIGEN_DEVICE_FUNC inline const Reshaped reshaped(NRowsType n /// \sa reshaped(NRowsType,NColsType), class Reshaped /// template -EIGEN_DEVICE_FUNC inline Reshaped reshaped(); +EIGEN_DEVICE_FUNC constexpr inline Reshaped reshaped(); /// This is the const version of reshaped(). template -EIGEN_DEVICE_FUNC inline const Reshaped reshaped() const; +EIGEN_DEVICE_FUNC constexpr inline const Reshaped reshaped() const; #else @@ -79,7 +79,7 @@ EIGEN_DEVICE_FUNC inline const Reshaped reshaped() const; #endif template -EIGEN_DEVICE_FUNC inline Reshaped< +EIGEN_DEVICE_FUNC constexpr inline Reshaped< EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size::value, internal::get_compiletime_reshape_size::value> @@ -92,7 +92,7 @@ reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST { } template -EIGEN_DEVICE_FUNC inline Reshaped< +EIGEN_DEVICE_FUNC constexpr inline Reshaped< EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size::value, internal::get_compiletime_reshape_size::value, @@ -108,14 +108,14 @@ reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST { // Views as linear vectors -EIGEN_DEVICE_FUNC inline Reshaped reshaped() +EIGEN_DEVICE_FUNC constexpr inline Reshaped reshaped() EIGEN_RESHAPED_METHOD_CONST { return Reshaped(derived(), size(), 1); } template -EIGEN_DEVICE_FUNC inline Reshaped +EIGEN_DEVICE_FUNC constexpr inline Reshaped reshaped() EIGEN_RESHAPED_METHOD_CONST { EIGEN_STATIC_ASSERT(Order == RowMajor || Order == ColMajor || Order == AutoOrder, INVALID_TEMPLATE_PARAMETER); return Reshaped= 201907L }