Class: Math::Polynomial
- Defined in:
- lib/mext/math/polynomial.rb
Instance Attribute Summary collapse
-
#factors ⇒ Object
readonly
:values
. -
#values ⇒ Object
readonly
:values
.
Attributes inherited from Function
Class Method Summary collapse
-
.from_yaml(yh) ⇒ Object
from_yaml(yaml_hash):.
Instance Method Summary collapse
-
#initialize(vs = []) ⇒ Polynomial
constructor
Math::Polynomial.new(values = []).
- #label ⇒ Object
-
#y(x) ⇒ Object
:doc:.
Methods inherited from Function
Methods included from Mext::Utilities
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
#factors ⇒ Object (readonly)
:values
is an array of pairs (x
, y
)
10 11 12 |
# File 'lib/mext/math/polynomial.rb', line 10 def factors @factors end |
#values ⇒ Object (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
#label ⇒ Object
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 |