linear_interp

Applies linear interpolation to a 1-dimensional grid.

Syntax

DSP style:

typedef struct {
    Ipp32u  nValues;
    Ipp32f  x1;
    Ipp32f  xSpacing;
    Ipp32f *pYData;
} ippsq_linear_interp_instance_f32;

float32_t ippsq_linear_interp_f32 (ippsq_linear_interp_instance_f32 *S, float32_t x);

q15_t ippsq_linear_interp_q15 (q15_t *pYData, q31_t x, uint32_t nValues);

q31_t ippsq_linear_interp_q31 (q31_t *pYData, q31_t x, uint32_t nValues);

Include Files

dsp.h

Parameters

x

Interpolation coordinate input value.

nValues

Number of elements in the pYData interpolation table.

x1

X space initial value for the floating point interpolation table.

xSpacing

X space step for the floating point interpolation table.

pYData

Pointer to the interpolation table of Y values. The number of elements is nValues.

Description

This function applies interpolation to find an intermediate point y by the specified x coordinate between 1-dimensional grid values using linear polynomials. The grid is defined by the pYData array with nValues elements (y0, y1, y2 in the following figure).



According to the figure above, the interpolation formula is as follows:

y = y0 + (xx1) * (y1 - y0) / xSpacing

Before using the floating point f32 flavor of the interpolation function, initialize the ippsq_linear_interp_instance_f32 structure by setting proper values to its fields. In this structure, x1 is a floating point value of the first grid element y0 and xSpacing is a floating point value of the step between the grid elements. The function may return:

  • y0 if the x coordinate lies on the left side from the x1 point

  • ynValues-1 if the x coordinate lies on the right side from the x1 + xSpacing * nValues point

  • zero if the structure pointer is NULL

If you use Q15 and Q31 integer functions, the x coordinate must be in 12.20 format, where the 12-bit integer part is a position in the pYData array and 20-bit fractional part of the x coordinate is between two nearest pYData array values.

Integer functions may return:

  • ynValues-1 if the x coordinate lies on the right side from the nValues point

  • zero if the pYData pointer is NULL

For more complete information about compiler optimizations, see our Optimization Notice.