Class: Interpolation::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/interpolation/base.rb

Direct Known Subclasses

OneDimensional

Instance Method Summary collapse

Constructor Details

#initialize(x, y, opts) ⇒ Base

Returns a new instance of Base.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/interpolation/base.rb', line 16

def initialize x, y, opts
  @x, @y = x, y

  @opts = {
    precision: 3,
    sorted: false,
    type: :linear
  }.merge(opts)

  @size = @x.size # considers size of @x only
  @x    = @x.sort unless @opts[:sorted]
  @x.map! { |n| n = Float(n)}
end