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

Issue with Interp #28

Open
DanielLeuenberger opened this issue Feb 12, 2016 · 4 comments
Open

Issue with Interp #28

DanielLeuenberger opened this issue Feb 12, 2016 · 4 comments

Comments

@DanielLeuenberger
Copy link

Hi,
I have this small test (test_interp.rb) of the Interp function:

require "gsl"
x=[0,1,2,3,4].to_gv
y=[0,1,2,3,4].to_gv
x_new = [3.5].to_gv
puts "x: #{x.inspect}"
puts "y: #{y.inspect}"
puts "x_new: #{x_new.inspect}"
i=GSL::Interp.alloc("linear",x.length)
y_new = i.eval(x,y,x_new)
puts "y_new: #{y_new.inspect}"

With ruby 1.9.3p125, rb-gsl 1.14.7 and GSL 1.14 this always works fine.

With ruby 2.2.0, rb-gsl 1.16.0.6 and GSL 1.16 this gives the error:

test_interp.rb:9:in `eval': Ruby/GSL error code 1, interpolation error (file interp.c, line 150), input domain error (GSL::ERROR::EDOM)

The bad thing is: this error is not reproducable, sometimes the example works, but most of the time it does not. Is there a known issue which explains the behaviour?

Thanks and best regards
Daniel

@DanielLeuenberger
Copy link
Author

After unsuccessful fiddling around with older Versions of GSL and rb-gsl, I accidentally tried the following way of allocating the Interp object:

i=GSL::Interp.alloc("linear",x,y)

Now, the Baby example above works.

Maybe this helps also others and might help to fix a bug in the library?

@v0dro
Copy link
Member

v0dro commented Feb 16, 2016

I think we should restrict allocation to one method only. I'll have a look soon.

@DanielLeuenberger
Copy link
Author

Also the second way of allocating the Interp object, leads occasionally to the same error, though not so often as the first one. A fix would be highly appreciated! Thanks a lot!

ktns pushed a commit to ktns/rb-gsl that referenced this issue Feb 26, 2016
Would help us in addressing SciRuby#28.
@urbanrotnik
Copy link

I am also facing this problem...

I think we should restrict allocation to one method only. I'll have a look soon.

@v0dro What you mean with .. allocation to one method only. ?
Should I call interp.alloc only once per my ruby method or is a problem if I use Vector.alloc in the same method?

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