Sha256: 36fec6e9994856fd55c1aa7cb75941b44d7288e001b88242041bf06adf36cbe0

Contents?: true

Size: 397 Bytes

Versions: 6

Compression:

Stored size: 397 Bytes

Contents

#!/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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gsl-2.1.0.3 examples/function/function.rb
gsl-2.1.0.2 examples/function/function.rb
gsl-2.1.0.1 examples/function/function.rb
gsl-2.1.0 examples/function/function.rb
gsl-1.16.0.6 examples/function/function.rb
rb-gsl-1.16.0.5 examples/function/function.rb