Class: Ecu::Interpolator
- Inherits:
-
Object
- Object
- Ecu::Interpolator
- Defined in:
- lib/ecu/labels/interpolator.rb
Class Method Summary collapse
Class Method Details
.interp1(x_ref, y_ref, x) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ecu/labels/interpolator.rb', line 9 def self.interp1(x_ref, y_ref, x) raise ArgumentError unless x_ref.size == y_ref.size raise ArgumentError unless x_ref.strictly_mon_inc? return y_ref.first if x < x_ref.first return y_ref.last if x > x_ref.last x1, x2, fx = find_position(x_ref, x) interp(y_ref[x1], y_ref[x2], fx) end |
.interp2(x_ref, y_ref, z_ref, x, y) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ecu/labels/interpolator.rb', line 21 def self.interp2(x_ref, y_ref, z_ref, x, y) raise ArgumentError unless z_ref.size == y_ref.size raise ArgumentError unless z_ref.all? { |row| row.size == x_ref.size } raise ArgumentError unless x_ref.strictly_mon_inc? raise ArgumentError unless y_ref.strictly_mon_inc? x1, x2, fx = find_position(x_ref, x) y1, y2, fy = find_position(y_ref, y) interp(interp(z_ref[y1][x1], z_ref[y2][x1], fy), interp(z_ref[y1][x2], z_ref[y2][x2], fy), fx) end |