# SVD: Better default to gesvd! instead of gesdd!?

**URL:** <https://discourse.julialang.org/t/svd-better-default-to-gesvd-instead-of-gesdd/20603>\
**Category:** Internals & Design\
**Tags:** linearalgebra\
**Created:** [February 9, 2019, 11:17am UTC](https://discourse.julialang.org/t/svd-better-default-to-gesvd-instead-of-gesdd/20603 "2019-02-09T11:17:53Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)\
**Post date:** [February 14, 2019, 11:44am UTC](https://discourse.julialang.org/t/svd-better-default-to-gesvd-instead-of-gesdd/20603/21 "2019-02-14T11:44:16Z")

</div>

The difference is not related to `full` or not but instead if the singular vectors are requested in the bidiagonal solver. The [documentation for `dbdsdc`](http://www.netlib.org/lapack/explore-html/d2/d24/group__aux_o_t_h_e_rcomputational_ga6465b3e8d562f4a16409308939a46a3f.html#ga6465b3e8d562f4a16409308939a46a3f) explains that

> The code currently calls DLASDQ if singular values only are desired.

I.e. when only the values are requested then the square root free QR algorithm is used instead of the Divide and Conquer algorithm since it is extremely fast but doesn’t compute singular vectors.

Hence there are actually three different algorithms: the square root free QR (`svdvals`), normal QR (`LAPACK.bdsqr!` or `svd` for small `n`) and DnC (`svd`). The two QR versions give very similar results, though, and they are very precise because they use the [zero shift QR algorithm](http://www.netlib.org/lapack/lawnspdf/lawn03.pdf) when there is a risk that a shift could cause significant cancellation. This is probably why you get better results from using the QR based solver.

As other people have also pointed out, I don’t think it’s a bug in the DnC solver. It’s just that solving secular equations have a larger error than zero shift QR.

In any case, I think having a keyword argument to select which solver to use is a very good idea.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 14, 2019, 12:01pm UTC](https://discourse.julialang.org/t/svd-better-default-to-gesvd-instead-of-gesdd/20603/22 "2019-02-14T12:01:31Z")

</div>

Alright. I [made a PR](https://github.com/JuliaLang/julia/pull/31057) that adds such a keyword argument.

[Previous page](https://discourse.julialang.org/t/svd-better-default-to-gesvd-instead-of-gesdd/20603.md?page=1)
