# Finding the least norm solution of least squares problem with a sparse matrix

I have a matrix `M` which is the transpose of the Laplacian of a graph and a vector `d` that may or may not be in the range of `M`. I want to compute `pinv(M)*d`.

I assumed that `qr(M)\d` does what I want, however it does it only when `M` is represented by a full matrix, see my previous question. If `M` is represented by a sparse matrix, it gives a solution but not the least norm one.

So what is the most efficient to get `pinv(M)*d`?

That will probably depend on your matrix. The iterative solvers LSQR and LSMR compute the least norm least square solution. In particular, they approximate the least norm solution if your system is feasible. These methods are implemented in IterativeSolvers.jl, cf. https://juliamath.github.io/IterativeSolvers.jl/dev/linear_systems/lsqr/.

3 Likes
3 Likes
{"ft_lang_label":"__label__en","ft_lang_prob":0.9587013,"math_prob":0.8900996,"size":424,"snap":"2020-34-2020-40","text_gpt3_token_len":116,"char_repetition_ratio":0.104761906,"word_repetition_ratio":0.023255814,"special_character_ratio":0.25,"punctuation_ratio":0.07920792,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99586165,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-21T16:11:31Z\",\"WARC-Record-ID\":\"<urn:uuid:d92c08b3-b0df-4688-951e-1ae67acac3d0>\",\"Content-Length\":\"19882\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c3aeda49-6e2f-4fd1-9faf-3801e04c809b>\",\"WARC-Concurrent-To\":\"<urn:uuid:20f0169f-9f01-427e-8eb9-79e05cb5cc7f>\",\"WARC-IP-Address\":\"72.52.80.20\",\"WARC-Target-URI\":\"https://discourse.julialang.org/t/finding-the-least-norm-solution-of-least-squares-problem-with-a-sparse-matrix/30702\",\"WARC-Payload-Digest\":\"sha1:QCFFXQPTGCI2FINC35LLPGUZOTYQO5GQ\",\"WARC-Block-Digest\":\"sha1:XUSXCYIWGF3VHOXQACEYCVV66LGPM5JK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400201826.20_warc_CC-MAIN-20200921143722-20200921173722-00510.warc.gz\"}"}