# Is there any function to calculate condition number of sparse matrix in Eigen libraray?

The function JacobiSVD and BDCSVD can calcuate condtion number of a dense matrix via singular values. However I need to know condition number of a sparese matrix due to slow computation speed using iterative linear solver. I can't find such function. If the sparse matrix is converted to one dense one in advance, the memory allocation occur because of large size of the matrix(about 10,000 x 10, 000). Many people may encounter this problem. Is there one way there to calculate condition number for a large sparese matrix in Eigen?

• Sep 17 '20 at 15:59
• calculating != estimating. Would a (non-guaranteed) estimate be sufficient for you OP? Sep 17 '20 at 17:55
• ^this. Computing eigenvalues/condition numbers is expensive for sparse matrices. But there are randomized algorithms that are much cheaper. Sep 17 '20 at 18:45
• 10000 by 10000 isn't large- it requires less than a gigabyte of RAM to store such a matrix in double precision. If you just want to investigate the conditioning of some sample matrices, there's absolutely no reason not to convert to full and compute the condition number approximately using an LU factorization or more precisely using the SVD. Once you have a better understanding of the ill-conditioning of your problems, you can look to improve the preconditioner that you're using with your iterative method. Sep 18 '20 at 4:32
• SuiteSparse has a routine called cholmod rcond which estimates the reciprocal condition number of a sparse matrix that can be decomposed with an LLT or LDLT factorization. "Returns a rough estimate of the reciprocal of the condition number: the minimum entry on the diagonal of L (or absolute entry of D for an LDLT factorization) divided by the maximum entry." This seems like a viable alternative to forming the dense matrix. fossies.org/linux/SuiteSparse/CHOLMOD/Doc/CHOLMOD_UserGuide.pdf Sep 27 '20 at 17:57