From 9836e8d035f72003b4af070c0da73660b28b8d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Wed, 8 Jan 2025 23:40:58 +0000 Subject: [PATCH] Fix read of uninitialized threshold in SparseQR --- Eigen/src/SparseQR/SparseQR.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Eigen/src/SparseQR/SparseQR.h b/Eigen/src/SparseQR/SparseQR.h index acb0c5ffc..4cc4ea141 100644 --- a/Eigen/src/SparseQR/SparseQR.h +++ b/Eigen/src/SparseQR/SparseQR.h @@ -365,7 +365,6 @@ void SparseQR::factorize(const MatrixType& mat) { IndexVector Ridx(n), Qidx(m); // Store temporarily the row indexes for the current column of R and Q Index nzcolR, nzcolQ; // Number of nonzero for the current column of R and Q ScalarVector tval(m); // The dense vector used to compute the current column - RealScalar pivotThreshold = m_threshold; m_R.setZero(); m_Q.setZero(); @@ -401,11 +400,14 @@ void SparseQR::factorize(const MatrixType& mat) { * Tim Davis, "Algorithm 915, SuiteSparseQR: Multifrontal Multithreaded Rank-Revealing * Sparse QR Factorization, ACM Trans. on Math. Soft. 38(1), 2011, Page 8:3 */ + RealScalar pivotThreshold; if (m_useDefaultThreshold) { RealScalar max2Norm = 0.0; for (int j = 0; j < n; j++) max2Norm = numext::maxi(max2Norm, m_pmat.col(j).norm()); if (max2Norm == RealScalar(0)) max2Norm = RealScalar(1); pivotThreshold = 20 * (m + n) * max2Norm * NumTraits::epsilon(); + } else { + pivotThreshold = m_threshold; } // Initialize the numerical permutation