src/k_interpolate.c
float k_interpolate(float currpos,
                    float vals[],
                    float pos[],
                    IDL_LONG n)
{
	unsigned long i,ip1;
	float sp,currval;

	k_locate(pos, (unsigned long) n, currpos, &i);
	if(i>=n-1) return(vals[n-1]);
	if(i<0) return(vals[0]);
	ip1=i+1;
	sp=currpos-pos[i];
	currval=vals[i]+sp*(vals[ip1]-vals[i])/(pos[ip1]-pos[i]);
	return(currval);
}
/* linear interpolate in a given vector; out of bounds --> 0 */
linear interpolate in a given vector; out of bounds --> 0
linear interpolate in a given vector ; out of bounds -- > 0
float k_interpolate(float currpos,
                    float vals[],
                    float pos[],
                    IDL_LONG n)
{
	unsigned long i,ip1;
	float sp,currval;
	k_locate(pos, (unsigned long) n, currpos, &i);
	if(i>=n-1) return(vals[n-1]);
	if(i<0) return(vals[0]);
	ip1=i+1;
	sp=currpos-pos[i];
	currval=vals[i]+sp*(vals[ip1]-vals[i])/(pos[ip1]-pos[i]);
	return(currval);
}
float k_interpolate ( float currpos , float vals [ ] , float pos [ ] , IDL_LONG n ) { unsigned long i , ip1 ; float sp , currval ; k_locate ( pos , ( unsigned long ) n , currpos , & i ) ; if ( i >= n - 1 ) return ( vals [ n - 1 ] ) ; if ( i < 0 ) return ( vals [ 0 ] ) ; ip1 = i + 1 ; sp = currpos - pos [ i ] ; currval = vals [ i ] + sp * ( vals [ ip1 ] - vals [ i ] ) / ( pos [ ip1 ] - pos [ i ] ) ; return ( currval ) ; }
linear interpolate in a given vector; out of bounds --> 0
linear interpolate in a given vector ; out of bounds -- > 0