Add typedefs for the return type of all block methods.

This commit is contained in:
Gael Guennebaud 2016-02-19 22:15:01 +01:00
parent f6f057bb7d
commit f3643eec57

View File

@ -8,7 +8,6 @@
// Public License v. 2.0. If a copy of the MPL was not distributed // 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/. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal expression type of a column */ /** \internal expression type of a column */
@ -29,6 +28,12 @@ template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, i
/** \internal expression type of a block of whole rows */ /** \internal expression type of a block of whole rows */
template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; }; template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; }; template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
/** \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 { typedef Block<Derived,Rows,Cols> Type; };
template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; };
typedef VectorBlock<Derived> SegmentReturnType; typedef VectorBlock<Derived> SegmentReturnType;
typedef const VectorBlock<const Derived> ConstSegmentReturnType; typedef const VectorBlock<const Derived> ConstSegmentReturnType;
@ -54,16 +59,16 @@ template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBloc
* \sa class Block, block(Index,Index) * \sa class Block, block(Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) inline BlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols)
{ {
return Block<Derived>(derived(), startRow, startCol, blockRows, blockCols); return BlockXpr(derived(), startRow, startCol, blockRows, blockCols);
} }
/** This is the const version of block(Index,Index,Index,Index). */ /** This is the const version of block(Index,Index,Index,Index). */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const inline const ConstBlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
{ {
return Block<const Derived>(derived(), startRow, startCol, blockRows, blockCols); return ConstBlockXpr(derived(), startRow, startCol, blockRows, blockCols);
} }
@ -80,16 +85,16 @@ inline const Block<const Derived> block(Index startRow, Index startCol, Index bl
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived> topRightCorner(Index cRows, Index cCols) inline BlockXpr topRightCorner(Index cRows, Index cCols)
{ {
return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols); return BlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
} }
/** This is the const version of topRightCorner(Index, Index).*/ /** This is the const version of topRightCorner(Index, Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const inline const ConstBlockXpr topRightCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols); return ConstBlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
} }
/** \returns an expression of a fixed-size top-right corner of *this. /** \returns an expression of a fixed-size top-right corner of *this.
@ -104,17 +109,17 @@ inline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived, CRows, CCols> topRightCorner() inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner()
{ {
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
} }
/** This is the const version of topRightCorner<int, int>().*/ /** This is the const version of topRightCorner<int, int>().*/
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived, CRows, CCols> topRightCorner() const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner() const
{ {
return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
} }
/** \returns an expression of a top-right corner of *this. /** \returns an expression of a top-right corner of *this.
@ -135,16 +140,16 @@ inline const Block<const Derived, CRows, CCols> topRightCorner() const
* \sa class Block * \sa class Block
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
inline Block<Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols)
{ {
return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
} }
/** This is the const version of topRightCorner<int, int>(Index, Index).*/ /** This is the const version of topRightCorner<int, int>(Index, Index).*/
template<int CRows, int CCols> template<int CRows, int CCols>
inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
} }
@ -160,16 +165,16 @@ inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Inde
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived> topLeftCorner(Index cRows, Index cCols) inline BlockXpr topLeftCorner(Index cRows, Index cCols)
{ {
return Block<Derived>(derived(), 0, 0, cRows, cCols); return BlockXpr(derived(), 0, 0, cRows, cCols);
} }
/** This is the const version of topLeftCorner(Index, Index).*/ /** This is the const version of topLeftCorner(Index, Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const inline const ConstBlockXpr topLeftCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived>(derived(), 0, 0, cRows, cCols); return ConstBlockXpr(derived(), 0, 0, cRows, cCols);
} }
/** \returns an expression of a fixed-size top-left corner of *this. /** \returns an expression of a fixed-size top-left corner of *this.
@ -183,17 +188,17 @@ inline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived, CRows, CCols> topLeftCorner() inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner()
{ {
return Block<Derived, CRows, CCols>(derived(), 0, 0); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
} }
/** This is the const version of topLeftCorner<int, int>().*/ /** This is the const version of topLeftCorner<int, int>().*/
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived, CRows, CCols> topLeftCorner() const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner() const
{ {
return Block<const Derived, CRows, CCols>(derived(), 0, 0); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
} }
/** \returns an expression of a top-left corner of *this. /** \returns an expression of a top-left corner of *this.
@ -214,16 +219,16 @@ inline const Block<const Derived, CRows, CCols> topLeftCorner() const
* \sa class Block * \sa class Block
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
inline Block<Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols)
{ {
return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
} }
/** This is the const version of topLeftCorner<int, int>(Index, Index).*/ /** This is the const version of topLeftCorner<int, int>(Index, Index).*/
template<int CRows, int CCols> template<int CRows, int CCols>
inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
} }
@ -239,16 +244,16 @@ inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived> bottomRightCorner(Index cRows, Index cCols) inline BlockXpr bottomRightCorner(Index cRows, Index cCols)
{ {
return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); return BlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
} }
/** This is the const version of bottomRightCorner(Index, Index).*/ /** This is the const version of bottomRightCorner(Index, Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) const inline const ConstBlockXpr bottomRightCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); return ConstBlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
} }
/** \returns an expression of a fixed-size bottom-right corner of *this. /** \returns an expression of a fixed-size bottom-right corner of *this.
@ -262,17 +267,17 @@ inline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) co
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived, CRows, CCols> bottomRightCorner() inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner()
{ {
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
} }
/** This is the const version of bottomRightCorner<int, int>().*/ /** This is the const version of bottomRightCorner<int, int>().*/
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived, CRows, CCols> bottomRightCorner() const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner() const
{ {
return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
} }
/** \returns an expression of a bottom-right corner of *this. /** \returns an expression of a bottom-right corner of *this.
@ -293,16 +298,16 @@ inline const Block<const Derived, CRows, CCols> bottomRightCorner() const
* \sa class Block * \sa class Block
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
inline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols)
{ {
return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
} }
/** This is the const version of bottomRightCorner<int, int>(Index, Index).*/ /** This is the const version of bottomRightCorner<int, int>(Index, Index).*/
template<int CRows, int CCols> template<int CRows, int CCols>
inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
} }
@ -318,16 +323,16 @@ inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, I
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived> bottomLeftCorner(Index cRows, Index cCols) inline BlockXpr bottomLeftCorner(Index cRows, Index cCols)
{ {
return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols); return BlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
} }
/** This is the const version of bottomLeftCorner(Index, Index).*/ /** This is the const version of bottomLeftCorner(Index, Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) const inline const ConstBlockXpr bottomLeftCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols); return ConstBlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
} }
/** \returns an expression of a fixed-size bottom-left corner of *this. /** \returns an expression of a fixed-size bottom-left corner of *this.
@ -341,17 +346,17 @@ inline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) con
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived, CRows, CCols> bottomLeftCorner() inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner()
{ {
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
} }
/** This is the const version of bottomLeftCorner<int, int>().*/ /** This is the const version of bottomLeftCorner<int, int>().*/
template<int CRows, int CCols> template<int CRows, int CCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() const
{ {
return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
} }
/** \returns an expression of a bottom-left corner of *this. /** \returns an expression of a bottom-left corner of *this.
@ -372,16 +377,16 @@ inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
* \sa class Block * \sa class Block
*/ */
template<int CRows, int CCols> template<int CRows, int CCols>
inline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols)
{ {
return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols); return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
} }
/** This is the const version of bottomLeftCorner<int, int>(Index, Index).*/ /** This is the const version of bottomLeftCorner<int, int>(Index, Index).*/
template<int CRows, int CCols> template<int CRows, int CCols>
inline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) const inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const
{ {
return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols); return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
} }
@ -704,7 +709,7 @@ inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n =
/** \returns a fixed-size expression of a block in *this. /** \returns a fixed-size expression of a block in *this.
* *
* The template parameters \a BlockRows and \a BlockCols are the number of * The template parameters \a NRows and \a NCols are the number of
* rows and columns in the block. * rows and columns in the block.
* *
* \param startRow the first row in the block * \param startRow the first row in the block
@ -718,25 +723,25 @@ inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n =
* *
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
template<int BlockRows, int BlockCols> template<int NRows, int NCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol)
{ {
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol); return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
} }
/** This is the const version of block<>(Index, Index). */ /** This is the const version of block<>(Index, Index). */
template<int BlockRows, int BlockCols> template<int NRows, int NCols>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) const
{ {
return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol); return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
} }
/** \returns an expression of a block in *this. /** \returns an expression of a block in *this.
* *
* \tparam BlockRows number of rows in block as specified at compile-time * \tparam NRows number of rows in block as specified at compile-time
* \tparam BlockCols number of columns in block as specified at compile-time * \tparam NCols number of columns in block as specified at compile-time
* \param startRow the first row in the block * \param startRow the first row in the block
* \param startCol the first column in the block * \param startCol the first column in the block
* \param blockRows number of rows in block as specified at run-time * \param blockRows number of rows in block as specified at run-time
@ -744,27 +749,27 @@ inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, In
* *
* This function is mainly useful for blocks where the number of rows is specified at compile-time * This function is mainly useful for blocks 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 * 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 blockRows should equal \a BlockRows unless * information should not contradict. In other words, \a blockRows should equal \a NRows unless
* \a BlockRows is \a Dynamic, and the same for the number of columns. * \a NRows is \a Dynamic, and the same for the number of columns.
* *
* Example: \include MatrixBase_template_int_int_block_int_int_int_int.cpp * Example: \include MatrixBase_template_int_int_block_int_int_int_int.cpp
* Output: \verbinclude MatrixBase_template_int_int_block_int_int_int_int.cpp * Output: \verbinclude MatrixBase_template_int_int_block_int_int_int_int.cpp
* *
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
template<int BlockRows, int BlockCols> template<int NRows, int NCols>
inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol, inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
Index blockRows, Index blockCols) Index blockRows, Index blockCols)
{ {
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols); return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
} }
/** This is the const version of block<>(Index, Index, Index, Index). */ /** This is the const version of block<>(Index, Index, Index, Index). */
template<int BlockRows, int BlockCols> template<int NRows, int NCols>
inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol, inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
Index blockRows, Index blockCols) const Index blockRows, Index blockCols) const
{ {
return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols); return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
} }
/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0. /** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.