Fix infinite recursion in ProductBase::coeff() (bug #447)

Triggered by product of dynamic-size 1 x n and n x 1 matrices.
Also, add regression test.
This commit is contained in:
Jitse Niesen
2012-04-18 15:23:28 +01:00
parent 5cab18976b
commit 57b5767fe2
2 changed files with 24 additions and 2 deletions

View File

@@ -154,7 +154,8 @@ class ProductBase : public MatrixBase<Derived>
#else
EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
eigen_assert(this->rows() == 1 && this->cols() == 1);
return derived().coeff(row,col);
Matrix<Scalar,1,1> result = *this;
return result.coeff(row,col);
#endif
}
@@ -162,7 +163,8 @@ class ProductBase : public MatrixBase<Derived>
{
EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
eigen_assert(this->rows() == 1 && this->cols() == 1);
return derived().coeff(i);
Matrix<Scalar,1,1> result = *this;
return result.coeff(i);
}
const Scalar& coeffRef(Index row, Index col) const