![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
File for "smart" interpolation routines. More...
#include <o2scl/interp.h>
#include <o2scl/vector.h>
Go to the source code of this file.
In addition to the smart interpolation routines, this file contains the template functions vector_find_level(), vector_integ_linear() and vector_invert_enclosed_sum().
Definition in file smart_interp.h.
Data Structures | |
class | smart_interp< vec_t, svec_t > |
Smart interpolation class. More... | |
class | smart_interp_vec< vec_t, svec_t, alloc_vec_t, alloc_t > |
Smart interpolation class with pre-specified vectors. More... | |
class | sma_interp< n > |
A specialization of smart_interp for C-style double arrays. More... | |
class | sma_interp_vec< arr_t > |
A specialization of smart_interp_vec for C-style double arrays. More... | |
Typedefs | |
typedef smart_interp < ovector_const_view, ovector_const_subvector > | sm_interp |
typedef smart_interp_vec < ovector_const_view, ovector_const_subvector, ovector, ovector_alloc > | sm_interp_vec |
Functions | |
template<class vec_t , class vec2_t > | |
int | vector_find_level (double level, size_t n, vec_t &x, vec2_t &y, ovector &locs) |
Perform inverse linear interpolation. | |
template<class vec_t > | |
double | vector_integ_linear (size_t n, vec_t &x, vec_t &y) |
Compute the integral over y(x) using linear interpolation. | |
template<class vec_t > | |
int | vector_invert_enclosed_sum (double sum, size_t n, vec_t &x, vec_t &y, double &lev) |
Compute the endpoints which enclose the regions whose integral is equal to sum . |
int vector_find_level | ( | double | level, |
size_t | n, | ||
vec_t & | x, | ||
vec2_t & | y, | ||
ovector & | locs | ||
) |
This function performs inverse linear interpolation of the data defined by x
and y
, finding all points in x
which have the property . All points for which this relation holds are put into the vector
locs
. The previous information contained in vector locs
before the function call is destroyed.
This is the 1-dimensional analog of finding contour levels as the contour class does for 2 dimensions.
Definition at line 867 of file smart_interp.h.
int vector_invert_enclosed_sum | ( | double | sum, |
size_t | n, | ||
vec_t & | x, | ||
vec_t & | y, | ||
double & | lev | ||
) |
Defining a new function, which takes as input any y-value,
from the function
(specified with the parameters
x
and y
) and outputs the integral of the function over all regions where
. This function inverts
, taking the value of an integral as input, and returns the corresponding y-value in the variable
lev
.
In order to make sure that the intepretation of the integral is unambiguous, this function requires that the first and last values of y
are equal, i.e. y[0]==y[n-1]
.
This function is particularly useful, for example, in computing the region which defines 68% around a peak of data, thus providing approximate limits.
Linear interpolation is used to describe the function , and the precision of this function is limited by this assumption. This function may also sometimes fail if
sum
is very close to the minimum or maximum value of the function .
Definition at line 938 of file smart_interp.h.
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).