mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-13 01:43:13 +08:00
Add constexpr to accessors in DenseBase, Quaternions and Translations
This commit is contained in:
parent
3c9109238f
commit
3c6521ed90
@ -89,12 +89,13 @@ class DenseCoeffsBase<Derived, ReadOnlyAccessors> : public EigenBase<Derived> {
|
|||||||
*
|
*
|
||||||
* \sa operator()(Index,Index) const, coeffRef(Index,Index), coeff(Index) const
|
* \sa operator()(Index,Index) const, coeffRef(Index,Index), coeff(Index) const
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType coeff(Index row, Index col) const {
|
||||||
eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
|
eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
|
||||||
return internal::evaluator<Derived>(derived()).coeff(row, col);
|
return internal::evaluator<Derived>(derived()).coeff(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeffByOuterInner(Index outer, Index inner) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType coeffByOuterInner(Index outer,
|
||||||
|
Index inner) const {
|
||||||
return coeff(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
|
return coeff(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ class DenseCoeffsBase<Derived, ReadOnlyAccessors> : public EigenBase<Derived> {
|
|||||||
*
|
*
|
||||||
* \sa operator()(Index,Index), operator[](Index)
|
* \sa operator()(Index,Index), operator[](Index)
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType operator()(Index row, Index col) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType operator()(Index row, Index col) const {
|
||||||
eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
|
eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
|
||||||
return coeff(row, col);
|
return coeff(row, col);
|
||||||
}
|
}
|
||||||
@ -122,7 +123,7 @@ class DenseCoeffsBase<Derived, ReadOnlyAccessors> : public EigenBase<Derived> {
|
|||||||
* \sa operator[](Index) const, coeffRef(Index), coeff(Index,Index) const
|
* \sa operator[](Index) const, coeffRef(Index), coeff(Index,Index) const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType coeff(Index index) const {
|
||||||
EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
|
EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
|
||||||
THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
|
THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
|
||||||
eigen_internal_assert(index >= 0 && index < size());
|
eigen_internal_assert(index >= 0 && index < size());
|
||||||
@ -137,7 +138,7 @@ class DenseCoeffsBase<Derived, ReadOnlyAccessors> : public EigenBase<Derived> {
|
|||||||
* z() const, w() const
|
* z() const, w() const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType operator[](Index index) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType operator[](Index index) const {
|
||||||
EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
|
EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
|
||||||
THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
|
THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
|
||||||
eigen_assert(index >= 0 && index < size());
|
eigen_assert(index >= 0 && index < size());
|
||||||
@ -154,32 +155,32 @@ class DenseCoeffsBase<Derived, ReadOnlyAccessors> : public EigenBase<Derived> {
|
|||||||
* z() const, w() const
|
* z() const, w() const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType operator()(Index index) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType operator()(Index index) const {
|
||||||
eigen_assert(index >= 0 && index < size());
|
eigen_assert(index >= 0 && index < size());
|
||||||
return coeff(index);
|
return coeff(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](0). */
|
/** equivalent to operator[](0). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType x() const { return (*this)[0]; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType x() const { return (*this)[0]; }
|
||||||
|
|
||||||
/** equivalent to operator[](1). */
|
/** equivalent to operator[](1). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType y() const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType y() const {
|
||||||
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
|
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
|
||||||
return (*this)[1];
|
return (*this)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](2). */
|
/** equivalent to operator[](2). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType z() const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType z() const {
|
||||||
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
|
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
|
||||||
return (*this)[2];
|
return (*this)[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](3). */
|
/** equivalent to operator[](3). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType w() const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType w() const {
|
||||||
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
|
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
|
||||||
return (*this)[3];
|
return (*this)[3];
|
||||||
}
|
}
|
||||||
@ -361,32 +362,32 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived,
|
|||||||
* \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()
|
* \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& operator()(Index index) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar& operator()(Index index) {
|
||||||
eigen_assert(index >= 0 && index < size());
|
eigen_assert(index >= 0 && index < size());
|
||||||
return coeffRef(index);
|
return coeffRef(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](0). */
|
/** equivalent to operator[](0). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& x() { return (*this)[0]; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar& x() { return (*this)[0]; }
|
||||||
|
|
||||||
/** equivalent to operator[](1). */
|
/** equivalent to operator[](1). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& y() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar& y() {
|
||||||
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
|
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
|
||||||
return (*this)[1];
|
return (*this)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](2). */
|
/** equivalent to operator[](2). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& z() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar& z() {
|
||||||
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
|
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
|
||||||
return (*this)[2];
|
return (*this)[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](3). */
|
/** equivalent to operator[](3). */
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& w() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar& w() {
|
||||||
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
|
EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
|
||||||
return (*this)[3];
|
return (*this)[3];
|
||||||
}
|
}
|
||||||
|
@ -57,22 +57,22 @@ class QuaternionBase : public RotationBase<Derived, 3> {
|
|||||||
typedef AngleAxis<Scalar> AngleAxisType;
|
typedef AngleAxis<Scalar> AngleAxisType;
|
||||||
|
|
||||||
/** \returns the \c x coefficient */
|
/** \returns the \c x coefficient */
|
||||||
EIGEN_DEVICE_FUNC inline CoeffReturnType x() const { return this->derived().coeffs().coeff(0); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline CoeffReturnType x() const { return this->derived().coeffs().coeff(0); }
|
||||||
/** \returns the \c y coefficient */
|
/** \returns the \c y coefficient */
|
||||||
EIGEN_DEVICE_FUNC inline CoeffReturnType y() const { return this->derived().coeffs().coeff(1); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline CoeffReturnType y() const { return this->derived().coeffs().coeff(1); }
|
||||||
/** \returns the \c z coefficient */
|
/** \returns the \c z coefficient */
|
||||||
EIGEN_DEVICE_FUNC inline CoeffReturnType z() const { return this->derived().coeffs().coeff(2); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline CoeffReturnType z() const { return this->derived().coeffs().coeff(2); }
|
||||||
/** \returns the \c w coefficient */
|
/** \returns the \c w coefficient */
|
||||||
EIGEN_DEVICE_FUNC inline CoeffReturnType w() const { return this->derived().coeffs().coeff(3); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline CoeffReturnType w() const { return this->derived().coeffs().coeff(3); }
|
||||||
|
|
||||||
/** \returns a reference to the \c x coefficient (if Derived is a non-const lvalue) */
|
/** \returns a reference to the \c x coefficient (if Derived is a non-const lvalue) */
|
||||||
EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType x() { return this->derived().coeffs().x(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline NonConstCoeffReturnType x() { return this->derived().coeffs().x(); }
|
||||||
/** \returns a reference to the \c y coefficient (if Derived is a non-const lvalue) */
|
/** \returns a reference to the \c y coefficient (if Derived is a non-const lvalue) */
|
||||||
EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType y() { return this->derived().coeffs().y(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline NonConstCoeffReturnType y() { return this->derived().coeffs().y(); }
|
||||||
/** \returns a reference to the \c z coefficient (if Derived is a non-const lvalue) */
|
/** \returns a reference to the \c z coefficient (if Derived is a non-const lvalue) */
|
||||||
EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType z() { return this->derived().coeffs().z(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline NonConstCoeffReturnType z() { return this->derived().coeffs().z(); }
|
||||||
/** \returns a reference to the \c w coefficient (if Derived is a non-const lvalue) */
|
/** \returns a reference to the \c w coefficient (if Derived is a non-const lvalue) */
|
||||||
EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType w() { return this->derived().coeffs().w(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline NonConstCoeffReturnType w() { return this->derived().coeffs().w(); }
|
||||||
|
|
||||||
/** \returns a read-only vector expression of the imaginary part (x,y,z) */
|
/** \returns a read-only vector expression of the imaginary part (x,y,z) */
|
||||||
EIGEN_DEVICE_FUNC inline const VectorBlock<const Coefficients, 3> vec() const { return coeffs().template head<3>(); }
|
EIGEN_DEVICE_FUNC inline const VectorBlock<const Coefficients, 3> vec() const { return coeffs().template head<3>(); }
|
||||||
|
@ -69,18 +69,18 @@ class Translation {
|
|||||||
EIGEN_DEVICE_FUNC explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {}
|
EIGEN_DEVICE_FUNC explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {}
|
||||||
|
|
||||||
/** \brief Returns the x-translation by value. **/
|
/** \brief Returns the x-translation by value. **/
|
||||||
EIGEN_DEVICE_FUNC inline Scalar x() const { return m_coeffs.x(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Scalar x() const { return m_coeffs.x(); }
|
||||||
/** \brief Returns the y-translation by value. **/
|
/** \brief Returns the y-translation by value. **/
|
||||||
EIGEN_DEVICE_FUNC inline Scalar y() const { return m_coeffs.y(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Scalar y() const { return m_coeffs.y(); }
|
||||||
/** \brief Returns the z-translation by value. **/
|
/** \brief Returns the z-translation by value. **/
|
||||||
EIGEN_DEVICE_FUNC inline Scalar z() const { return m_coeffs.z(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Scalar z() const { return m_coeffs.z(); }
|
||||||
|
|
||||||
/** \brief Returns the x-translation as a reference. **/
|
/** \brief Returns the x-translation as a reference. **/
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& x() { return m_coeffs.x(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Scalar& x() { return m_coeffs.x(); }
|
||||||
/** \brief Returns the y-translation as a reference. **/
|
/** \brief Returns the y-translation as a reference. **/
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& y() { return m_coeffs.y(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Scalar& y() { return m_coeffs.y(); }
|
||||||
/** \brief Returns the z-translation as a reference. **/
|
/** \brief Returns the z-translation as a reference. **/
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& z() { return m_coeffs.z(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Scalar& z() { return m_coeffs.z(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC const VectorType& vector() const { return m_coeffs; }
|
EIGEN_DEVICE_FUNC const VectorType& vector() const { return m_coeffs; }
|
||||||
EIGEN_DEVICE_FUNC VectorType& vector() { return m_coeffs; }
|
EIGEN_DEVICE_FUNC VectorType& vector() { return m_coeffs; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user