Class: Math::Function

Inherits:
Object
  • Object
show all
Includes:
Mext::Utilities
Defined in:
lib/mext/math/function.rb

Direct Known Subclasses

Expon, Line, Log, Polynomial, Stepwise

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mext::Utilities

included

Constructor Details

#initializeFunction

Math::Function.new:

abstract base class function

:nodoc:



12
13
14
# File 'lib/mext/math/function.rb', line 12

def initialize
  setup
end

Instance Attribute Details

#x_endObject (readonly)

Returns the value of attribute x_end.



5
6
7
# File 'lib/mext/math/function.rb', line 5

def x_end
  @x_end
end

#x_startObject (readonly)

Returns the value of attribute x_start.



5
6
7
# File 'lib/mext/math/function.rb', line 5

def x_start
  @x_start
end

Instance Method Details

#labelObject

:doc:

label

Returns a label which can be used in plots



55
56
57
# File 'lib/mext/math/function.rb', line 55

def label
  ''
end

#xy(s) ⇒ Object

:doc:

xy(step)

Returns a full deployment of the function evaluated with a step of step. It is returned in two arrays - one for the x values and the other for the y values.

This method is mainly for testing purposes with the dataxy method of gruff

:nodoc:



38
39
40
41
42
43
44
45
46
47
# File 'lib/mext/math/function.rb', line 38

def xy(s)
  resx = []
  resy = []
  self.x_start.step(x_end, s) do
    |x|
    resx << x
    resy << self.y(x)
  end
  [resx, resy]
end

#y(x) ⇒ Object

:doc:

y(x):

Returns a real value given x

:nodoc:



23
24
25
# File 'lib/mext/math/function.rb', line 23

def y(x)
  x
end