10#ifndef EIGEN_DENSECOEFFSBASE_H
11#define EIGEN_DENSECOEFFSBASE_H
14#include "./InternalHeaderCheck.h"
20struct add_const_on_value_type_if_arithmetic {
21 typedef std::conditional_t<is_arithmetic<T>::value, T, add_const_on_value_type_t<T>> type;
37template <
typename Derived>
40 typedef typename internal::traits<Derived>::StorageKind StorageKind;
41 typedef typename internal::traits<Derived>::Scalar Scalar;
42 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
51 typedef std::conditional_t<bool(internal::traits<Derived>::Flags&
LvalueBit),
const Scalar&,
52 std::conditional_t<internal::is_arithmetic<Scalar>::value, Scalar,
const Scalar>>
55 typedef typename internal::add_const_on_value_type_if_arithmetic<typename internal::packet_traits<Scalar>::type>::type
64 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index rowIndexByOuterInner(
Index outer,
Index inner)
const {
65 return int(Derived::RowsAtCompileTime) == 1 ? 0
66 : int(Derived::ColsAtCompileTime) == 1 ? inner
71 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index colIndexByOuterInner(
Index outer,
Index inner)
const {
72 return int(Derived::ColsAtCompileTime) == 1 ? 0
73 : int(Derived::RowsAtCompileTime) == 1 ? inner
92 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
coeff(
Index row,
Index col)
const {
93 eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
94 return internal::evaluator<Derived>(derived()).coeff(row, col);
97 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType coeffByOuterInner(
Index outer,
99 return coeff(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
107 eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
108 return coeff(row, col);
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
coeff(
Index index)
const {
127 EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags &
LinearAccessBit,
128 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
129 eigen_internal_assert(index >= 0 && index < size());
130 return internal::evaluator<Derived>(derived()).coeff(index);
141 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
operator[](
Index index)
const {
142 EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
143 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
144 eigen_assert(index >= 0 && index < size());
158 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
operator()(
Index index)
const {
159 eigen_assert(index >= 0 && index < size());
165 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
x()
const {
return (*
this)[0]; }
169 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
y()
const {
170 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
176 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
z()
const {
177 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
183 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR CoeffReturnType
w()
const {
184 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
198 template <
int LoadMode>
199 EIGEN_STRONG_INLINE PacketReturnType packet(
Index row,
Index col)
const {
200 typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
201 eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
202 return internal::evaluator<Derived>(derived()).template packet<LoadMode, DefaultPacketType>(row, col);
206 template <
int LoadMode>
207 EIGEN_STRONG_INLINE PacketReturnType packetByOuterInner(Index outer, Index inner)
const {
208 return packet<LoadMode>(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
221 template <
int LoadMode>
222 EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const {
223 EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
224 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
225 typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
226 eigen_internal_assert(index >= 0 && index < size());
227 return internal::evaluator<Derived>(derived()).template packet<LoadMode, DefaultPacketType>(index);
237 void coeffRefByOuterInner();
239 void writePacketByOuterInner();
241 void copyCoeffByOuterInner();
243 void copyPacketByOuterInner();
263template <
typename Derived>
264class DenseCoeffsBase<Derived,
WriteAccessors> :
public DenseCoeffsBase<Derived, ReadOnlyAccessors> {
266 typedef DenseCoeffsBase<Derived, ReadOnlyAccessors>
Base;
268 typedef typename internal::traits<Derived>::StorageKind StorageKind;
269 typedef typename internal::traits<Derived>::Scalar Scalar;
270 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
271 typedef typename NumTraits<Scalar>::Real RealScalar;
274 using Base::colIndexByOuterInner;
277 using Base::rowIndexByOuterInner;
280 using Base::operator[];
281 using Base::operator();
302 eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
303 return internal::evaluator<Derived>(derived()).coeffRef(row, col);
306 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRefByOuterInner(
Index outer,
Index inner) {
307 return coeffRef(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
316 eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
317 return coeffRef(row, col);
336 EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags &
LinearAccessBit,
337 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
338 eigen_internal_assert(index >= 0 && index < size());
339 return internal::evaluator<Derived>(derived()).coeffRef(index);
350 EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
351 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
352 eigen_assert(index >= 0 && index < size());
353 return coeffRef(index);
365 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar&
operator()(
Index index) {
366 eigen_assert(index >= 0 && index < size());
367 return coeffRef(index);
372 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar&
x() {
return (*
this)[0]; }
376 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar&
y() {
377 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
383 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar&
z() {
384 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
390 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Scalar&
w() {
391 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
408template <
typename Derived>
409class DenseCoeffsBase<Derived,
DirectAccessors> :
public DenseCoeffsBase<Derived, ReadOnlyAccessors> {
411 typedef DenseCoeffsBase<Derived, ReadOnlyAccessors>
Base;
412 typedef typename internal::traits<Derived>::Scalar Scalar;
413 typedef typename NumTraits<Scalar>::Real RealScalar;
424 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride()
const {
return derived().innerStride(); }
431 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride()
const {
return derived().outerStride(); }
434 EIGEN_CONSTEXPR
inline Index stride()
const {
return Derived::IsVectorAtCompileTime ? innerStride() : outerStride(); }
441 return Derived::IsRowMajor ? outerStride() : innerStride();
449 return Derived::IsRowMajor ? innerStride() : outerStride();
465template <
typename Derived>
468 typedef DenseCoeffsBase<Derived, WriteAccessors>
Base;
469 typedef typename internal::traits<Derived>::Scalar Scalar;
470 typedef typename NumTraits<Scalar>::Real RealScalar;
481 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride() const EIGEN_NOEXCEPT {
return derived().innerStride(); }
488 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride() const EIGEN_NOEXCEPT {
return derived().outerStride(); }
491 EIGEN_CONSTEXPR
inline Index stride() const EIGEN_NOEXCEPT {
492 return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();
499 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index rowStride() const EIGEN_NOEXCEPT {
500 return Derived::IsRowMajor ? outerStride() : innerStride();
507 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index colStride() const EIGEN_NOEXCEPT {
508 return Derived::IsRowMajor ? innerStride() : outerStride();
514template <
int Alignment,
typename Derived,
bool JustReturnZero>
515struct first_aligned_impl {
516 static EIGEN_CONSTEXPR
inline Index run(
const Derived&) EIGEN_NOEXCEPT {
return 0; }
519template <
int Alignment,
typename Derived>
520struct first_aligned_impl<Alignment, Derived, false> {
521 static inline Index run(
const Derived& m) {
return internal::first_aligned<Alignment>(m.data(), m.size()); }
532template <
int Alignment,
typename Derived>
533static inline Index first_aligned(
const DenseBase<Derived>& m) {
534 enum { ReturnZero = (int(evaluator<Derived>::Alignment) >= Alignment) || !(Derived::Flags &
DirectAccessBit) };
535 return first_aligned_impl<Alignment, Derived, ReturnZero>::run(m.derived());
538template <
typename Derived>
539static inline Index first_default_aligned(
const DenseBase<Derived>& m) {
540 typedef typename Derived::Scalar Scalar;
541 typedef typename packet_traits<Scalar>::type DefaultPacketType;
542 return internal::first_aligned<int(unpacket_traits<DefaultPacketType>::alignment), Derived>(m);
545template <typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
546struct inner_stride_at_compile_time {
547 enum { ret = traits<Derived>::InnerStrideAtCompileTime };
550template <
typename Derived>
551struct inner_stride_at_compile_time<Derived, false> {
555template <typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
556struct outer_stride_at_compile_time {
557 enum { ret = traits<Derived>::OuterStrideAtCompileTime };
560template <
typename Derived>
561struct outer_stride_at_compile_time<Derived, false> {
EIGEN_CONSTEXPR Index innerStride() const
Definition DenseCoeffsBase.h:424
EIGEN_CONSTEXPR Index rowStride() const
Definition DenseCoeffsBase.h:440
EIGEN_CONSTEXPR Index outerStride() const
Definition DenseCoeffsBase.h:431
EIGEN_CONSTEXPR Index colStride() const
Definition DenseCoeffsBase.h:448
EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
Definition DenseCoeffsBase.h:481
EIGEN_CONSTEXPR Index rowStride() const EIGEN_NOEXCEPT
Definition DenseCoeffsBase.h:499
EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
Definition DenseCoeffsBase.h:488
EIGEN_CONSTEXPR Index colStride() const EIGEN_NOEXCEPT
Definition DenseCoeffsBase.h:507
Base class providing read-only coefficient access to matrices and arrays.
Definition DenseCoeffsBase.h:38
EIGEN_CONSTEXPR CoeffReturnType operator[](Index index) const
Definition DenseCoeffsBase.h:141
EIGEN_CONSTEXPR CoeffReturnType y() const
Definition DenseCoeffsBase.h:169
EIGEN_CONSTEXPR CoeffReturnType w() const
Definition DenseCoeffsBase.h:183
EIGEN_CONSTEXPR CoeffReturnType x() const
Definition DenseCoeffsBase.h:165
EIGEN_CONSTEXPR CoeffReturnType operator()(Index row, Index col) const
Definition DenseCoeffsBase.h:106
EIGEN_CONSTEXPR CoeffReturnType operator()(Index index) const
Definition DenseCoeffsBase.h:158
EIGEN_CONSTEXPR CoeffReturnType coeff(Index index) const
Definition DenseCoeffsBase.h:126
EIGEN_CONSTEXPR CoeffReturnType z() const
Definition DenseCoeffsBase.h:176
EIGEN_CONSTEXPR CoeffReturnType coeff(Index row, Index col) const
Definition DenseCoeffsBase.h:92
Base class providing read/write coefficient access to matrices and arrays.
Definition DenseCoeffsBase.h:264
EIGEN_CONSTEXPR Scalar & x()
Definition DenseCoeffsBase.h:372
EIGEN_CONSTEXPR Scalar & z()
Definition DenseCoeffsBase.h:383
EIGEN_CONSTEXPR Scalar & w()
Definition DenseCoeffsBase.h:390
Scalar & operator[](Index index)
Definition DenseCoeffsBase.h:349
Scalar & operator()(Index row, Index col)
Definition DenseCoeffsBase.h:315
Scalar & coeffRef(Index row, Index col)
Definition DenseCoeffsBase.h:301
EIGEN_CONSTEXPR Scalar & operator()(Index index)
Definition DenseCoeffsBase.h:365
Scalar & coeffRef(Index index)
Definition DenseCoeffsBase.h:335
EIGEN_CONSTEXPR Scalar & y()
Definition DenseCoeffsBase.h:376
@ DirectAccessors
Definition Constants.h:376
@ ReadOnlyAccessors
Definition Constants.h:372
@ WriteAccessors
Definition Constants.h:374
@ DirectWriteAccessors
Definition Constants.h:378
const unsigned int LinearAccessBit
Definition Constants.h:133
const unsigned int DirectAccessBit
Definition Constants.h:159
const unsigned int LvalueBit
Definition Constants.h:148
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83
Definition EigenBase.h:33
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:43