mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-03 18:50:39 +08:00
Biug 1242: fix comma init with empty matrices.
(grafted from a3f7edf7e7672094190e04a0b4417de1abfa3de5 )
This commit is contained in:
parent
d5c2a01031
commit
87112908be
@ -76,8 +76,11 @@ struct CommaInitializer
|
||||
template<typename OtherDerived>
|
||||
CommaInitializer& operator,(const DenseBase<OtherDerived>& other)
|
||||
{
|
||||
if(other.cols()==0 || other.rows()==0)
|
||||
if(other.rows()==0)
|
||||
{
|
||||
m_col += other.cols();
|
||||
return *this;
|
||||
}
|
||||
if (m_col==m_xpr.cols())
|
||||
{
|
||||
m_row+=m_currentBlockRows;
|
||||
@ -86,7 +89,7 @@ struct CommaInitializer
|
||||
eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()
|
||||
&& "Too many rows passed to comma initializer (operator<<)");
|
||||
}
|
||||
eigen_assert(m_col<m_xpr.cols()
|
||||
eigen_assert(m_col<m_xpr.cols() || (m_xpr.cols()==0 && m_col==0)
|
||||
&& "Too many coefficients passed to comma initializer (operator<<)");
|
||||
eigen_assert(m_currentBlockRows==other.rows());
|
||||
if (OtherDerived::SizeAtCompileTime != Dynamic)
|
||||
|
@ -43,4 +43,27 @@ void test_commainitializer()
|
||||
4, 5, 6,
|
||||
vec[2].transpose();
|
||||
VERIFY_IS_APPROX(m3, ref);
|
||||
|
||||
|
||||
// Check with empty matrices (bug #1242)
|
||||
{
|
||||
int const M = 0;
|
||||
int const N1 = 2;
|
||||
int const N2 = 1;
|
||||
|
||||
{
|
||||
Matrix<double, M, N1> A1;
|
||||
Matrix<double, M, N2> A2;
|
||||
Matrix<double, M, N1 + N2> B;
|
||||
B << A1, A2;
|
||||
}
|
||||
{
|
||||
Matrix<double, N1, M> A1;
|
||||
Matrix<double, N2, M> A2;
|
||||
Matrix<double, N1 + N2, M> B;
|
||||
B << A1,
|
||||
A2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user