0

I regularly have upwards of 10^8 sets of linear least squares to solve (heaps of Ax = B) coming out of monte-carlo simulations. Until now I have been using a simple loop, but obviously this is slow. Is there a way of vectorizing the process, so that I can send the lot at once to the function and it returns 10^8 solutions to the 10^8 sets? I have looked extensively online. All I can find is a python code that does what I want stacked_lstsq, but I don't know how to translate this into Matlab. Any help appreciated.

user46655
  • 11
  • 7
  • Without a [mcve], this is too broad – Wolfie Feb 04 '19 at 09:11
  • Please do not post [duplicate questions](https://stackoverflow.com/questions/54509198/matlab-multiple-halir-ellipse-fitting-using-vectorization), instead [edit] your questions to improve them! – Wolfie Feb 04 '19 at 09:19
  • You can use https://www.mathworks.com/help/distcomp/pagefun.html if you have a gpu. Otherwise there are others such as ndfun for the cpu. Note that if you have a non-square `A`, you will have to do (A'A)^-1A'B to solve the systems – Durkee Feb 05 '19 at 02:29
  • Sorry, not ndfun but mmx https://github.com/yuvaltassa/mmx – Durkee Feb 05 '19 at 02:38
  • Thanks Durkee. Will have a close look at mmx. – user46655 Feb 05 '19 at 04:31

0 Answers0