diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-09-09 09:30:23 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-09-09 09:30:23 +0000 |
commit | 703539110b5c26f01ac37fe6114afdbb5c3c6c99 (patch) | |
tree | 16be3c0fbdab00bcfa895799f1f73b5015afb30a /Eigen | |
parent | c41ceee7508965a9f571e6b67f3e396943c6376c (diff) |
add the missing templated version of block for sub-vectors
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/Geometry | 7 | ||||
-rw-r--r-- | Eigen/src/Array/AllAndAny.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/Block.h | 38 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 3 |
4 files changed, 44 insertions, 8 deletions
diff --git a/Eigen/Geometry b/Eigen/Geometry index 1ac279b99..2a2dfda2b 100644 --- a/Eigen/Geometry +++ b/Eigen/Geometry @@ -1,7 +1,7 @@ #ifndef EIGEN_GEOMETRY_MODULE_H #define EIGEN_GEOMETRY_MODULE_H -#include "Core" +#include "Array" #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -23,11 +23,6 @@ namespace Eigen { * \endcode */ -// the Geometry module use cwiseCos and cwiseSin which are defined in the Array module -#include "src/Array/CwiseOperators.h" -#include "src/Array/Functors.h" -#include "src/Array/PartialRedux.h" - #include "src/Geometry/OrthoMethods.h" #include "src/Geometry/RotationBase.h" #include "src/Geometry/Rotation2D.h" diff --git a/Eigen/src/Array/AllAndAny.h b/Eigen/src/Array/AllAndAny.h index 76cc2db84..cc4560b2f 100644 --- a/Eigen/src/Array/AllAndAny.h +++ b/Eigen/src/Array/AllAndAny.h @@ -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; diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 18fcdbb2b..71ad6d5f1 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -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 diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index a9d15032c..81aae3593 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -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; |