diff options
author | yoco <peter.xiau@gmail.com> | 2014-01-18 04:21:20 +0800 |
---|---|---|
committer | yoco <peter.xiau@gmail.com> | 2014-01-18 04:21:20 +0800 |
commit | fe2ad0647afbe920dae6de60b814d84d76c5f65d (patch) | |
tree | 332aafcccc7c4e3700edfda1e0db8c8b15b38acb | |
parent | 7bd58ad0b6fe260b0b555ba75a798097500523b1 (diff) |
reshape now supported
- add member function to plugin
- add forward declaration
- add documentation
- add include
-rw-r--r-- | Eigen/Core | 1 | ||||
-rw-r--r-- | Eigen/src/Core/util/ForwardDeclarations.h | 1 | ||||
-rw-r--r-- | Eigen/src/plugins/BlockMethods.h | 56 |
3 files changed, 58 insertions, 0 deletions
diff --git a/Eigen/Core b/Eigen/Core index 468ae0c76..f1c952832 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -345,6 +345,7 @@ using std::ptrdiff_t; #include "src/Core/Stride.h" #include "src/Core/Map.h" #include "src/Core/Block.h" +#include "src/Core/Reshape.h" #include "src/Core/VectorBlock.h" #include "src/Core/Ref.h" #include "src/Core/Transpose.h" diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 0a2144c69..a4f3435bb 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -79,6 +79,7 @@ template<typename ExpressionType> class ForceAlignedAccess; template<typename ExpressionType> class SwapWrapper; template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false> class Block; +template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false> class Reshape; template<typename MatrixType, int Size=Dynamic> class VectorBlock; template<typename MatrixType> class Transpose; diff --git a/Eigen/src/plugins/BlockMethods.h b/Eigen/src/plugins/BlockMethods.h index 9b7fdc4aa..d1da27766 100644 --- a/Eigen/src/plugins/BlockMethods.h +++ b/Eigen/src/plugins/BlockMethods.h @@ -993,3 +993,59 @@ inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n); } + +/** \returns a dynamic-size expression of a reshape in *this. + * + * \param reshapeRows the number of rows in the reshape + * \param reshapeCols the number of columns in the reshape + * + * Example: \include MatrixBase_reshape_int_int.cpp + * Output: \verbinclude MatrixBase_reshape_int_int.out + * + * \note Even though 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. + * + * \sa class Reshape, reshape() + */ +EIGEN_DEVICE_FUNC +inline Reshape<Derived> reshape(Index reshapeRows, Index reshapeCols) +{ + return Reshape<Derived>(derived(), reshapeRows, reshapeCols); +} + +/** This is the const version of reshape(Index,Index). */ +EIGEN_DEVICE_FUNC +inline const Reshape<const Derived> reshape(Index reshapeRows, Index reshapeCols) const +{ + return Reshape<const Derived>(derived(), reshapeRows, reshapeCols); +} + +/** \returns a fixed-size expression of a reshape in *this. + * + * The template parameters \a ReshapeRows and \a ReshapeCols are the number of + * rows and columns in the reshape. + * + * Example: \include MatrixBase_reshape.cpp + * Output: \verbinclude MatrixBase_reshape.out + * + * \note since reshape is a templated member, the keyword template has to be used + * if the matrix type is also a template parameter: \code m.template reshape<3,3>(); \endcode + * + * \sa class Reshape, reshape(Index,Index) + */ +template<int ReshapeRows, int ReshapeCols> +EIGEN_DEVICE_FUNC +inline Reshape<Derived, ReshapeRows, ReshapeCols> reshape() +{ + return Reshape<Derived, ReshapeRows, ReshapeCols>(derived()); +} + +/** This is the const version of reshape<>(Index, Index). */ +template<int ReshapeRows, int ReshapeCols> +EIGEN_DEVICE_FUNC +inline const Reshape<const Derived, ReshapeRows, ReshapeCols> reshape() const +{ + return Reshape<const Derived, ReshapeRows, ReshapeCols>(derived()); +} + |