aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2016-08-12 15:15:34 +0200
committerGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2016-08-12 15:15:34 +0200
commitc83b754ee0c65881fe8e42b2b901e23fe6adbb1c (patch)
tree712b0674cf74aebf0b97555d8fb4aaf1d0fa67ee
parente3a8dfb02fff69dc455ba724b1f42a697ea4308c (diff)
bug #1272: Disable assertion when total number of columns is zero.
Also moved assertion to finished() method and adapted unit-test
-rw-r--r--Eigen/src/Core/CommaInitializer.h11
-rw-r--r--test/commainitializer.cpp9
2 files changed, 12 insertions, 8 deletions
diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h
index b39a661d0..d218e9814 100644
--- a/Eigen/src/Core/CommaInitializer.h
+++ b/Eigen/src/Core/CommaInitializer.h
@@ -103,9 +103,7 @@ struct CommaInitializer
EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception)
#endif
{
- eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows()
- && m_col == m_xpr.cols()
- && "Too few coefficients passed to comma initializer (operator<<)");
+ finished();
}
/** \returns the built matrix once all its coefficients have been set.
@@ -116,7 +114,12 @@ struct CommaInitializer
* \endcode
*/
EIGEN_DEVICE_FUNC
- inline XprType& finished() { return m_xpr; }
+ inline XprType& finished() {
+ eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)
+ && m_col == m_xpr.cols()
+ && "Too few coefficients passed to comma initializer (operator<<)");
+ return m_xpr;
+ }
XprType& m_xpr; // target expression
Index m_row; // current row id
diff --git a/test/commainitializer.cpp b/test/commainitializer.cpp
index 5ece4f6cc..9844adbd2 100644
--- a/test/commainitializer.cpp
+++ b/test/commainitializer.cpp
@@ -23,11 +23,12 @@ void test_blocks()
MatrixXi matx11 = mat11, matx12 = mat12, matx21 = mat21, matx22 = mat22;
- // The only remaining border case is M1==M2>0 && N1==N2==0.
- // In that case it is not possible to decide (without backtracking) if a block starts a new row or does not
- if(M1 != M2 || M1 == 0 || N1>0 || N2>0)
{
VERIFY_IS_EQUAL((m_fixed << mat11, mat12, mat21, matx22).finished(), (m_dynamic << mat11, matx12, mat21, matx22).finished());
+ VERIFY_IS_EQUAL((m_fixed.template topLeftCorner<M1,N1>()), mat11);
+ VERIFY_IS_EQUAL((m_fixed.template topRightCorner<M1,N2>()), mat12);
+ VERIFY_IS_EQUAL((m_fixed.template bottomLeftCorner<M2,N1>()), mat21);
+ VERIFY_IS_EQUAL((m_fixed.template bottomRightCorner<M2,N2>()), mat22);
VERIFY_IS_EQUAL((m_fixed << mat12, mat11, matx21, mat22).finished(), (m_dynamic << mat12, matx11, matx21, mat22).finished());
}
@@ -36,7 +37,7 @@ void test_blocks()
VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat11, mat21, mat22));
VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat21, mat21, mat22));
}
- else if(N2 > 0 || M1 != M2) // border case if both sublocks have zero columns and same number of rows
+ else
{
// allow insertion of zero-column blocks:
VERIFY_IS_EQUAL((m_fixed << mat11, mat12, mat11, mat11, mat21, mat21, mat22).finished(), (m_dynamic << mat12, mat22).finished());