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

Substitute unnecessary matrix inversion, use linear solve instead. #74

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

ilopezgp
Copy link
Contributor

@ilopezgp ilopezgp commented Aug 5, 2020

This PR solves issue #73 . Inverting the observational covariance matrix is not necessary, a linear solve can be used instead. The linear solve is faster and more accurate, which can be important when the observational covariance matrix is large or ill-conditioned.

@ilopezgp ilopezgp added the enhancement New feature or request label Aug 5, 2020
@ilopezgp ilopezgp self-assigned this Aug 5, 2020
@codecov
Copy link

codecov bot commented Aug 5, 2020

Codecov Report

Merging #74 into master will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
- Coverage   81.99%   81.90%   -0.09%     
==========================================
  Files           7        7              
  Lines         422      420       -2     
==========================================
- Hits          346      344       -2     
  Misses         76       76              
Impacted Files Coverage Δ
src/MCMC.jl 76.59% <100.00%> (-0.49%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd2cf97...d158298. Read the comment docs.

@ilopezgp ilopezgp requested a review from bielim August 7, 2020 18:24
@ilopezgp
Copy link
Contributor Author

ilopezgp commented Aug 11, 2020

@odunbar I ran the test/MCMC/runtests.jl with this version of the code. It takes an average of 12.8 s to run with my computer. I ran the same test with master and it took an average of 13.5 s to run. At least for the MCMC test, this is faster. This PR always uses a linear solve with a diagonal matrix (stored as a Diagonal type), so the linear solve seems to be quick enough to not slow down the code.

@odunbar
Copy link
Collaborator

odunbar commented Aug 11, 2020

Yeah I expected if the type was recognized, then it would hopefully do something more efficient! Good to know. I'm happy for this to be merged

@ilopezgp
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 11, 2020

Build succeeded:

@bors bors bot merged commit 2e0f764 into master Aug 11, 2020
@bors bors bot deleted the il/fix_invs branch August 11, 2020 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants