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

bring LSMR implementation of jutho/krylovkit.jl#46 up to date #109

Closed
wants to merge 11 commits into from

Conversation

VictorVanthilt
Copy link
Contributor

@VictorVanthilt VictorVanthilt commented Dec 6, 2024

other than change @maartenvd 's code to use the new apply_normal and apply_adjoint syntax, this PR is equivalent to #46.

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 85.82090% with 19 lines in your changes missing coverage. Please review.

Project coverage is 83.75%. Comparing base (4d2a06f) to head (0b4de03).

Files with missing lines Patch % Lines
src/linsolve/lsmr.jl 85.49% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #109      +/-   ##
==========================================
- Coverage   85.87%   83.75%   -2.13%     
==========================================
  Files          30       31       +1     
  Lines        3286     3373      +87     
==========================================
+ Hits         2822     2825       +3     
- Misses        464      548      +84     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@VictorVanthilt VictorVanthilt marked this pull request as ready for review December 12, 2024 15:12
@VictorVanthilt
Copy link
Contributor Author

VictorVanthilt commented Dec 12, 2024

This should now be ready to merge.

Comment on lines +284 to +286
"""
LSMR(; orth = KrylovDefaults.orth,atol = KrylovDefaults.tol,btol = KrylovDefaults.tol,conlim = 1/KrylovDefaults.tol,
maxiter = KrylovDefaults.maxiter,krylovdim = KrylovDefaults.krylovdim,λ = 0.0,verbosity = 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this docstring could use some formatting improvements and a bit of a clean up 😉

conlim::S
maxiter::Int
verbosity::Int
λ::S
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having unicode as names for fields can turn out to be not entirely convenient, since this means there is no alternative to access that field on a machine/terminal that has no support for this. While I also like to use unicode, I would advise to only do that for internal variable names, or in cases where an alternative alias can be provided.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it would be good to have an additional mention to the docstring that LSMR requires a different interface for the function handles, since it needs both the regular as well as the adjoint action.

Comment on lines +143 to +148
# Now use these norms to estimate certain other quantities,
# some of which will be small near a solution.
test1 = normr / normb
test2 = normAr / (normA * normr)
test3 = inv(condA)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by the placement of these variables. Is there a reason to define these before the logger, and to then use test1, test2 and test3 below with some unexplained conditions? I think it is a bit more readable to keep that together:
test3 + 1 <= 1 vs inv(condA) + 1 <= 1 seems like it reads better

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these different convergence criteria currently used? If not, I would probably streamline them to be compatible with what we use in the other methods, even if this "reduces" the functionality or options to specify the convergence. I will take a stab at this myself.

@info msg
end

if 1 + test3 <= 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be re-expressed as test3 <= eps(one(test3)) ? This is somewhat strange code, because you could easily think that this just means test3 <= 0, which would be a different check.

test/linsolve.jl Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you should probably also test a non-square matrix here, since that is the primary use-case of the method?

@Jutho Jutho mentioned this pull request Jan 4, 2025
@VictorVanthilt
Copy link
Contributor Author

VictorVanthilt commented Jan 6, 2025

This PR was closed in favor of #111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants