diff --git a/Eigen/src/SparseQR/SparseQR.h b/Eigen/src/SparseQR/SparseQR.h index 0c70609b4..1bf631507 100644 --- a/Eigen/src/SparseQR/SparseQR.h +++ b/Eigen/src/SparseQR/SparseQR.h @@ -220,6 +220,7 @@ class SparseQR protected: inline void sort_matrix_Q() { + if(this->m_isQSorted) return; // The matrix Q is sorted during the transposition SparseMatrix mQrm(this->m_Q); this->m_Q = mQrm; @@ -622,17 +623,14 @@ struct SparseQRMatrixQReturnType : public EigenBase void evalTo(MatrixBase& dest) const { - dest.resize(m_qr.rows(), m_qr.cols()); dest.derived() = m_qr.matrixQ() * Dest::Identity(m_qr.rows(), m_qr.rows()); } template void evalTo(SparseMatrixBase& dest) const { Dest idMat(m_qr.rows(), m_qr.rows()); idMat.setIdentity(); - dest.derived().resize(m_qr.rows(), m_qr.cols()); // Sort the sparse householder reflectors if needed - if(!m_qr.m_isQSorted) - const_cast(&m_qr)->sort_matrix_Q(); + const_cast(&m_qr)->sort_matrix_Q(); dest.derived() = SparseQR_QProduct(m_qr, idMat, false); }