arrayfun for multiple least squares problems?
Show older comments
I want to solve thousands of very tiny least squares problems, all of the same size. It is taking forever to do them one at a time, but I can't seem to figure out how to use arrayfun, or accumarray, or ... to do this. Is there a way to speed this up?
Answers (2)
bym
on 4 Oct 2011
0 votes
see if my answer on fitting multiple curves would help
Walter Roberson
on 5 Oct 2011
0 votes
arrayfun() over enough elements usually times as being slightly slower than a "for" loop that has had preallocation done.
If you are using the \ operator (mldivide), sometimes you can do better. The \ operator has to analyze what kind of problem is involved each time, but you already know the problem type.
You might, for example, be able to figure out which BLAS or LAPACK routines are suitable, and call them directly using a MATLAB File Exchange contribution http://www.mathworks.com/matlabcentral/fileexchange/16777
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!