aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/plugins
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2017-01-16 22:21:23 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2017-01-16 22:21:23 +0100
commit4989922be2708378b2438db5a843640ec468ce4c (patch)
tree19f81b7439f227edde89cd38fccffd94fbc1d3af /Eigen/src/plugins
parent12e22a2844d060cfbeab7a48512046ee59709e53 (diff)
Add support for symbolic expressions as arguments of operator()
Diffstat (limited to 'Eigen/src/plugins')
-rw-r--r--Eigen/src/plugins/IndexedViewMethods.h41
1 files changed, 31 insertions, 10 deletions
diff --git a/Eigen/src/plugins/IndexedViewMethods.h b/Eigen/src/plugins/IndexedViewMethods.h
index 0584a5926..90ade05ed 100644
--- a/Eigen/src/plugins/IndexedViewMethods.h
+++ b/Eigen/src/plugins/IndexedViewMethods.h
@@ -38,19 +38,24 @@ typedef typename internal::IndexedViewCompatibleType<Index,1>::type IvcIndex;
template<typename Indices>
typename IvcRowType<Indices>::type
ivcRow(const Indices& indices) const {
- return internal::makeIndexedViewCompatible(indices, internal::variable_if_dynamic<Index,RowsAtCompileTime>(derived().rows()));
+ return internal::makeIndexedViewCompatible(indices, internal::variable_if_dynamic<Index,RowsAtCompileTime>(derived().rows()),Specialized);
};
template<typename Indices>
typename IvcColType<Indices>::type
ivcCol(const Indices& indices) const {
- return internal::makeIndexedViewCompatible(indices, internal::variable_if_dynamic<Index,ColsAtCompileTime>(derived().cols()));
+ return internal::makeIndexedViewCompatible(indices, internal::variable_if_dynamic<Index,ColsAtCompileTime>(derived().cols()),Specialized);
};
template<typename Indices>
typename IvcColType<Indices>::type
ivcSize(const Indices& indices) const {
- return internal::makeIndexedViewCompatible(indices, internal::variable_if_dynamic<Index,SizeAtCompileTime>(derived().size()));
+ return internal::makeIndexedViewCompatible(indices, internal::variable_if_dynamic<Index,SizeAtCompileTime>(derived().size()),Specialized);
+};
+
+template<typename RowIndices, typename ColIndices>
+struct valid_indexed_view_overload {
+ enum { value = !(internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value) };
};
public:
@@ -67,9 +72,8 @@ struct EIGEN_INDEXED_VIEW_METHOD_TYPE {
// This is the generic version
template<typename RowIndices, typename ColIndices>
-typename internal::enable_if<
- ! (internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::IsBlockAlike
- || (internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value)),
+typename internal::enable_if<valid_indexed_view_overload<RowIndices,ColIndices>::value
+ && internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::ReturnAsIndexedView,
typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type >::type
operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
{
@@ -80,9 +84,8 @@ operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_IND
// The folowing overload returns a Block<> object
template<typename RowIndices, typename ColIndices>
-typename internal::enable_if<
- internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::IsBlockAlike
- && !(internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value),
+typename internal::enable_if<valid_indexed_view_overload<RowIndices,ColIndices>::value
+ && internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::ReturnAsBlock,
typename internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::BlockType>::type
operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
{
@@ -96,6 +99,17 @@ operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_IND
internal::size(actualColIndices));
}
+// The following overload returns a Scalar
+
+template<typename RowIndices, typename ColIndices>
+typename internal::enable_if<valid_indexed_view_overload<RowIndices,ColIndices>::value
+ && internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::ReturnAsScalar,
+ CoeffReturnType >::type
+operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
+{
+ return Base::operator()(internal::eval_expr_given_size(rowIndices,rows()),internal::eval_expr_given_size(colIndices,cols()));
+}
+
// The folowing three overloads are needed to handle raw Index[N] arrays.
template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndices>
@@ -148,7 +162,7 @@ operator()(const Indices& indices) EIGEN_INDEXED_VIEW_METHOD_CONST
template<typename Indices>
typename internal::enable_if<
- (internal::get_compile_time_incr<typename IvcType<Indices>::type>::value==1) && (!internal::is_integral<Indices>::value),
+ (internal::get_compile_time_incr<typename IvcType<Indices>::type>::value==1) && (!internal::is_integral<Indices>::value) && (!Symbolic::is_symbolic<Indices>::value),
VectorBlock<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,internal::array_size<Indices>::value> >::type
operator()(const Indices& indices) EIGEN_INDEXED_VIEW_METHOD_CONST
{
@@ -158,6 +172,13 @@ operator()(const Indices& indices) EIGEN_INDEXED_VIEW_METHOD_CONST
(derived(), internal::first(actualIndices), internal::size(actualIndices));
}
+template<typename IndexType>
+typename internal::enable_if<Symbolic::is_symbolic<IndexType>::value, CoeffReturnType >::type
+operator()(const IndexType& id) EIGEN_INDEXED_VIEW_METHOD_CONST
+{
+ return Base::operator()(internal::eval_expr_given_size(id,size()));
+}
+
template<typename IndicesT, std::size_t IndicesN>
typename internal::enable_if<IsRowMajor,
IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,IvcIndex,const IndicesT (&)[IndicesN]> >::type