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;
58 std::conditional_t<internal::is_arithmetic<Scalar>::value, Scalar,
const Scalar>>
61 typedef typename internal::add_const_on_value_type_if_arithmetic<typename internal::packet_traits<Scalar>::type>::type
64 typedef EigenBase<Derived> Base;
70 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index rowIndexByOuterInner(
Index outer,
Index inner)
const {
71 return int(Derived::RowsAtCompileTime) == 1 ? 0
72 : int(Derived::ColsAtCompileTime) == 1 ? inner
77 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index colIndexByOuterInner(
Index outer,
Index inner)
const {
78 return int(Derived::ColsAtCompileTime) == 1 ? 0
79 : int(Derived::RowsAtCompileTime) == 1 ? inner
98 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType coeff(
Index row,
Index col)
const {
99 eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
100 return internal::evaluator<Derived>(derived()).coeff(row, col);
103 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType coeffByOuterInner(
Index outer,
Index inner)
const {
104 return coeff(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
111 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType operator()(
Index row,
Index col)
const {
112 eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
113 return coeff(row, col);
116#ifdef EIGEN_MULTIDIMENSIONAL_SUBSCRIPT
121 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType operator[](
Index row,
Index col)
const {
122 return operator()(row, col);
141 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType coeff(
Index index)
const {
142 EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags &
LinearAccessBit,
143 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
144 eigen_internal_assert(index >= 0 && index < size());
145 return internal::evaluator<Derived>(derived()).coeff(index);
156 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType operator[](
Index index)
const {
157 EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
158 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
159 eigen_assert(index >= 0 && index < size());
173 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType operator()(
Index index)
const {
174 eigen_assert(index >= 0 && index < size());
180 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType x()
const {
return (*
this)[0]; }
184 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType y()
const {
185 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
191 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType z()
const {
192 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
198 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType w()
const {
199 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
213 template <
int LoadMode>
214 EIGEN_STRONG_INLINE PacketReturnType packet(
Index row,
Index col)
const {
215 typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
216 eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
217 return internal::evaluator<Derived>(derived()).template packet<LoadMode, DefaultPacketType>(row, col);
221 template <
int LoadMode>
222 EIGEN_STRONG_INLINE PacketReturnType packetByOuterInner(
Index outer,
Index inner)
const {
223 return packet<LoadMode>(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
236 template <
int LoadMode>
237 EIGEN_STRONG_INLINE PacketReturnType packet(
Index index)
const {
238 EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags &
LinearAccessBit,
239 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
240 typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
241 eigen_internal_assert(index >= 0 && index < size());
242 return internal::evaluator<Derived>(derived()).template packet<LoadMode, DefaultPacketType>(index);
252 void coeffRefByOuterInner();
254 void writePacketByOuterInner();
256 void copyCoeffByOuterInner();
258 void copyPacketByOuterInner();
278template <
typename Derived>
279class DenseCoeffsBase<Derived,
WriteAccessors> :
public DenseCoeffsBase<Derived, ReadOnlyAccessors> {
281 typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base;
283 typedef typename internal::traits<Derived>::StorageKind StorageKind;
284 typedef typename internal::traits<Derived>::Scalar Scalar;
285 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
286 typedef typename NumTraits<Scalar>::Real RealScalar;
289 using Base::colIndexByOuterInner;
292 using Base::rowIndexByOuterInner;
295 using Base::operator[];
296 using Base::operator();
316 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& coeffRef(
Index row,
Index col) {
317 eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
318 return internal::evaluator<Derived>(derived()).coeffRef(row, col);
321 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRefByOuterInner(
Index outer,
Index inner) {
322 return coeffRef(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner));
329 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& operator()(
Index row,
Index col) {
330 eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
331 return coeffRef(row, col);
334#ifdef EIGEN_MULTIDIMENSIONAL_SUBSCRIPT
339 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& operator[](
Index row,
Index col) {
340 return operator()(row, col);
359 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& coeffRef(
Index index) {
360 EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags &
LinearAccessBit,
361 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
362 eigen_internal_assert(index >= 0 && index < size());
363 return internal::evaluator<Derived>(derived()).coeffRef(index);
373 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& operator[](
Index index) {
374 EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
375 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
376 eigen_assert(index >= 0 && index < size());
377 return coeffRef(index);
389 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& operator()(
Index index) {
390 eigen_assert(index >= 0 && index < size());
391 return coeffRef(index);
396 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& x() {
return (*
this)[0]; }
400 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& y() {
401 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 2, OUT_OF_RANGE_ACCESS);
407 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& z() {
408 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 3, OUT_OF_RANGE_ACCESS);
414 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& w() {
415 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime == -1 || Derived::SizeAtCompileTime >= 4, OUT_OF_RANGE_ACCESS);
432template <
typename Derived>
433class DenseCoeffsBase<Derived,
DirectAccessors> :
public DenseCoeffsBase<Derived, ReadOnlyAccessors> {
435 typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base;
436 typedef typename internal::traits<Derived>::Scalar Scalar;
437 typedef typename NumTraits<Scalar>::Real RealScalar;
458 constexpr Index stride()
const {
return Derived::IsVectorAtCompileTime ? innerStride() : outerStride(); }
485template <
typename Derived>
488 typedef DenseCoeffsBase<Derived, WriteAccessors> Base;
489 typedef typename internal::traits<Derived>::Scalar Scalar;
490 typedef typename NumTraits<Scalar>::Real RealScalar;
501 EIGEN_DEVICE_FUNC
constexpr Index innerStride() const noexcept {
return derived().innerStride(); }
508 EIGEN_DEVICE_FUNC
constexpr Index outerStride() const noexcept {
return derived().outerStride(); }
511 constexpr Index stride() const noexcept {
return Derived::IsVectorAtCompileTime ? innerStride() : outerStride(); }
532template <
int Alignment,
typename Derived,
bool JustReturnZero>
533struct first_aligned_impl {
534 static constexpr Index run(
const Derived&)
noexcept {
return 0; }
537template <
int Alignment,
typename Derived>
538struct first_aligned_impl<Alignment, Derived, false> {
539 static inline Index run(
const Derived& m) {
return internal::first_aligned<Alignment>(m.data(), m.size()); }
550template <
int Alignment,
typename Derived>
551static inline Index first_aligned(
const DenseBase<Derived>& m) {
552 enum { ReturnZero = (int(evaluator<Derived>::Alignment) >= Alignment) || !(Derived::Flags &
DirectAccessBit) };
553 return first_aligned_impl<Alignment, Derived, ReturnZero>::run(m.derived());
556template <
typename Derived>
557static inline Index first_default_aligned(
const DenseBase<Derived>& m) {
558 typedef typename Derived::Scalar Scalar;
559 typedef typename packet_traits<Scalar>::type DefaultPacketType;
560 return internal::first_aligned<int(unpacket_traits<DefaultPacketType>::alignment), Derived>(m);
563template <typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
564struct inner_stride_at_compile_time {
565 enum { ret = traits<Derived>::InnerStrideAtCompileTime };
568template <
typename Derived>
569struct inner_stride_at_compile_time<Derived, false> {
573template <typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
574struct outer_stride_at_compile_time {
575 enum { ret = traits<Derived>::OuterStrideAtCompileTime };
578template <
typename Derived>
579struct outer_stride_at_compile_time<Derived, false> {
constexpr Index rowStride() const
Definition DenseCoeffsBase.h:464
constexpr Index innerStride() const
Definition DenseCoeffsBase.h:448
constexpr Index colStride() const
Definition DenseCoeffsBase.h:470
constexpr Index outerStride() const
Definition DenseCoeffsBase.h:455
constexpr Index colStride() const noexcept
Definition DenseCoeffsBase.h:525
constexpr Index innerStride() const noexcept
Definition DenseCoeffsBase.h:501
constexpr Index outerStride() const noexcept
Definition DenseCoeffsBase.h:508
constexpr Index rowStride() const noexcept
Definition DenseCoeffsBase.h:517
@ 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 B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
Definition EigenBase.h:33