# Computing the SVD of a LinearMap

**URL:** <https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534>\
**Category:** General Usage\
**Tags:** linearalgebra\
**Created:** [August 9, 2022, 2:04pm UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534 "2022-08-09T14:04:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnshPatel7](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@AnshPatel7](https://discourse.julialang.org/u/AnshPatel7)\
**Post date:** [August 9, 2022, 2:04pm UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534/1 "2022-08-09T14:04:30Z")

</div>

I’m trying to compute the SVD of a LinearMap since a dense representation of the matrix would go out of memory. I tried using `IterativeSolvers.svdl` but it does not give me all of the singular values or the U matrix. Is there any other way to get the SVD on Julia?

---

<div class="post-metadata">

**Author:** ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Post date:** [August 9, 2022, 2:11pm UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534/2 "2022-08-09T14:11:55Z")

</div>

But if you need all singular values and the full U matrix you will face the same memory problem ? If you are ready to truncate the series, there is [GitHub - JuliaLinearAlgebra/TSVD.jl: Truncated singular value decomposition with partial reorthogonalization](https://github.com/JuliaLinearAlgebra/TSVD.jl) or [GitHub - JuliaLinearAlgebra/Arpack.jl: Julia Wrappers for the arpack-ng Fortran library](https://github.com/JuliaLinearAlgebra/Arpack.jl)

---

<div class="post-metadata">

**Author:** ![AnshPatel7](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@AnshPatel7](https://discourse.julialang.org/u/AnshPatel7)\
**Post date:** [August 9, 2022, 3:02pm UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534/3 "2022-08-09T15:02:35Z")

</div>

I hoped to get the singular values as a vector (for the scales at which I am working this would be within memory) and U as a LinearMap. I’m trying to compute the preconditioner for `IterativeSolvers.lsqr` using the LSRN method. Here the preconditioner would be U\*\Sigma^{-1} which is why I dont really need the dense matrix representations at any point.

---

<div class="post-metadata">

**Author:** ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Post date:** [August 9, 2022, 7:03pm UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534/4 "2022-08-09T19:03:21Z")

</div>

Since you want to use it as a preconditioner, maybe the truncated version still works since anyway the preconditioner is only an approximation to the true inverse anyway ? Do you have an idea on the singular values spectrum (how fast it decreases) ?

I’m not aware of an svd decomposition returning U as a function rather than a full matrix and if that exists I would like to learn about it !

---

<div class="post-metadata">

**Author:** ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)\
**Post date:** [August 9, 2022, 8:38pm UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534/5 "2022-08-09T20:38:16Z")

</div>

> [@JM\_Beckers](#):
>
> I’m not aware of an svd decomposition returning U as a function rather than a full matrix and if that exists I would like to learn about it !

Well, there’s [this paper](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4277194/).

---

<div class="post-metadata">

**Author:** ![AnshPatel7](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@AnshPatel7](https://discourse.julialang.org/u/AnshPatel7)\
**Post date:** [August 10, 2022, 7:32am UTC](https://discourse.julialang.org/t/computing-the-svd-of-a-linearmap/85534/6 "2022-08-10T07:32:41Z")

</div>

The spectrum of the singular values is the same as that of a random matrix (a Gaussian ensemble). So your suggestion is worth a shot.  
Thank you.
