Function vector_lookup (o2scl)

O2scl : Function List

template<class vec_t, class data_t>
size_t o2scl::vector_lookup(size_t n, const vec_t &x, data_t x0)

Lookup the value x0 in the first n elements of vector x.

The function finds the element among the first n elements of x which is closest to the value x0. It ignores all elements in x which are not finite. If the vector is empty, or if all of the first n elements in x are not finite, then the error handler will be called.

This function works for all vector types vec_t with an operator[] method which returns a floating point number of type fp_t (either as a value or a reference), and which is composed of a floating point number of type fp_t for which the function abs() is defined.

template<class vec_t, class fp_t>
size_t o2scl::vector_lookup(const vec_t &x, fp_t x0)

Lookup element x0 in vector x.

This function finds the element in vector x which is closest to x0. It ignores all elements in x which are not finite. If the vector is empty, or if all of the elements in x are not finite, then the error handler will be called.

This function works for all classes vec_t with a size() method and where an operator[] is defined which returns a fp_t (either as a value or a reference), and which is composed of a floating point number of type fp_t for which the function abs() is defined.