Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:56:12

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 #ifndef EIGEN_DENSECOEFFSBASE_H
0011 #define EIGEN_DENSECOEFFSBASE_H
0012 
0013 namespace Eigen {
0014 
0015 namespace internal {
0016 template<typename T> struct add_const_on_value_type_if_arithmetic
0017 {
0018   typedef typename conditional<is_arithmetic<T>::value, T, typename add_const_on_value_type<T>::type>::type type;
0019 };
0020 }
0021 
0022 /** \brief Base class providing read-only coefficient access to matrices and arrays.
0023   * \ingroup Core_Module
0024   * \tparam Derived Type of the derived class
0025   *
0026   * \note #ReadOnlyAccessors Constant indicating read-only access
0027   *
0028   * This class defines the \c operator() \c const function and friends, which can be used to read specific
0029   * entries of a matrix or array.
0030   *
0031   * \sa DenseCoeffsBase<Derived, WriteAccessors>, DenseCoeffsBase<Derived, DirectAccessors>,
0032   *     \ref TopicClassHierarchy
0033   */
0034 template<typename Derived>
0035 class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived>
0036 {
0037   public:
0038     typedef typename internal::traits<Derived>::StorageKind StorageKind;
0039     typedef typename internal::traits<Derived>::Scalar Scalar;
0040     typedef typename internal::packet_traits<Scalar>::type PacketScalar;
0041 
0042     // Explanation for this CoeffReturnType typedef.
0043     // - This is the return type of the coeff() method.
0044     // - The LvalueBit means exactly that we can offer a coeffRef() method, which means exactly that we can get references
0045     // to coeffs, which means exactly that we can have coeff() return a const reference (as opposed to returning a value).
0046     // - The is_artihmetic check is required since "const int", "const double", etc. will cause warnings on some systems
0047     // while the declaration of "const T", where T is a non arithmetic type does not. Always returning "const Scalar&" is
0048     // not possible, since the underlying expressions might not offer a valid address the reference could be referring to.
0049     typedef typename internal::conditional<bool(internal::traits<Derived>::Flags&LvalueBit),
0050                          const Scalar&,
0051                          typename internal::conditional<internal::is_arithmetic<Scalar>::value, Scalar, const Scalar>::type
0052                      >::type CoeffReturnType;
0053 
0054     typedef typename internal::add_const_on_value_type_if_arithmetic<
0055                          typename internal::packet_traits<Scalar>::type
0056                      >::type PacketReturnType;
0057 
0058     typedef EigenBase<Derived> Base;
0059     using Base::rows;
0060     using Base::cols;
0061     using Base::size;
0062     using Base::derived;
0063 
0064     EIGEN_DEVICE_FUNC
0065     EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner) const
0066     {
0067       return int(Derived::RowsAtCompileTime) == 1 ? 0
0068           : int(Derived::ColsAtCompileTime) == 1 ? inner
0069           : int(Derived::Flags)&RowMajorBit ? outer
0070           : inner;
0071     }
0072 
0073     EIGEN_DEVICE_FUNC
0074     EIGEN_STRONG_INLINE Index colIndexByOuterInner(Index outer, Index inner) const
0075     {
0076       return int(Derived::ColsAtCompileTime) == 1 ? 0
0077           : int(Derived::RowsAtCompileTime) == 1 ? inner
0078           : int(Derived::Flags)&RowMajorBit ? inner
0079           : outer;
0080     }
0081 
0082     /** Short version: don't use this function, use
0083       * \link operator()(Index,Index) const \endlink instead.
0084       *
0085       * Long version: this function is similar to
0086       * \link operator()(Index,Index) const \endlink, but without the assertion.
0087       * Use this for limiting the performance cost of debugging code when doing
0088       * repeated coefficient access. Only use this when it is guaranteed that the
0089       * parameters \a row and \a col are in range.
0090       *
0091       * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
0092       * function equivalent to \link operator()(Index,Index) const \endlink.
0093       *
0094       * \sa operator()(Index,Index) const, coeffRef(Index,Index), coeff(Index) const
0095       */
0096     EIGEN_DEVICE_FUNC
0097     EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const
0098     {
0099       eigen_internal_assert(row >= 0 && row < rows()
0100                          && col >= 0 && col < cols());
0101       return internal::evaluator<Derived>(derived()).coeff(row,col);
0102     }
0103 
0104     EIGEN_DEVICE_FUNC
0105     EIGEN_STRONG_INLINE CoeffReturnType coeffByOuterInner(Index outer, Index inner) const
0106     {
0107       return coeff(rowIndexByOuterInner(outer, inner),
0108                    colIndexByOuterInner(outer, inner));
0109     }
0110 
0111     /** \returns the coefficient at given the given row and column.
0112       *
0113       * \sa operator()(Index,Index), operator[](Index)
0114       */
0115     EIGEN_DEVICE_FUNC
0116     EIGEN_STRONG_INLINE CoeffReturnType operator()(Index row, Index col) const
0117     {
0118       eigen_assert(row >= 0 && row < rows()
0119           && col >= 0 && col < cols());
0120       return coeff(row, col);
0121     }
0122 
0123     /** Short version: don't use this function, use
0124       * \link operator[](Index) const \endlink instead.
0125       *
0126       * Long version: this function is similar to
0127       * \link operator[](Index) const \endlink, but without the assertion.
0128       * Use this for limiting the performance cost of debugging code when doing
0129       * repeated coefficient access. Only use this when it is guaranteed that the
0130       * parameter \a index is in range.
0131       *
0132       * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
0133       * function equivalent to \link operator[](Index) const \endlink.
0134       *
0135       * \sa operator[](Index) const, coeffRef(Index), coeff(Index,Index) const
0136       */
0137 
0138     EIGEN_DEVICE_FUNC
0139     EIGEN_STRONG_INLINE CoeffReturnType
0140     coeff(Index index) const
0141     {
0142       EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
0143                           THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
0144       eigen_internal_assert(index >= 0 && index < size());
0145       return internal::evaluator<Derived>(derived()).coeff(index);
0146     }
0147 
0148 
0149     /** \returns the coefficient at given index.
0150       *
0151       * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
0152       *
0153       * \sa operator[](Index), operator()(Index,Index) const, x() const, y() const,
0154       * z() const, w() const
0155       */
0156 
0157     EIGEN_DEVICE_FUNC
0158     EIGEN_STRONG_INLINE CoeffReturnType
0159     operator[](Index index) const
0160     {
0161       EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
0162                           THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
0163       eigen_assert(index >= 0 && index < size());
0164       return coeff(index);
0165     }
0166 
0167     /** \returns the coefficient at given index.
0168       *
0169       * This is synonymous to operator[](Index) const.
0170       *
0171       * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
0172       *
0173       * \sa operator[](Index), operator()(Index,Index) const, x() const, y() const,
0174       * z() const, w() const
0175       */
0176 
0177     EIGEN_DEVICE_FUNC
0178     EIGEN_STRONG_INLINE CoeffReturnType
0179     operator()(Index index) const
0180     {
0181       eigen_assert(index >= 0 && index < size());
0182       return coeff(index);
0183     }
0184 
0185     /** equivalent to operator[](0).  */
0186 
0187     EIGEN_DEVICE_FUNC
0188     EIGEN_STRONG_INLINE CoeffReturnType
0189     x() const { return (*this)[0]; }
0190 
0191     /** equivalent to operator[](1).  */
0192 
0193     EIGEN_DEVICE_FUNC
0194     EIGEN_STRONG_INLINE CoeffReturnType
0195     y() const
0196     {
0197       EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=2, OUT_OF_RANGE_ACCESS);
0198       return (*this)[1];
0199     }
0200 
0201     /** equivalent to operator[](2).  */
0202 
0203     EIGEN_DEVICE_FUNC
0204     EIGEN_STRONG_INLINE CoeffReturnType
0205     z() const
0206     {
0207       EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=3, OUT_OF_RANGE_ACCESS);
0208       return (*this)[2];
0209     }
0210 
0211     /** equivalent to operator[](3).  */
0212 
0213     EIGEN_DEVICE_FUNC
0214     EIGEN_STRONG_INLINE CoeffReturnType
0215     w() const
0216     {
0217       EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=4, OUT_OF_RANGE_ACCESS);
0218       return (*this)[3];
0219     }
0220 
0221     /** \internal
0222       * \returns the packet of coefficients starting at the given row and column. It is your responsibility
0223       * to ensure that a packet really starts there. This method is only available on expressions having the
0224       * PacketAccessBit.
0225       *
0226       * The \a LoadMode parameter may have the value \a #Aligned or \a #Unaligned. Its effect is to select
0227       * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets
0228       * starting at an address which is a multiple of the packet size.
0229       */
0230 
0231     template<int LoadMode>
0232     EIGEN_STRONG_INLINE PacketReturnType packet(Index row, Index col) const
0233     {
0234       typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
0235       eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
0236       return internal::evaluator<Derived>(derived()).template packet<LoadMode,DefaultPacketType>(row,col);
0237     }
0238 
0239 
0240     /** \internal */
0241     template<int LoadMode>
0242     EIGEN_STRONG_INLINE PacketReturnType packetByOuterInner(Index outer, Index inner) const
0243     {
0244       return packet<LoadMode>(rowIndexByOuterInner(outer, inner),
0245                               colIndexByOuterInner(outer, inner));
0246     }
0247 
0248     /** \internal
0249       * \returns the packet of coefficients starting at the given index. It is your responsibility
0250       * to ensure that a packet really starts there. This method is only available on expressions having the
0251       * PacketAccessBit and the LinearAccessBit.
0252       *
0253       * The \a LoadMode parameter may have the value \a #Aligned or \a #Unaligned. Its effect is to select
0254       * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets
0255       * starting at an address which is a multiple of the packet size.
0256       */
0257 
0258     template<int LoadMode>
0259     EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
0260     {
0261       EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
0262                           THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
0263       typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;
0264       eigen_internal_assert(index >= 0 && index < size());
0265       return internal::evaluator<Derived>(derived()).template packet<LoadMode,DefaultPacketType>(index);
0266     }
0267 
0268   protected:
0269     // explanation: DenseBase is doing "using ..." on the methods from DenseCoeffsBase.
0270     // But some methods are only available in the DirectAccess case.
0271     // So we add dummy methods here with these names, so that "using... " doesn't fail.
0272     // It's not private so that the child class DenseBase can access them, and it's not public
0273     // either since it's an implementation detail, so has to be protected.
0274     void coeffRef();
0275     void coeffRefByOuterInner();
0276     void writePacket();
0277     void writePacketByOuterInner();
0278     void copyCoeff();
0279     void copyCoeffByOuterInner();
0280     void copyPacket();
0281     void copyPacketByOuterInner();
0282     void stride();
0283     void innerStride();
0284     void outerStride();
0285     void rowStride();
0286     void colStride();
0287 };
0288 
0289 /** \brief Base class providing read/write coefficient access to matrices and arrays.
0290   * \ingroup Core_Module
0291   * \tparam Derived Type of the derived class
0292   *
0293   * \note #WriteAccessors Constant indicating read/write access
0294   *
0295   * This class defines the non-const \c operator() function and friends, which can be used to write specific
0296   * entries of a matrix or array. This class inherits DenseCoeffsBase<Derived, ReadOnlyAccessors> which
0297   * defines the const variant for reading specific entries.
0298   *
0299   * \sa DenseCoeffsBase<Derived, DirectAccessors>, \ref TopicClassHierarchy
0300   */
0301 template<typename Derived>
0302 class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, ReadOnlyAccessors>
0303 {
0304   public:
0305 
0306     typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base;
0307 
0308     typedef typename internal::traits<Derived>::StorageKind StorageKind;
0309     typedef typename internal::traits<Derived>::Scalar Scalar;
0310     typedef typename internal::packet_traits<Scalar>::type PacketScalar;
0311     typedef typename NumTraits<Scalar>::Real RealScalar;
0312 
0313     using Base::coeff;
0314     using Base::rows;
0315     using Base::cols;
0316     using Base::size;
0317     using Base::derived;
0318     using Base::rowIndexByOuterInner;
0319     using Base::colIndexByOuterInner;
0320     using Base::operator[];
0321     using Base::operator();
0322     using Base::x;
0323     using Base::y;
0324     using Base::z;
0325     using Base::w;
0326 
0327     /** Short version: don't use this function, use
0328       * \link operator()(Index,Index) \endlink instead.
0329       *
0330       * Long version: this function is similar to
0331       * \link operator()(Index,Index) \endlink, but without the assertion.
0332       * Use this for limiting the performance cost of debugging code when doing
0333       * repeated coefficient access. Only use this when it is guaranteed that the
0334       * parameters \a row and \a col are in range.
0335       *
0336       * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
0337       * function equivalent to \link operator()(Index,Index) \endlink.
0338       *
0339       * \sa operator()(Index,Index), coeff(Index, Index) const, coeffRef(Index)
0340       */
0341     EIGEN_DEVICE_FUNC
0342     EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col)
0343     {
0344       eigen_internal_assert(row >= 0 && row < rows()
0345                          && col >= 0 && col < cols());
0346       return internal::evaluator<Derived>(derived()).coeffRef(row,col);
0347     }
0348 
0349     EIGEN_DEVICE_FUNC
0350     EIGEN_STRONG_INLINE Scalar&
0351     coeffRefByOuterInner(Index outer, Index inner)
0352     {
0353       return coeffRef(rowIndexByOuterInner(outer, inner),
0354                       colIndexByOuterInner(outer, inner));
0355     }
0356 
0357     /** \returns a reference to the coefficient at given the given row and column.
0358       *
0359       * \sa operator[](Index)
0360       */
0361 
0362     EIGEN_DEVICE_FUNC
0363     EIGEN_STRONG_INLINE Scalar&
0364     operator()(Index row, Index col)
0365     {
0366       eigen_assert(row >= 0 && row < rows()
0367           && col >= 0 && col < cols());
0368       return coeffRef(row, col);
0369     }
0370 
0371 
0372     /** Short version: don't use this function, use
0373       * \link operator[](Index) \endlink instead.
0374       *
0375       * Long version: this function is similar to
0376       * \link operator[](Index) \endlink, but without the assertion.
0377       * Use this for limiting the performance cost of debugging code when doing
0378       * repeated coefficient access. Only use this when it is guaranteed that the
0379       * parameters \a row and \a col are in range.
0380       *
0381       * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
0382       * function equivalent to \link operator[](Index) \endlink.
0383       *
0384       * \sa operator[](Index), coeff(Index) const, coeffRef(Index,Index)
0385       */
0386 
0387     EIGEN_DEVICE_FUNC
0388     EIGEN_STRONG_INLINE Scalar&
0389     coeffRef(Index index)
0390     {
0391       EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
0392                           THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)
0393       eigen_internal_assert(index >= 0 && index < size());
0394       return internal::evaluator<Derived>(derived()).coeffRef(index);
0395     }
0396 
0397     /** \returns a reference to the coefficient at given index.
0398       *
0399       * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
0400       *
0401       * \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()
0402       */
0403 
0404     EIGEN_DEVICE_FUNC
0405     EIGEN_STRONG_INLINE Scalar&
0406     operator[](Index index)
0407     {
0408       EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
0409                           THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
0410       eigen_assert(index >= 0 && index < size());
0411       return coeffRef(index);
0412     }
0413 
0414     /** \returns a reference to the coefficient at given index.
0415       *
0416       * This is synonymous to operator[](Index).
0417       *
0418       * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
0419       *
0420       * \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()
0421       */
0422 
0423     EIGEN_DEVICE_FUNC
0424     EIGEN_STRONG_INLINE Scalar&
0425     operator()(Index index)
0426     {
0427       eigen_assert(index >= 0 && index < size());
0428       return coeffRef(index);
0429     }
0430 
0431     /** equivalent to operator[](0).  */
0432 
0433     EIGEN_DEVICE_FUNC
0434     EIGEN_STRONG_INLINE Scalar&
0435     x() { return (*this)[0]; }
0436 
0437     /** equivalent to operator[](1).  */
0438 
0439     EIGEN_DEVICE_FUNC
0440     EIGEN_STRONG_INLINE Scalar&
0441     y()
0442     {
0443       EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=2, OUT_OF_RANGE_ACCESS);
0444       return (*this)[1];
0445     }
0446 
0447     /** equivalent to operator[](2).  */
0448 
0449     EIGEN_DEVICE_FUNC
0450     EIGEN_STRONG_INLINE Scalar&
0451     z()
0452     {
0453       EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=3, OUT_OF_RANGE_ACCESS);
0454       return (*this)[2];
0455     }
0456 
0457     /** equivalent to operator[](3).  */
0458 
0459     EIGEN_DEVICE_FUNC
0460     EIGEN_STRONG_INLINE Scalar&
0461     w()
0462     {
0463       EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=4, OUT_OF_RANGE_ACCESS);
0464       return (*this)[3];
0465     }
0466 };
0467 
0468 /** \brief Base class providing direct read-only coefficient access to matrices and arrays.
0469   * \ingroup Core_Module
0470   * \tparam Derived Type of the derived class
0471   *
0472   * \note #DirectAccessors Constant indicating direct access
0473   *
0474   * This class defines functions to work with strides which can be used to access entries directly. This class
0475   * inherits DenseCoeffsBase<Derived, ReadOnlyAccessors> which defines functions to access entries read-only using
0476   * \c operator() .
0477   *
0478   * \sa \blank \ref TopicClassHierarchy
0479   */
0480 template<typename Derived>
0481 class DenseCoeffsBase<Derived, DirectAccessors> : public DenseCoeffsBase<Derived, ReadOnlyAccessors>
0482 {
0483   public:
0484 
0485     typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base;
0486     typedef typename internal::traits<Derived>::Scalar Scalar;
0487     typedef typename NumTraits<Scalar>::Real RealScalar;
0488 
0489     using Base::rows;
0490     using Base::cols;
0491     using Base::size;
0492     using Base::derived;
0493 
0494     /** \returns the pointer increment between two consecutive elements within a slice in the inner direction.
0495       *
0496       * \sa outerStride(), rowStride(), colStride()
0497       */
0498     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0499     inline Index innerStride() const
0500     {
0501       return derived().innerStride();
0502     }
0503 
0504     /** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns
0505       *          in a column-major matrix).
0506       *
0507       * \sa innerStride(), rowStride(), colStride()
0508       */
0509     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0510     inline Index outerStride() const
0511     {
0512       return derived().outerStride();
0513     }
0514 
0515     // FIXME shall we remove it ?
0516     EIGEN_CONSTEXPR inline Index stride() const
0517     {
0518       return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();
0519     }
0520 
0521     /** \returns the pointer increment between two consecutive rows.
0522       *
0523       * \sa innerStride(), outerStride(), colStride()
0524       */
0525     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0526     inline Index rowStride() const
0527     {
0528       return Derived::IsRowMajor ? outerStride() : innerStride();
0529     }
0530 
0531     /** \returns the pointer increment between two consecutive columns.
0532       *
0533       * \sa innerStride(), outerStride(), rowStride()
0534       */
0535     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0536     inline Index colStride() const
0537     {
0538       return Derived::IsRowMajor ? innerStride() : outerStride();
0539     }
0540 };
0541 
0542 /** \brief Base class providing direct read/write coefficient access to matrices and arrays.
0543   * \ingroup Core_Module
0544   * \tparam Derived Type of the derived class
0545   *
0546   * \note #DirectWriteAccessors Constant indicating direct access
0547   *
0548   * This class defines functions to work with strides which can be used to access entries directly. This class
0549   * inherits DenseCoeffsBase<Derived, WriteAccessors> which defines functions to access entries read/write using
0550   * \c operator().
0551   *
0552   * \sa \blank \ref TopicClassHierarchy
0553   */
0554 template<typename Derived>
0555 class DenseCoeffsBase<Derived, DirectWriteAccessors>
0556   : public DenseCoeffsBase<Derived, WriteAccessors>
0557 {
0558   public:
0559 
0560     typedef DenseCoeffsBase<Derived, WriteAccessors> Base;
0561     typedef typename internal::traits<Derived>::Scalar Scalar;
0562     typedef typename NumTraits<Scalar>::Real RealScalar;
0563 
0564     using Base::rows;
0565     using Base::cols;
0566     using Base::size;
0567     using Base::derived;
0568 
0569     /** \returns the pointer increment between two consecutive elements within a slice in the inner direction.
0570       *
0571       * \sa outerStride(), rowStride(), colStride()
0572       */
0573     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0574     inline Index innerStride() const EIGEN_NOEXCEPT
0575     {
0576       return derived().innerStride();
0577     }
0578 
0579     /** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns
0580       *          in a column-major matrix).
0581       *
0582       * \sa innerStride(), rowStride(), colStride()
0583       */
0584     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0585     inline Index outerStride() const EIGEN_NOEXCEPT
0586     {
0587       return derived().outerStride();
0588     }
0589 
0590     // FIXME shall we remove it ?
0591     EIGEN_CONSTEXPR inline Index stride() const EIGEN_NOEXCEPT
0592     {
0593       return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();
0594     }
0595 
0596     /** \returns the pointer increment between two consecutive rows.
0597       *
0598       * \sa innerStride(), outerStride(), colStride()
0599       */
0600     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0601     inline Index rowStride() const EIGEN_NOEXCEPT
0602     {
0603       return Derived::IsRowMajor ? outerStride() : innerStride();
0604     }
0605 
0606     /** \returns the pointer increment between two consecutive columns.
0607       *
0608       * \sa innerStride(), outerStride(), rowStride()
0609       */
0610     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0611     inline Index colStride() const EIGEN_NOEXCEPT
0612     {
0613       return Derived::IsRowMajor ? innerStride() : outerStride();
0614     }
0615 };
0616 
0617 namespace internal {
0618 
0619 template<int Alignment, typename Derived, bool JustReturnZero>
0620 struct first_aligned_impl
0621 {
0622   static EIGEN_CONSTEXPR inline Index run(const Derived&) EIGEN_NOEXCEPT
0623   { return 0; }
0624 };
0625 
0626 template<int Alignment, typename Derived>
0627 struct first_aligned_impl<Alignment, Derived, false>
0628 {
0629   static inline Index run(const Derived& m)
0630   {
0631     return internal::first_aligned<Alignment>(m.data(), m.size());
0632   }
0633 };
0634 
0635 /** \internal \returns the index of the first element of the array stored by \a m that is properly aligned with respect to \a Alignment for vectorization.
0636   *
0637   * \tparam Alignment requested alignment in Bytes.
0638   *
0639   * There is also the variant first_aligned(const Scalar*, Integer) defined in Memory.h. See it for more
0640   * documentation.
0641   */
0642 template<int Alignment, typename Derived>
0643 static inline Index first_aligned(const DenseBase<Derived>& m)
0644 {
0645   enum { ReturnZero = (int(evaluator<Derived>::Alignment) >= Alignment) || !(Derived::Flags & DirectAccessBit) };
0646   return first_aligned_impl<Alignment, Derived, ReturnZero>::run(m.derived());
0647 }
0648 
0649 template<typename Derived>
0650 static inline Index first_default_aligned(const DenseBase<Derived>& m)
0651 {
0652   typedef typename Derived::Scalar Scalar;
0653   typedef typename packet_traits<Scalar>::type DefaultPacketType;
0654   return internal::first_aligned<int(unpacket_traits<DefaultPacketType>::alignment),Derived>(m);
0655 }
0656 
0657 template<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
0658 struct inner_stride_at_compile_time
0659 {
0660   enum { ret = traits<Derived>::InnerStrideAtCompileTime };
0661 };
0662 
0663 template<typename Derived>
0664 struct inner_stride_at_compile_time<Derived, false>
0665 {
0666   enum { ret = 0 };
0667 };
0668 
0669 template<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>
0670 struct outer_stride_at_compile_time
0671 {
0672   enum { ret = traits<Derived>::OuterStrideAtCompileTime };
0673 };
0674 
0675 template<typename Derived>
0676 struct outer_stride_at_compile_time<Derived, false>
0677 {
0678   enum { ret = 0 };
0679 };
0680 
0681 } // end namespace internal
0682 
0683 } // end namespace Eigen
0684 
0685 #endif // EIGEN_DENSECOEFFSBASE_H