// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008-2010 Gael Guennebaud <[email protected]> // Copyright (C) 2006-2010 Benoit Jacob <[email protected]> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_PARSED_BY_DOXYGEN /// \internal expression type of a column */ typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr; typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr; /// \internal expression type of a row */ typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr; typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr; /// \internal expression type of a block of whole columns */ typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr; typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr; /// \internal expression type of a block of whole rows */ typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr; typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr; /// \internal expression type of a block of whole columns */ template <int N> struct NColsBlockXpr { … }; template <int N> struct ConstNColsBlockXpr { … }; /// \internal expression type of a block of whole rows */ template <int N> struct NRowsBlockXpr { … }; template <int N> struct ConstNRowsBlockXpr { … }; /// \internal expression of a block */ typedef Block<Derived> BlockXpr; typedef const Block<const Derived> ConstBlockXpr; /// \internal expression of a block of fixed sizes */ template <int Rows, int Cols> struct FixedBlockXpr { … }; template <int Rows, int Cols> struct ConstFixedBlockXpr { … }; typedef VectorBlock<Derived> SegmentReturnType; typedef const VectorBlock<const Derived> ConstSegmentReturnType; template <int Size> struct FixedSegmentReturnType { … }; template <int Size> struct ConstFixedSegmentReturnType { … }; /// \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. /// /// \param startRow the first row in the block /// \param startCol the first column in the block /// \param blockRows number of rows in the block, specified at either run-time or compile-time /// \param blockCols number of columns in the block, specified at either run-time or compile-time /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. /// /// Example using runtime (aka dynamic) sizes: \include MatrixBase_block_int_int_int_int.cpp /// Output: \verbinclude MatrixBase_block_int_int_int_int.out /// /// \newin{3.4}: /// /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing /// Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. In the later case, \c n plays the role of a runtime fallback value /// in case \c N equals Eigen::Dynamic. Here is an example with a fixed number of rows \c NRows and dynamic number of /// columns \c cols: \code mat.block(i,j,fix<NRows>,cols) \endcode /// /// This function thus fully covers the features offered by the following overloads block<NRows,NCols>(Index, Index), /// and block<NRows,NCols>(Index, Index, Index, Index) that are thus obsolete. Indeed, this generic version avoids /// redundancy, it preserves the argument order, and prevents the need to rely on the template keyword in templated /// code. /// /// but with less redundancy and more consistency as it does not modify the argument order /// and seamlessly enable hybrid fixed/dynamic sizes. /// /// \note Even in the case that the returned expression has dynamic size, in the case /// when it is applied to a fixed-size matrix, it inherits a fixed maximal size, /// which means that evaluating it does not cause a dynamic memory allocation. /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa class Block, fix, fix<N>(int) /// template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else typename FixedBlockXpr<..., ...>::Type #endif block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols) { … } /// This is the const version of block(Index,Index,NRowsType,NColsType) template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else const typename ConstFixedBlockXpr<..., ...>::Type #endif block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols) const { … } /// \returns a expression of a top-right corner of \c *this with either dynamic or fixed sizes. /// /// \param cRows the number of rows in the corner /// \param cCols the number of columns in the corner /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. /// /// Example with dynamic sizes: \include MatrixBase_topRightCorner_int_int.cpp /// Output: \verbinclude MatrixBase_topRightCorner_int_int.out /// /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing /// Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink /// for the details. /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else typename FixedBlockXpr<..., ...>::Type #endif topRightCorner(NRowsType cRows, NColsType cCols) { … } /// This is the const version of topRightCorner(NRowsType, NColsType). template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else const typename ConstFixedBlockXpr<..., ...>::Type #endif topRightCorner(NRowsType cRows, NColsType cCols) const { … } /// \returns an expression of a fixed-size top-right corner of \c *this. /// /// \tparam CRows the number of rows in the corner /// \tparam CCols the number of columns in the corner /// /// Example: \include MatrixBase_template_int_int_topRightCorner.cpp /// Output: \verbinclude MatrixBase_template_int_int_topRightCorner.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa class Block, block<int,int>(Index,Index) /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type topRightCorner() { … } /// This is the const version of topRightCorner<int, int>(). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type topRightCorner() const { … } /// \returns an expression of a top-right corner of \c *this. /// /// \tparam CRows number of rows in corner as specified at compile-time /// \tparam CCols number of columns in corner as specified at compile-time /// \param cRows number of rows in corner as specified at run-time /// \param cCols number of columns in corner as specified at run-time /// /// This function is mainly useful for corners where the number of rows is specified at compile-time /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time /// information should not contradict. In other words, \a cRows should equal \a CRows unless /// \a CRows is \a Dynamic, and the same for the number of columns. /// /// Example: \include MatrixBase_template_int_int_topRightCorner_int_int.cpp /// Output: \verbinclude MatrixBase_template_int_int_topRightCorner_int_int.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa class Block /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type topRightCorner(Index cRows, Index cCols) { … } /// This is the const version of topRightCorner<int, int>(Index, Index). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type topRightCorner( Index cRows, Index cCols) const { … } /// \returns an expression of a top-left corner of \c *this with either dynamic or fixed sizes. /// /// \param cRows the number of rows in the corner /// \param cCols the number of columns in the corner /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. /// /// Example: \include MatrixBase_topLeftCorner_int_int.cpp /// Output: \verbinclude MatrixBase_topLeftCorner_int_int.out /// /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing /// Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink /// for the details. /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else typename FixedBlockXpr<..., ...>::Type #endif topLeftCorner(NRowsType cRows, NColsType cCols) { … } /// This is the const version of topLeftCorner(Index, Index). template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else const typename ConstFixedBlockXpr<..., ...>::Type #endif topLeftCorner(NRowsType cRows, NColsType cCols) const { … } /// \returns an expression of a fixed-size top-left corner of \c *this. /// /// The template parameters CRows and CCols are the number of rows and columns in the corner. /// /// Example: \include MatrixBase_template_int_int_topLeftCorner.cpp /// Output: \verbinclude MatrixBase_template_int_int_topLeftCorner.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type topLeftCorner() { … } /// This is the const version of topLeftCorner<int, int>(). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type topLeftCorner() const { … } /// \returns an expression of a top-left corner of \c *this. /// /// \tparam CRows number of rows in corner as specified at compile-time /// \tparam CCols number of columns in corner as specified at compile-time /// \param cRows number of rows in corner as specified at run-time /// \param cCols number of columns in corner as specified at run-time /// /// This function is mainly useful for corners where the number of rows is specified at compile-time /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time /// information should not contradict. In other words, \a cRows should equal \a CRows unless /// \a CRows is \a Dynamic, and the same for the number of columns. /// /// Example: \include MatrixBase_template_int_int_topLeftCorner_int_int.cpp /// Output: \verbinclude MatrixBase_template_int_int_topLeftCorner_int_int.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa class Block /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type topLeftCorner(Index cRows, Index cCols) { … } /// This is the const version of topLeftCorner<int, int>(Index, Index). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type topLeftCorner( Index cRows, Index cCols) const { … } /// \returns an expression of a bottom-right corner of \c *this with either dynamic or fixed sizes. /// /// \param cRows the number of rows in the corner /// \param cCols the number of columns in the corner /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. /// /// Example: \include MatrixBase_bottomRightCorner_int_int.cpp /// Output: \verbinclude MatrixBase_bottomRightCorner_int_int.out /// /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing /// Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink /// for the details. /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else typename FixedBlockXpr<..., ...>::Type #endif bottomRightCorner(NRowsType cRows, NColsType cCols) { … } /// This is the const version of bottomRightCorner(NRowsType, NColsType). template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else const typename ConstFixedBlockXpr<..., ...>::Type #endif bottomRightCorner(NRowsType cRows, NColsType cCols) const { … } /// \returns an expression of a fixed-size bottom-right corner of \c *this. /// /// The template parameters CRows and CCols are the number of rows and columns in the corner. /// /// Example: \include MatrixBase_template_int_int_bottomRightCorner.cpp /// Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type bottomRightCorner() { … } /// This is the const version of bottomRightCorner<int, int>(). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type bottomRightCorner() const { … } /// \returns an expression of a bottom-right corner of \c *this. /// /// \tparam CRows number of rows in corner as specified at compile-time /// \tparam CCols number of columns in corner as specified at compile-time /// \param cRows number of rows in corner as specified at run-time /// \param cCols number of columns in corner as specified at run-time /// /// This function is mainly useful for corners where the number of rows is specified at compile-time /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time /// information should not contradict. In other words, \a cRows should equal \a CRows unless /// \a CRows is \a Dynamic, and the same for the number of columns. /// /// Example: \include MatrixBase_template_int_int_bottomRightCorner_int_int.cpp /// Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner_int_int.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa class Block /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type bottomRightCorner(Index cRows, Index cCols) { … } /// This is the const version of bottomRightCorner<int, int>(Index, Index). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type bottomRightCorner( Index cRows, Index cCols) const { … } /// \returns an expression of a bottom-left corner of \c *this with either dynamic or fixed sizes. /// /// \param cRows the number of rows in the corner /// \param cCols the number of columns in the corner /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. /// /// Example: \include MatrixBase_bottomLeftCorner_int_int.cpp /// Output: \verbinclude MatrixBase_bottomLeftCorner_int_int.out /// /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing /// Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink /// for the details. /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else typename FixedBlockXpr<..., ...>::Type #endif bottomLeftCorner(NRowsType cRows, NColsType cCols) { … } /// This is the const version of bottomLeftCorner(NRowsType, NColsType). template <typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value, internal::get_fixed_value<NColsType>::value>::Type #else typename ConstFixedBlockXpr<..., ...>::Type #endif bottomLeftCorner(NRowsType cRows, NColsType cCols) const { … } /// \returns an expression of a fixed-size bottom-left corner of \c *this. /// /// The template parameters CRows and CCols are the number of rows and columns in the corner. /// /// Example: \include MatrixBase_template_int_int_bottomLeftCorner.cpp /// Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type bottomLeftCorner() { … } /// This is the const version of bottomLeftCorner<int, int>(). template <int CRows, int CCols> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type bottomLeftCorner() const { … } /// \returns an expression of a bottom-left corner of \c *this. /// /// \tparam CRows number of rows in corner as specified at compile-time /// \tparam CCols number of columns in corner as specified at compile-time /// \param cRows number of rows in corner as specified at run-time /// \param cCols number of columns in corner as specified at run-time /// /// This function is mainly useful for corners where the number of rows is specified at compile-time /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time /// information should not contradict. In other words, \a cRows should equal \a CRows unless /// \a CRows is \a Dynamic, and the same for the number of columns. /// /// Example: \include MatrixBase_template_int_int_bottomLeftCorner_int_int.cpp /// Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner_int_int.out /// EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL /// /// \sa class Block /// template <int CRows, int CCols> EIGEN_STRONG_INLINE typename FixedBlockXpr<CRows, CCols>::Type bottomLeftCorner(Index cRows, Index cCols) { … } /// This is the const version of bottomLeftCorner<int, int>(Index, Index). template <int CRows, int CCols> EIGEN_STRONG_INLINE const typename ConstFixedBlockXpr<CRows, CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const { … } /// \returns a block consisting of the top rows of \c *this. /// /// \param n the number of rows in the block /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. /// /// Example: \include MatrixBase_topRows_int.cpp /// Output: \verbinclude MatrixBase_topRows_int.out /// /// The number of rows \a n can also be specified at compile-time by passing Eigen::fix<N>, /// or Eigen::fix<N>(n) as arguments. /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. /// EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <typename NRowsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type #else typename NRowsBlockXpr<...>::Type #endif topRows(NRowsType n) { … } /// This is the const version of topRows(NRowsType). template <typename NRowsType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE #ifndef EIGEN_PARSED_BY_DOXYGEN const typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type #else const typename ConstNRowsBlockXpr<...>::Type #endif topRows(NRowsType n) const { … } /// \returns a block consisting of the top rows of \c *this. /// /// \tparam N the number of rows in the block as specified at compile-time /// \param n the number of rows in the block as specified at run-time /// /// The compile-time and run-time information should not contradict. In other words, /// \a n should equal \a N unless \a N is \a Dynamic. /// /// Example: \include MatrixBase_template_int_topRows.cpp /// Output: \verbinclude MatrixBase_template_int_topRows.out /// EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row - major) /// /// \sa block(Index,Index,NRowsType,NColsType), class Block /// template <int N> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NRowsBlockXpr<N>::Type topRows(Index n = …