# Cholesky Decomposition of a Sparse Symmetric Positive Semidefinite (SPSD) Singular Matrix

**URL:** <https://discourse.julialang.org/t/cholesky-decomposition-of-a-sparse-symmetric-positive-semidefinite-spsd-singular-matrix/119682>\
**Category:** Numerics\
**Tags:** linearalgebra, numerics, sparse, factorization\
**Created:** [September 21, 2024, 2:57pm UTC](https://discourse.julialang.org/t/cholesky-decomposition-of-a-sparse-symmetric-positive-semidefinite-spsd-singular-matrix/119682 "2024-09-21T14:57:40Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [September 22, 2024, 4:38pm UTC](https://discourse.julialang.org/t/cholesky-decomposition-of-a-sparse-symmetric-positive-semidefinite-spsd-singular-matrix/119682/6 "2024-09-22T16:38:05Z")

</div>

> [@RoyiAvital](#):
>
> Hence I assumed a matching factorization will be more efficient than a general.

First, QR for least-squares _is_ specialized to the problem — you apply QR to A, _not_ to A^T A (which you never compute).

Second, while QR on A is generally slower than forming A^T A and doing Cholesky (the “normal equations” approach), the latter can be _much_ less accurate when A is badly conditioned (i.e. the columns are nearly linearly dependent, i.e. A^T A is nearly singular). If you care about getting the _right_ answer, and not just the _fastest_ answer, I would use QR.

See also [Efficient way of doing linear regression - #33 by stevengj](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232/33)

---

_[View the full topic](https://discourse.julialang.org/t/cholesky-decomposition-of-a-sparse-symmetric-positive-semidefinite-spsd-singular-matrix/119682)._
