Class: Math::Polynomial

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

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 = []) ⇒ Polynomial

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

stepwise function

Arguments are:

values: an array of (x, y) pairs

:nodoc:



22
23
24
# File 'lib/mext/math/polynomial.rb', line 22

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

Instance Attribute Details

#factorsObject (readonly)

:values

is an array of pairs (x, y)



10
11
12
# File 'lib/mext/math/polynomial.rb', line 10

def factors
  @factors
end

#valuesObject (readonly)

:values

is an array of pairs (x, y)



10
11
12
# File 'lib/mext/math/polynomial.rb', line 10

def values
  @values
end

Class Method Details

.from_yaml(yh) ⇒ Object

from_yaml(yaml_hash):

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

values: an array of duples [x, y]



51
52
53
# File 'lib/mext/math/polynomial.rb', line 51

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

Instance Method Details

#labelObject



37
38
39
# File 'lib/mext/math/polynomial.rb', line 37

def label
  'polynomial function'
end

#y(x) ⇒ Object

:doc:

y(x):

Returns a value for any given x

:nodoc:



33
34
35
# File 'lib/mext/math/polynomial.rb', line 33

def y(x)
  calculate(x)
end