From 96793cd20323db844447bc0ca3a9f4878e9bad8d Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Mon, 26 Oct 2026 23:02:17 +0000 Subject: [PATCH] Document that sparse `cond` of a singular matrix returns `Inf` Co-Authored-By: Claude Opus 5.5 --- src/linalg.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/linalg.jl b/src/linalg.jl index 446f071d..ffb19d1b 100644 --- a/src/linalg.jl +++ b/src/linalg.jl @@ -986,6 +986,11 @@ estimator of Higham and Tisseur, from a factorization of `A` by `factorize` and forming the inverse, so the result can fall below the exact condition number. `p = 2`, the default, throws an `ArgumentError`, so `cond(A)` does too: use `cond(Array(A))` for a matrix small enough to store dense. + +A singular matrix gives `Inf` when its factorization meets an exactly zero pivot. Rounding +can hide that zero, and the result is then finite but very large. The sparse LU pivots in +another order than the dense one, so `cond(A, p)` can be finite where `cond(Array(A), p)` +is `Inf`. """ function cond(A::AbstractSparseMatrixCSC, p::Real=2) # as for a dense matrix; the estimator of the inverse's norm needs at least one column