diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index a1659e2a7..5d5b147d9 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -189,11 +189,24 @@ template class MatrixBase /** \returns the size of the inner dimension according to the storage order, * i.e., the number of rows for a columns major matrix, and the number of cols otherwise */ int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); } - + + /** Only plain matrices, not expressions may be resized; therefore the only useful resize method is + * Matrix::resize(). The present method only asserts that the new size equals the old size, and does + * nothing else. + */ + void resize(int size) + { ei_assert(size == this->size() && "MatrixBase::resize() does not actually allow to resize."); } + /** Only plain matrices, not expressions may be resized; therefore the only useful resize method is + * Matrix::resize(). The present method only asserts that the new size equals the old size, and does + * nothing else. + */ + void resize(int rows, int cols) + { ei_assert(rows == this->rows() && cols == this->cols() && "MatrixBase::resize() does not actually allow to resize."); } + #ifndef EIGEN_PARSED_BY_DOXYGEN /** \internal the plain matrix type corresponding to this expression. Note that is not necessarily * exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const - * reference to a matrix, not a matrix! It guaranteed however, that the return type of eval() is either + * reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either * PlainMatrixType or const PlainMatrixType&. */ typedef typename ei_plain_matrix_type::type PlainMatrixType; diff --git a/test/lu.cpp b/test/lu.cpp index f34c941f7..a7217f5b9 100644 --- a/test/lu.cpp +++ b/test/lu.cpp @@ -40,7 +40,6 @@ template void lu_non_invertible() typename ei_lu_kernel_impl::ReturnMatrixType m1kernel = lu.kernel(); typename ei_lu_image_impl ::ReturnMatrixType m1image = lu.image(); - std::cout << "rows:" << rows << " cols:" << cols << " | " << rank << " ----- " << lu.rank() << std::endl; VERIFY(rank == lu.rank()); VERIFY(cols - lu.rank() == lu.dimensionOfKernel()); VERIFY(!lu.isInjective()); @@ -54,7 +53,8 @@ template void lu_non_invertible() m2 = MatrixType::Random(cols,cols2); m3 = m1*m2; m2 = MatrixType::Random(cols,cols2); - m2 = lu.solve(m3); + // test that the code, which does resize(), may be applied to an xpr + m2.block(0,0,cols,cols2) = lu.solve(m3); VERIFY_IS_APPROX(m3, m1*m2); typedef Matrix SquareMatrixType;