10 #ifndef EIGEN_DENSECOEFFSBASE_H
11 #define EIGEN_DENSECOEFFSBASE_H
18 template<
typename T>
struct add_const_on_value_type_if_arithmetic
20 typedef std::conditional_t<is_arithmetic<T>::value,
T, add_const_on_value_type_t<T>> type;
36 template<
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),
53 std::conditional_t<internal::is_arithmetic<Scalar>::value,
Scalar,
const Scalar>
56 typedef typename internal::add_const_on_value_type_if_arithmetic<
57 typename internal::packet_traits<Scalar>::type
69 return int(Derived::RowsAtCompileTime) == 1 ? 0
70 : int(Derived::ColsAtCompileTime) == 1 ? inner
78 return int(Derived::ColsAtCompileTime) == 1 ? 0
79 : int(Derived::RowsAtCompileTime) == 1 ? inner
103 return internal::evaluator<Derived>(derived()).coeff(
row,
col);
109 return coeff(rowIndexByOuterInner(outer, inner),
110 colIndexByOuterInner(outer, inner));
141 EIGEN_STRONG_INLINE CoeffReturnType
145 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
147 return internal::evaluator<Derived>(derived()).coeff(index);
160 EIGEN_STRONG_INLINE CoeffReturnType
164 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
180 EIGEN_STRONG_INLINE CoeffReturnType
190 EIGEN_STRONG_INLINE CoeffReturnType
191 x()
const {
return (*
this)[0]; }
196 EIGEN_STRONG_INLINE CoeffReturnType
199 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=2, OUT_OF_RANGE_ACCESS);
206 EIGEN_STRONG_INLINE CoeffReturnType
209 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=3, OUT_OF_RANGE_ACCESS);
216 EIGEN_STRONG_INLINE CoeffReturnType
219 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=4, OUT_OF_RANGE_ACCESS);
233 template<
int LoadMode>
236 typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
238 return internal::evaluator<Derived>(derived()).template packet<LoadMode,DefaultPacketType>(
row,
col);
243 template<
int LoadMode>
246 return packet<LoadMode>(rowIndexByOuterInner(outer, inner),
247 colIndexByOuterInner(outer, inner));
260 template<
int LoadMode>
264 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
265 typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
267 return internal::evaluator<Derived>(derived()).template packet<LoadMode,DefaultPacketType>(index);
303 template<
typename Derived>
310 typedef typename internal::traits<Derived>::StorageKind
StorageKind;
311 typedef typename internal::traits<Derived>::Scalar
Scalar;
320 using Base::rowIndexByOuterInner;
321 using Base::colIndexByOuterInner;
322 using Base::operator[];
323 using Base::operator();
348 return internal::evaluator<Derived>(derived()).coeffRef(
row,
col);
352 EIGEN_STRONG_INLINE Scalar&
355 return coeffRef(rowIndexByOuterInner(outer, inner),
356 colIndexByOuterInner(outer, inner));
365 EIGEN_STRONG_INLINE Scalar&
370 return coeffRef(
row,
col);
390 EIGEN_STRONG_INLINE Scalar&
394 THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
396 return internal::evaluator<Derived>(derived()).coeffRef(index);
407 EIGEN_STRONG_INLINE Scalar&
411 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
413 return coeffRef(index);
426 EIGEN_STRONG_INLINE Scalar&
430 return coeffRef(index);
436 EIGEN_STRONG_INLINE Scalar&
437 x() {
return (*
this)[0]; }
442 EIGEN_STRONG_INLINE Scalar&
445 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=2, OUT_OF_RANGE_ACCESS);
452 EIGEN_STRONG_INLINE Scalar&
455 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=3, OUT_OF_RANGE_ACCESS);
462 EIGEN_STRONG_INLINE Scalar&
465 EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=4, OUT_OF_RANGE_ACCESS);
482 template<
typename Derived>
488 typedef typename internal::traits<Derived>::Scalar
Scalar;
503 return derived().innerStride();
514 return derived().outerStride();
520 return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();
530 return Derived::IsRowMajor ? outerStride() : innerStride();
540 return Derived::IsRowMajor ? innerStride() : outerStride();
556 template<
typename Derived>
563 typedef typename internal::traits<Derived>::Scalar
Scalar;
578 return derived().innerStride();
589 return derived().outerStride();
595 return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();
605 return Derived::IsRowMajor ? outerStride() : innerStride();
615 return Derived::IsRowMajor ? innerStride() : outerStride();
621 template<
int Alignment,
typename Derived,
bool JustReturnZero>
622 struct first_aligned_impl
628 template<
int Alignment,
typename Derived>
629 struct first_aligned_impl<Alignment, Derived, false>
631 static inline Index run(
const Derived&
m)
633 return internal::first_aligned<Alignment>(
m.data(),
m.size());
644 template<
int Alignment,
typename Derived>
647 enum { ReturnZero = (int(evaluator<Derived>::Alignment) >= Alignment) || !(Derived::Flags &
DirectAccessBit) };
648 return first_aligned_impl<Alignment, Derived, ReturnZero>::run(
m.derived());
651 template<
typename Derived>
654 typedef typename Derived::Scalar Scalar;
655 typedef typename packet_traits<Scalar>::type DefaultPacketType;
659 template<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
660 struct inner_stride_at_compile_time
662 enum { ret = traits<Derived>::InnerStrideAtCompileTime };
665 template<
typename Derived>
666 struct inner_stride_at_compile_time<Derived, false>
671 template<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
672 struct outer_stride_at_compile_time
674 enum { ret = traits<Derived>::OuterStrideAtCompileTime };
677 template<
typename Derived>
678 struct outer_stride_at_compile_time<Derived, false>
RowXpr row(Index i)
This is the const version of row(). */.
ColXpr col(Index i)
This is the const version of col().
#define eigen_internal_assert(x)
#define EIGEN_DEVICE_FUNC
#define EIGEN_STATIC_ASSERT(X, MSG)
Eigen::Triplet< double > T
Base class for all dense matrices, vectors, and arrays.
EIGEN_CONSTEXPR Index stride() const
DenseCoeffsBase< Derived, ReadOnlyAccessors > Base
EIGEN_CONSTEXPR Index innerStride() const
EIGEN_CONSTEXPR Index rowStride() const
NumTraits< Scalar >::Real RealScalar
internal::traits< Derived >::Scalar Scalar
EIGEN_CONSTEXPR Index outerStride() const
EIGEN_CONSTEXPR Index colStride() const
NumTraits< Scalar >::Real RealScalar
EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index rowStride() const EIGEN_NOEXCEPT
DenseCoeffsBase< Derived, WriteAccessors > Base
internal::traits< Derived >::Scalar Scalar
EIGEN_CONSTEXPR Index stride() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index colStride() const EIGEN_NOEXCEPT
Base class providing read-only coefficient access to matrices and arrays.
internal::packet_traits< Scalar >::type PacketScalar
CoeffReturnType y() const
CoeffReturnType x() const
internal::traits< Derived >::StorageKind StorageKind
Index colIndexByOuterInner(Index outer, Index inner) const
void coeffRefByOuterInner()
CoeffReturnType operator[](Index index) const
void copyCoeffByOuterInner()
void writePacketByOuterInner()
Index rowIndexByOuterInner(Index outer, Index inner) const
CoeffReturnType z() const
internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits< Scalar >::type >::type PacketReturnType
PacketReturnType packet(Index index) const
CoeffReturnType w() const
std::conditional_t< bool(internal::traits< Derived >::Flags &LvalueBit), const Scalar &, std::conditional_t< internal::is_arithmetic< Scalar >::value, Scalar, const Scalar > > CoeffReturnType
CoeffReturnType coeff(Index index) const
CoeffReturnType operator()(Index row, Index col) const
internal::traits< Derived >::Scalar Scalar
PacketReturnType packetByOuterInner(Index outer, Index inner) const
CoeffReturnType coeffByOuterInner(Index outer, Index inner) const
EigenBase< Derived > Base
void copyPacketByOuterInner()
PacketReturnType packet(Index row, Index col) const
CoeffReturnType coeff(Index row, Index col) const
CoeffReturnType operator()(Index index) const
Base class providing read/write coefficient access to matrices and arrays.
Scalar & operator()(Index index)
Scalar & coeffRefByOuterInner(Index outer, Index inner)
NumTraits< Scalar >::Real RealScalar
DenseCoeffsBase< Derived, ReadOnlyAccessors > Base
internal::packet_traits< Scalar >::type PacketScalar
Scalar & operator[](Index index)
internal::traits< Derived >::Scalar Scalar
Scalar & coeffRef(Index row, Index col)
Scalar & coeffRef(Index index)
Scalar & operator()(Index row, Index col)
internal::traits< Derived >::StorageKind StorageKind
const unsigned int LinearAccessBit
const unsigned int DirectAccessBit
const unsigned int LvalueBit
const unsigned int RowMajorBit
static Index first_default_aligned(const DenseBase< Derived > &m)
static Index first_aligned(const DenseBase< Derived > &m)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::Index Index
The interface type of indices.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.