add the missing templated version of block for sub-vectors

This commit is contained in:
Gael Guennebaud
2008-09-09 09:30:23 +00:00
parent c41ceee750
commit 703539110b
7 changed files with 67 additions and 8 deletions

View File

@@ -89,7 +89,7 @@ struct ei_any_unroller<Derived, Dynamic>
* \sa MatrixBase::any(), Cwise::operator<()
*/
template<typename Derived>
bool MatrixBase<Derived>::all(void) const
inline bool MatrixBase<Derived>::all(void) const
{
const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
<= EIGEN_UNROLLING_LIMIT;
@@ -113,7 +113,7 @@ bool MatrixBase<Derived>::all(void) const
* \sa MatrixBase::all()
*/
template<typename Derived>
bool MatrixBase<Derived>::any(void) const
inline bool MatrixBase<Derived>::any(void) const
{
const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
<= EIGEN_UNROLLING_LIMIT;

View File

@@ -451,6 +451,44 @@ MatrixBase<Derived>::end(int size) const
ColsAtCompileTime == 1 ? 1 : size);
}
/** \returns a fixed-size expression of a sub-vector of \c *this
*
* \only_for_vectors
*
* The template parameter \a Size is the number of coefficients in the block
*
* \param start the index of the first element of the sub-vector
*
* Example: \include MatrixBase_template_int.cpp
* Output: \verbinclude MatrixBase_template_int.out
*
* \sa class Block
*/
template<typename Derived>
template<int Size>
inline typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::block(int start)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
(ColsAtCompileTime == 1 ? 1 : Size)>
(derived(), RowsAtCompileTime == 1 ? 0 : start,
ColsAtCompileTime == 1 ? 0 : start);
}
/** This is the const version of block<int>(int).*/
template<typename Derived>
template<int Size>
inline const typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::block(int start) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
(ColsAtCompileTime == 1 ? 1 : Size)>
(derived(), RowsAtCompileTime == 1 ? 0 : start,
ColsAtCompileTime == 1 ? 0 : start);
}
/** \returns a fixed-size expression of the first coefficients of *this.
*
* \only_for_vectors

View File

@@ -381,6 +381,9 @@ template<typename Derived> class MatrixBase
template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType end();
template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType end() const;
template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType block(int start);
template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType block(int start) const;
DiagonalCoeffs<Derived> diagonal();
const DiagonalCoeffs<Derived> diagonal() const;