Class: Math::Stepwise

Inherits:
Function show all
Defined in:
lib/mext/math/stepwise.rb

Defined Under Namespace

Classes: Point

Instance Attribute Summary collapse

Attributes inherited from Function

#x_end, #x_start

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

#xy

Methods included from Mext::Utilities

included

Constructor Details

#initialize(vs = []) ⇒ Stepwise

Math::Stepwise.new(values = [])

stepwise function

Arguments are:

values: an array of (x, y) pairs

:nodoc:



31
32
33
# File 'lib/mext/math/stepwise.rb', line 31

def initialize(vs = [])
  setup(vs)
end

Instance Attribute Details

#valuesObject (readonly)

:values

is an array of pairs (x, y)



19
20
21
# File 'lib/mext/math/stepwise.rb', line 19

def values
  @values
end

Class Method Details

.from_yaml(yh) ⇒ Object

from_yaml(yaml_hash):

creates a Math::Stepwise class from a yaml file which must have the relevant fields:

values: an array of duples [x, y]



60
61
62
# File 'lib/mext/math/stepwise.rb', line 60

def from_yaml(yh)
  new(yh['values'])
end

Instance Method Details

#labelObject



46
47
48
# File 'lib/mext/math/stepwise.rb', line 46

def label
  'stepwise function'
end

#y(x) ⇒ Object

:doc:

y(x):

Returns a value for any given x

:nodoc:



42
43
44
# File 'lib/mext/math/stepwise.rb', line 42

def y(x)
  lookup(x)
end