At Tue, 8 Jun 2010 13:31:29 -0700,
Luke wrote:
>
> I have a gsl_vector whose values are evenly space from -M_PI to M_PI.
> I am using the GSL single dimensional root finding algorithm on a
> single equation which gives me a value that is in the range of [-M_PI,
> M_PI], but won't be exactly equal to any of the elements. My goal is
> to find the index of the element in my gsl_vector which is closest to
> the solution from the root finding algorithm. Here is an illustration
> of situation:
>
> v = {-1.0, -0.5, 0.0, 0.5, 1.0}
> x_star = 0.3
>
> Since the entry of v closest to x_star is 0.5, the index I would want
> to obtain is i = 3.
>
> I would imagine the function call to be something like:
>
> i = get_nearest_index(v, x_star);
Hi
See the Interpolation chapter of the manual in the section on "Index
Look-up and Acceleration"
--
Brian Gough
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl