Class: ChebyRuby::UnivariateFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/chebyruby/univariate_function.rb

Overview

This is the class for a univariate function.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&func) ⇒ UnivariateFunction

The constructor for the class UnivariateFunction.

Parameters:

  • func (Lambda)

    which represents the function.



10
11
12
# File 'lib/chebyruby/univariate_function.rb', line 10

def initialize(&func)
  @func = func
end

Instance Attribute Details

#funcLambda

the univariate function.

Returns:

  • (Lambda)

    the current value of func



4
5
6
# File 'lib/chebyruby/univariate_function.rb', line 4

def func
  @func
end

Instance Method Details

#value(x) ⇒ Object

This gets the value of the function at a specified value.

Parameters:

  • x (Numeric)

    the value at which the function is evaluated.

Returns:

  • the value of the function at x.



18
19
20
# File 'lib/chebyruby/univariate_function.rb', line 18

def value(x)
  func.call(x.to_f)
end