aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-10-02 14:02:34 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-10-02 14:02:34 +0200
commit12487531ce45b61f6d764d7b0fea33815bd763da (patch)
treeb71e776dd15febb57fcdf86d4dad81d2dc452fbe /Eigen/src
parent37e29fc89389ff1514315b1cf96a8253e0b5c69d (diff)
Add templated subVector<Vertical/Horizonal>(Index) aliases to col/row(Index) methods (plus subVectors<>() to retrieve the number of rows/columns)
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/VectorwiseOp.h19
-rw-r--r--Eigen/src/plugins/BlockMethods.h29
2 files changed, 30 insertions, 18 deletions
diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h
index 893bc796f..e44cbd468 100644
--- a/Eigen/src/Core/VectorwiseOp.h
+++ b/Eigen/src/Core/VectorwiseOp.h
@@ -186,24 +186,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
};
protected:
-
- typedef typename internal::conditional<isVertical,
- typename ExpressionType::ColXpr,
- typename ExpressionType::RowXpr>::type SubVector;
- /** \internal
- * \returns the i-th subvector according to the \c Direction */
- EIGEN_DEVICE_FUNC
- SubVector subVector(Index i)
- {
- return SubVector(m_matrix.derived(),i);
- }
-
- /** \internal
- * \returns the number of subvectors in the direction \c Direction */
- EIGEN_DEVICE_FUNC
- Index subVectors() const
- { return isVertical?m_matrix.cols():m_matrix.rows(); }
-
+
template<typename OtherDerived> struct ExtendedType {
typedef Replicate<OtherDerived,
isVertical ? 1 : ExpressionType::RowsAtCompileTime,
diff --git a/Eigen/src/plugins/BlockMethods.h b/Eigen/src/plugins/BlockMethods.h
index 67fdebc6f..528af05ec 100644
--- a/Eigen/src/plugins/BlockMethods.h
+++ b/Eigen/src/plugins/BlockMethods.h
@@ -1399,3 +1399,32 @@ innerVectors(Index outerStart, Index outerSize) const
IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize);
}
+
+/** \returns the i-th subvector (column or vector) according to the \c Direction
+ * \sa subVectors()
+ */
+EIGEN_DEVICE_FUNC
+template<DirectionType Direction>
+typename internal::conditional<Direction==Vertical,ColXpr,RowXpr>::type
+subVector(Index i)
+{
+ return typename internal::conditional<Direction==Vertical,ColXpr,RowXpr>::type(derived(),i);
+}
+
+/** This is the const version of subVector(Index) */
+EIGEN_DEVICE_FUNC
+template<DirectionType Direction>
+typename internal::conditional<Direction==Vertical,ConstColXpr,ConstRowXpr>::type
+subVector(Index i) const
+{
+ return typename internal::conditional<Direction==Vertical,ConstColXpr,ConstRowXpr>::type(derived(),i);
+}
+
+/** \returns the number of subvectors (rows or columns) in the direction \c Direction
+ * \sa subVector(Index)
+ */
+EIGEN_DEVICE_FUNC
+template<DirectionType Direction>
+Index subVectors() const
+{ return (Direction==Vertical)?cols():rows(); }
+