Skip to content
BlockMethods.h 36.5 KiB
Newer Older
Luker's avatar
Luker committed
/// \param  n the number of coefficients in the segment 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_start.cpp
/// Output: \verbinclude MatrixBase_template_int_start.out
///
/// \sa class Block
///
Luker's avatar
Luker committed
template<int N>
Luker's avatar
Luker committed
EIGEN_DEVICE_FUNC
Luker's avatar
Luker committed
inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
{
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
}

Luker's avatar
Luker committed
/// This is the const version of head<int>().
Luker's avatar
Luker committed
template<int N>
Luker's avatar
Luker committed
EIGEN_DEVICE_FUNC
Luker's avatar
Luker committed
inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
{
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
}

Luker's avatar
Luker committed
/// \returns a fixed-size expression of the last coefficients of *this.
///
/// \only_for_vectors
///
/// \tparam N the number of coefficients in the segment as specified at compile-time
/// \param  n the number of coefficients in the segment 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_end.cpp
/// Output: \verbinclude MatrixBase_template_int_end.out
///
/// \sa class Block
///
Luker's avatar
Luker committed
template<int N>
Luker's avatar
Luker committed
EIGEN_DEVICE_FUNC
Luker's avatar
Luker committed
inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
{
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
}

Luker's avatar
Luker committed
/// This is the const version of tail<int>.
Luker's avatar
Luker committed
template<int N>
Luker's avatar
Luker committed
EIGEN_DEVICE_FUNC
Luker's avatar
Luker committed
inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
{
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
}