diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-04-04 15:09:21 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-04-04 15:09:21 +0200 |
commit | 368dd4cd9d18cf904b2ce3c4de18020269dcbba1 (patch) | |
tree | 94d5a95599a0d2b17b3d473fe1c0b8cf8266f596 /Eigen/src/plugins | |
parent | e116f6847e3cd9d16ea3be14c2b7efbd0a1c2b0b (diff) |
Make innerVector() and innerVectors() methods available to all expressions supported by Block.
Before, only SparseBase exposed such methods.
Diffstat (limited to 'Eigen/src/plugins')
-rw-r--r-- | Eigen/src/plugins/BlockMethods.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Eigen/src/plugins/BlockMethods.h b/Eigen/src/plugins/BlockMethods.h index 5caf14469..5fcd13cc4 100644 --- a/Eigen/src/plugins/BlockMethods.h +++ b/Eigen/src/plugins/BlockMethods.h @@ -40,6 +40,14 @@ typedef const VectorBlock<const Derived> ConstSegmentReturnType; template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; }; template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; }; +/// \internal inner-vector +typedef Block<Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> InnerVectorReturnType; +typedef Block<const Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> ConstInnerVectorReturnType; + +/// \internal set of inner-vectors +typedef Block<Derived,Dynamic,Dynamic,true> InnerVectorsReturnType; +typedef Block<const Derived,Dynamic,Dynamic,true> ConstInnerVectorsReturnType; + #endif // not EIGEN_PARSED_BY_DOXYGEN /// \returns an expression of a block in \c *this with either dynamic or fixed sizes. @@ -1354,3 +1362,39 @@ inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n); } + +/// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this +/// is col-major (resp. row-major). +/// +InnerVectorReturnType innerVector(Index outer) +{ return InnerVectorReturnType(derived(), outer); } + +/// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this +/// is col-major (resp. row-major). Read-only. +/// +const ConstInnerVectorReturnType innerVector(Index outer) const +{ return ConstInnerVectorReturnType(derived(), outer); } + +/// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this +/// is col-major (resp. row-major). +/// +InnerVectorsReturnType +innerVectors(Index outerStart, Index outerSize) +{ + return Block<Derived,Dynamic,Dynamic,true>(derived(), + IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart, + IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize); + +} + +/// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this +/// is col-major (resp. row-major). Read-only. +/// +const ConstInnerVectorsReturnType +innerVectors(Index outerStart, Index outerSize) const +{ + return Block<const Derived,Dynamic,Dynamic,true>(derived(), + IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart, + IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize); + +}
\ No newline at end of file |