# How to calculate opnorm for a sparse matrix in julia?

**URL:** https://discourse.julialang.org/t/how-to-calculate-opnorm-for-a-sparse-matrix-in-julia/120820
**Category:** General Usage
**Tags:** question
**Created:** [October 2, 2024, 4:25pm UTC](https://discourse.julialang.org/t/how-to-calculate-opnorm-for-a-sparse-matrix-in-julia/120820 "2024-10-02T16:25:02Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [October 2, 2024, 4:59pm UTC](https://discourse.julialang.org/t/how-to-calculate-opnorm-for-a-sparse-matrix-in-julia/120820/3 "2024-10-02T16:59:03Z")

</div>

> [@Oscar\_Smith](#):
>
> Do you want the actual `opnorm` or are you OK with an approximation? The reason it isn’t implemented is that the 2 norm is usually computed with an SVD which would be really slow for sparse matrices.

In particular, the operator 2-norm \Vert A \Vert\_2 is exactly equal to the _largest_ singular value of A. For a large sparse matrix (or a matrix implicitly defined as a linear operator), you **need to compute this by iterative methods** , which are _not_ included in SparseArrays but are provided by many packages.

For example, you can use `KrylovKit.svdsolve(A)[1][1]` from KrylovKit.jl to get the largest singular value of a sparse matrix `A`, equivalent to the operator norm.

PS. I edited @usaer’s original post to quote the code properly. Please see [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-calculate-opnorm-for-a-sparse-matrix-in-julia/120820)._
