# Condition number of sparse matrix

**URL:** <https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131>\
**Category:** New to Julia\
**Tags:** question, linearalgebra, sparse\
**Created:** [February 26, 2022, 4:44pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131 "2022-02-26T16:44:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [February 26, 2022, 4:44pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/1 "2022-02-26T16:44:09Z")

</div>

Hello. Early adopter (v0.4-v0.5) coming back to Julia after wrangling with other languages for too long.

I am trying to compute the condition number of a sparse matrix but cannot find a method overloaded for sparse matrices.

I found a couple of issues that claimed to be closed by  
[https://github.com/JuliaLang/julia/pull/12467](https://github.com/JuliaLang/julia/pull/12467)

However, I simply cannot find this implementation anywhere. Is it in some module other than LinearAlgebra or SparseArrays?

Edit: I should add that I am currently using Julia version 1.2.0.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [February 26, 2022, 4:53pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/2 "2022-02-26T16:53:59Z")

</div>

> [@jecs](#):
>
> Edit: I should add that I am currently using Julia version 1.2.0.

Then [this](https://github.com/JuliaLang/julia/pull/12467) might interest you.

---

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [February 26, 2022, 4:55pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/4 "2022-02-26T16:55:51Z")

</div>

I linked that pull request in my original post. I cannot seem to find it anywhere.

---

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [February 26, 2022, 4:58pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/5 "2022-02-26T16:58:11Z")

</div>

Edit: Actually, no Google lied. 1.2.0 is from 2019. So cond for sparse matrices should be in there somewhere.

---

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [February 26, 2022, 5:17pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/6 "2022-02-26T17:17:11Z")

</div>

OK, so the method is in there, but the only norms that you can use are L1 and Linf. Any reason why L2 isn’t there? Maybe the error message could be a bit clearer? The way it is written, I am led to believe that the _only_ way to calculate the condition number is to convert to a dense array.

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [February 26, 2022, 5:44pm UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/7 "2022-02-26T17:44:05Z")

</div>

You can get a decent condition estimate for L1 and LInf with an LU facatorization. The L2 condition number needs the largest and smallest singular values, which is more expensive. Maybe ARPack has something you could use for this.

---

<div class="post-metadata">

**Author:** ![marteaua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marteaua/32/214927_2.png) [@marteaua](https://discourse.julialang.org/u/marteaua)\
**Post date:** [May 27, 2025, 7:08am UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131/8 "2025-05-27T07:08:48Z")

</div>

I agree I also lost some time trying to densify too big matrices, but 1-norm was enough for me, I opened a doc PR.
