Object-oriented Scientific Computing Library: Version 0.910
Interpolation

The lower-level interpolation types based on GSL all inherit from base_interp. These lower-level interpolation classes automatically use the GSL accelerated lookup system and have also been modified to handle monotonically decreasing vectors. They are template classes compatible with any vector type whose elements can be accessed with operator[].

Integrals are always computed assuming that if the limits are ordered so that if the upper limit appears earlier in the array x in comparison to the lower limit, that the value of the integral has the opposite sign than if the upper limit appears later in the array x .

The classes o2scl_interp and o2scl_interp_vec provide simpler interfaces to the lower-level interpolation types taking care of memory allocation and initialization automatically. The difference between the two classes, o2scl_interp and o2scl_interp_vec, analogous to the difference between using gsl_interp_eval() and gsl_spline_eval() in GSL. You can create a o2scl_interp object and use it to interpolate among any pair of chosen vectors, i.e.

    ovector x(20), y(20);
    // fill x and y with data
    o2scl_interp oi;
    double y_half=oi.interp(0.5,20,x,y);

Alternatively, you can create a o2scl_interp_vec object which can be optimized for a pair of vectors that you specify in advance

    ovector x(20), y(20);
    // fill x and y with data
    o2scl_interp_vec oi(20,x,y);
    double y_half=oi.interp(0.5);

Two specializations for C-style arrays of double-precision numbers are provided in array_interp and array_interp_vec.

Lookup and binary search

The classes search_vec and search_vec_ext contain searching functions for generic vector types which contain monotonic (either increasing or decreasing) data. It is search_vec which is used internally by the interpolation classes to perform cached binary searching. These classes also allow one to to exahaustively search for the index of an element in a vector without regard to any kind of ordering, e.g. search_vec::ordered_lookup() (see also ovector::lookup()).

"Smart" interpolation

The classes smart_interp and smart_interp_vec allow interpolation, lookup, differentiation, and integration of data which is non-monotonic or multiply-valued outside the region of interest. As with o2scl_interp above, the corresponding array versions are given in sma_interp and sma_interp_vec.

Interpolation manager objects

Many O2scl classes require the ability to create and destroy several interpolation objects to interpolate many different vectors at the same time. For this purpose, interpolation managers have been created, which allow the user to provide a class with an interpolation manager associated with a low-level interpolation type (and thus free the user from having to worry about the associated memory management). The abstract base interpolation manager type is base_interp_mgr, and the default interpolation manager object is def_interp_mgr . The def_interp_mgr class has two template arguments: the first is the vector type to be interpolated, and the second is the lower-lever interpolation type. The user is free to use the same interpolation manager instance for many different classes which require interpolation because the interpolation manager allocates separate interpolation instances for each class as necessary.

For an example usage of the default interpolation manager, see the Contour lines , which specifies an interpolation manager for the contour class. The table class also works with interpolation manager objects (see table::set_interp() ).

Two and higher dimensional interpolation

Support for two-dimensional interpolation (by successive one-dimensional interpolations) is given in twod_intp (see Two-dimensional Interpolation), and a simple version of n-dimensional interpolation in tensor_grid.

Inverse interpolation and other functions

The equivalent to "inverse" linear interpolation, which computes all the abcissae which have a fixed value of the ordinate is implemented in the template function vector_find_level() which is documented in smart_interp.h . This function together with vector_invert_enclosed_sum() can be used to determine confidence limits surrounding the peak of a 1-dimensional data set using linear interpolation.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.