-
Notifications
You must be signed in to change notification settings - Fork 15
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
ellipse, combine A0 and A1 integral, sort !sanity_check, parallel ptrapz #165
Conversation
Sweet! I think sorting will not work so well if we have an ellipse. Do you think it would work to change the distance measure with appropriate weighting? Like this:
(I think I got the weighting wrong...) |
I guess I have to ask what the significance of sorting is if the contour is not a circle. To me it seems that the idea of returning the If the user chooses not to search over a disk, they should not expect to get the closest eigenpairs. So while I don't see any harm to defining a weighted norm for the ellipse, I don't really see it as especially meaningful, since "closest" is only a meaningful measure if the contour was a circle to begin with. What do you think? |
I view the contour as also the region of interest. That's the same as closest to σ for circles but not ellipses (unless we use weighting). Contour integral methods sometimes capture eigvals outside the contour. Suppose we use σ=0, radius=[1;3], neigs=1 and that algorithm finds eigenvalues λ=[1.5im 2] Then the user will get the eigenvalue λ=1.5im, which is not inside the contour, probably not the eigval she wanted. This will matter if we are interested in (close to) real eigenvalues. Discarding eigvals outside the contour would also be okay solution for me. |
I see, that's a good point, and one that has come up in my own use. Would it not be better to address the problem head on by throwing away eigenvalues that are outside the contour, maybe throwing a warning and suggesting higher |
Sounds good! |
Great, I'll add an inside-contour check this weekend. |
hmm, I hate to nitpick, but I think the logic surrounding Right now, the user requests The actual Beyn algorithm as I understand it constructs a matrix I think it makes more sense to explicitly construct a |
You're totally right that about Beyn's method and k vs p (seems easy to fix), and indeed it requires reworking the sanity_check code (less obvious). |
I think I fixed it with the most recent commit. The The commits I just made seem to check out with the example we worked on previously for The most recent commit does not throw away the outside eigenpairs per se, it just moves them to the end of the line and throws a warning. If all This gives sufficient warning to the user, guides them on how to improve accuracy, but leaves it to them to decide what to do with the extra eigenpairs. I did this because I have found that knowing what the "wrong" eigenvalue is can help diagnose how to fix it, if it indeed needs fixing. How does that sound? |
Looks very good. In particular that you don't discard wrt to boundary but instead put them at the end. This is robust wrt numerical errors that make eigvals jump over boundary. Is it possible to somehow also avoid throwing a warning if I will have a look at this PR again tomorrow, but it looks ready to be merged. |
good idea about the I've just made the change. |
Summary of changes
Circle contour extended to ellipse (useful when, say, you are interested in complex eigenvalues close to the real axis).
More useful still would be the ability to define a polygon, which could define a strip along the real or imaginary axes, but that is not done here.
I've combined the quadratures for
A0
andA1
, which reduces the number of calls to the linear operator by half, leading to significant speedup.I added a the sorting step for the case when
sanity_check=false
. This means that the eval/evecs will always be sorted by their distance fromσ
, regardless of thesanity_check
status.Lastly, I extended the quadrature methods by a parallel version of
:ptrapz
, called:ptrapz_parallel
.I changed some of the function documentation to reflect this.
Timing statistics due to the changes
Setup:
The results before the changes are
The results for the serial code after the changes are
The results for the parallel code after changes (there is no pre-change counterpart) (use
quad_method=:ptrapz_parallel
)