=begin
= GSL::Function class

== Class Methods

--- GSL::Function.new
--- GSL::Function.alloc
    Constructor for an instance of the (({Function})) class.
   
    * ex:
       require("gsl")
       f = Function.new { |x| sin(x) }

    The value of the function is evaluated by the method (({eval})), as

       p f.eval(x)

    The function can have constant parameters of arbitrary numbers. Here is an
    example in case of exponential function (({f(x; a, b) = a*exp(-b*x)})).
      
       f = Function.new { |x, params|    # x: a scalar, params: an array
         a = params[0]
         b = params[1]
         a*exp(-b*x)
       }
    To evaluate the function (({f(x) = 2*exp(-3*x)})), 
       f.set_params([2, 3])
       f.eval(x)

== Methods

--- GSL::Function#eval(x)
--- GSL::Function#call(x)
--- GSL::Function#at(x)
--- GSL::Function#[x]
    These methods return a value of the function at ((|x|)).
      p f.eval(2.5)
      p f.call(2.5)
      p f[2.5]

--- GSL::Function#set { |x| ... }
--- GSL::Function#set(proc, params)
    This method sets or resets the procedure of ((|self|)), as

      f = GSL::Function.new { |x| sin(x) }
      p f.eval(1.0)               <- sin(1.0)
      f.set { |x| cos(x) }
      p f.eval(1.0)               <- cos(1.0)

--- GSL::Function#set_params(params)
    This set the constant parameters of the function.

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

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

((<back|URL:index.html>))
=end
