Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better solve performance with lsqr #76

Closed
grinsted opened this issue Jan 6, 2020 · 4 comments
Closed

better solve performance with lsqr #76

grinsted opened this issue Jan 6, 2020 · 4 comments

Comments

@grinsted
Copy link

grinsted commented Jan 6, 2020

I get better performance when I use the scipy.sparse.linalg.lsqr iterative solver instead of np.linalg.lstsq.

I get 16.7s vs 19.8s for a test with a big data set.

@efiring
Copy link
Collaborator

efiring commented Jan 6, 2020

That's a very small difference. And, I'm puzzled by your use of a sparse solver; the matrix involved is not sparse.

@grinsted
Copy link
Author

grinsted commented Jan 6, 2020

Those time measurements includes "matrix prep" time which makes up about two thirds of the total run time for solve. When I only measure the LSQR vs LSTSQ statetement then the relative improvement is much greater (9s vs 14s -on another machine). That is IMO substantial. Matrix prep time can also be optimized i believe.

I looked into LSQR because I had prior experience (from matlab) where it gave huge performance boosts on other large non-sparse matrix systems. Perhaps there are other iterative methods that are even better.(?)

@grinsted
Copy link
Author

grinsted commented Jan 7, 2020

Here's a little snippet comparing performance of LSTSQ, LSQR, LSMR: scipy/scipy#11204

For matrices that are 100000x20 and 100000x60 then i get:

                    wall_time
n      p  solver             
100000 20 la.lstsq   0.063300
          spa.lsmr   0.010690
          spa.lsqr   0.016128
       60 la.lstsq   0.215469
          spa.lsmr   0.029070
          spa.lsqr   0.041543

grinsted added a commit to grinsted/UTide that referenced this issue Jan 22, 2020
@efiring
Copy link
Collaborator

efiring commented Sep 8, 2020

Closing, see #81 (comment). This can be reopened as needed.

@efiring efiring closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants