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

divonne and cuhre pass vector of length 2 for one-dimensional integration #14

Closed
oschulz opened this issue Oct 23, 2017 · 6 comments
Closed
Labels

Comments

@oschulz
Copy link

oschulz commented Oct 23, 2017

When integrating in one dimension, vegas and suave call the integrand with a vectir of length 1 (as expected), but divonne and cuhre pass a vector of length 2:

julia> vegas((x, f) -> ((@assert length(x) == 1); f[1] = norm(x)), 1)
...

julia> suave((x, f) -> ((@assert length(x) == 1); f[1] = norm(x)), 1)
...

julia> divonne((x, f) -> ((@assert length(x) == 1); f[1] = norm(x)), 1)
ERROR: AssertionError: length(x) == 1
julia> divonne((x, f) -> ((@assert length(x) == 2); f[1] = norm(x)), 1)
...

julia> cuhre((x, f) -> ((@assert length(x) == 1); f[1] = norm(x)), 1)
ERROR: AssertionError: length(x) == 1
julia> cuhre((x, f) -> ((@assert length(x) == 2); f[1] = norm(x)), 1)
...
@oschulz oschulz changed the title cuhre and suave pass vector of length 2 for one-dimensional integration divonne and cuhre pass vector of length 2 for one-dimensional integration Oct 23, 2017
@giordano
Copy link
Owner

giordano commented Oct 23, 2017

Hi Oliver. That's correct, those methods require ndim to be at least 2. Did you run into some issues because of this?

@oschulz
Copy link
Author

oschulz commented Oct 23, 2017

Hi, thanks - should have looked into the Cuba docs. :-) I did run into issues, but it was only in a toy case. But maybe divonne and cuhre should throw an ArgumentError if run for one dimension, just in case?

@giordano
Copy link
Owner

Currently I forcibly set ndim = 2 if it's equal to 1:

ndim == 1 && (ndim = 2)
I thought that this would have been quite harmless, but I see that using something like norm can lead to unexpected results.

I will change the default value of ndim for cuhre and divonne to 2, throw an error for lower values, better document this.

@oschulz
Copy link
Author

oschulz commented Oct 24, 2017

grazie!

@giordano
Copy link
Owner

Bitte ;-) I've merged PR #15, do let me know if you need a tagged version of this package.

@oschulz
Copy link
Author

oschulz commented Oct 24, 2017

Thanks, no, I don't need an urgent tag on this.

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

No branches or pull requests

2 participants