Sha256: 0cdf25655b5376285e31cb232a446f9353917ccd6493825defc7ddb08297b492

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module Math

  class Function

    attr_reader :x_start, :x_end
    #
    # +Math::Function.new+:
    #
    # abstract base class function
    #
    #:nodoc:
    def initialize
      setup
    end

    #:doc:
    #
    # +y(x)+:
    #
    # Returns a real value given x
    #
    #:nodoc:
    def y(x)
    end

    #: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:
    def xy(s)
      resx = []
      resy = []
      self.x_start.step(x_end, s) do
        |x|
        resx << x
        resy << self.y(x)
      end
      [resx, resy]
    end

    #:doc:
    #
    # +label+
    #
    # Returns a label which can be used in plots
    #
    def label
      ''
    end

  private

    def setup
      raise Mext::PureAbstractMethodCalled
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-mext-0.4.1 lib/mext/math/function.rb
ruby-mext-0.4.0 lib/mext/math/function.rb
ruby-mext-0.3.2 lib/mext/math/function.rb
ruby-mext-0.3.1 lib/mext/math/function.rb