aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/src/Core/IndexedView.h4
-rw-r--r--test/indexed_view.cpp7
2 files changed, 9 insertions, 2 deletions
diff --git a/Eigen/src/Core/IndexedView.h b/Eigen/src/Core/IndexedView.h
index 8c57a277c..3485d8f46 100644
--- a/Eigen/src/Core/IndexedView.h
+++ b/Eigen/src/Core/IndexedView.h
@@ -21,8 +21,8 @@ struct traits<IndexedView<XprType, RowIndices, ColIndices> >
enum {
RowsAtCompileTime = int(array_size<RowIndices>::value),
ColsAtCompileTime = int(array_size<ColIndices>::value),
- MaxRowsAtCompileTime = RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) : int(traits<XprType>::MaxRowsAtCompileTime),
- MaxColsAtCompileTime = ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) : int(traits<XprType>::MaxColsAtCompileTime),
+ MaxRowsAtCompileTime = RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) : Dynamic,
+ MaxColsAtCompileTime = ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) : Dynamic,
XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0,
IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp
index 8ede612d1..6518642df 100644
--- a/test/indexed_view.cpp
+++ b/test/indexed_view.cpp
@@ -408,6 +408,13 @@ void check_indexed_view()
VERIFY_IS_EQUAL( A(i,i), A.coeff(i_sizet, i_short) );
VERIFY_IS_EQUAL( A(i,i), A.coeff(5, i_sizet) );
+ // Regression test for Max{Rows,Cols}AtCompileTime
+ {
+ Matrix3i A3 = Matrix3i::Random();
+ ArrayXi ind(5); ind << 1,1,1,1,1;
+ VERIFY_IS_EQUAL( A3(ind,ind).eval(), MatrixXi::Constant(5,5,A3(1,1)) );
+ }
+
}
EIGEN_DECLARE_TEST(indexed_view)