def interpolate interpolant
      case @opts[:type]
      when :linear
        for_each (interpolant) { |x| linear_interpolation(x)  }
      when :cubic
        cubic_spline_interpolation interpolant
      else
        raise ArgumentError, "1 D interpolation of type #{@opts[:type]} not supported"
      end
    end
def interpolate interpolant
      case @opts[:type]
      when :linear
        for_each (interpolant) { |x| linear_interpolation(x)  }
      when :cubic
        cubic_spline_interpolation interpolant
      else
        raise ArgumentError, "1 D interpolation of type #{@opts[:type]} not supported"
      end
    end
Constructor for all One Dimensional interpolation operations.

 The function values to be supplied to this class are of the form y = f(x).

 Henceforth, y will be referred to as ordinate and x as absicca. If absicca
 and ordinate arrays are not of the same length, then the effective size used
 for interpolation will be MIN(x.size, y.size).

 ==== Arguments

 * +x+ -    The collection of absiccas. Must be a 1 D NMatrix or ruby Array.

 * +y+ -    The collection of ordinates corresponding to the absicca. 'y' can
            either be a 1D NMatrix or Array OR a 2D NMatrix. In case y contains
            multiple columns, the interpolation is carried out on each column,
            unless specified.

 * +opts+ - Various options for carrying out the interpolation.

 ==== Options

 * +:type+ - The kind of interpolation that the user wants to perform. Should be
             specified as a symbol. Defaults to linear. Only linear and cubic
             interpolation supported as of now. Cubic interpolation done with splines.

 * +:sorted+ - Set this option as *true* if the absicca collection is supplied in
             the arguments in a sorted manner. If not supplied, it will be assumed
             that absiccas are not sorted and they will sorted be sorted anyway.

 * +:axis+ - In case of a multidimensional ordinate matrix, specify the column over
 which interpolation must be performed. *axis* starts indexing from 0 and should be
 lower than the number of columns in the ordinate matrix.

 * +:precision+ - Specifies the precision of the interpolated values returned. Defaults
 to 3.

 * +:yp1+ - First derivative of the 0th point (cubic spline).

 * +:ypn+ - First derivative of the last (n-1)th point (cubic spline).

 == Usage

   x = (0..9).step(1).to_a
   y = x.map { |n| Math.exp(n) }
   f = Interpolation::OneDimensional.new x,y, type: :cubic
   f.interpolate 2.5
     #=> 12.287
 Performs the actual interpolation on the value passed as an argument. Kind of
 interpolation performed is determined according to what is specified in the
 constructor.

 ==== Arguments

 * +interpolant+ - The value for which the interpolation is to be performed. Can
                   either be a Numeric, Array of Numerics or NMatrix. If multidimensional
                   NMatrix is supplied then will flatten it and interpolate over
                   all its values. Will return answer in the form of an NMatrix if
                   *interpolant* is supplied as an NMatrix.