GSL::Function class

Class Methods


Methods




Graph


Example

A quadratic function, f(x) = x^2 + 2x + 3.

>> require("gsl")
=> true
>> f = Function.alloc { |x, param| x*x + param[0]*x + param[1] }
=> #<GSL::Function:0x6e8eb0>
>> f.set_params(2, 3)
=> #<GSL::Function:0x6e8eb0>
>> f.eval(2)                             <--- Scalar
=> 11
>> f.eval(1..4)                          <--- Range
=> [6.0, 11.0, 18.0, 27.0]
>> f.eval([1, 2, 3])                     <--- Array
=> [6.0, 11.0, 18.0]
>> f.eval(Matrix.alloc([1, 2], [3, 4]))    <--- GSL::Matrix
[ 6.000e+00 1.100e+01
  1.800e+01 2.700e+01 ]
=> #<GSL::Matrix:0x6dd1b4>

back