/usr/share/doc/ruby-gsl/examples/function/function.rb is in ruby-gsl 2.1.0.3+dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #!/usr/bin/env ruby
require("gsl")
include Math
f = GSL::Function::alloc{ |x, params|
a = params[0]
b = params[1]
c = params[2]
(a*x + b)*x + c
}
p f.proc
p f.params
a = 1; b = 2; c = 3
f.set_params(a, b, c)
p f.params
p f.eval(2)
p f.call(4)
f.set { |x|
x*x*x
}
p f.params
p f.eval(2)
p f[4]
f2 = GSL::Function.alloc { |x|
sin(x) - log(x)*sqrt(x)
}
p f2.eval(2.5)
p f2.arity
|