/* Process function for the Q31 Linear Interpolation Function.  */
q31_t arm_linear_interp_q31(const q31_t *pYData, q31_t x, uint32_t nValues)
/* Process function for the Q31 Linear Interpolation Function.  */
q31_t arm_linear_interp_q31(const q31_t *pYData, q31_t x, uint32_t nValues)
{
    q31_t y;
    q31_t y0, y1;
    q31_t fract;
    int32_t index;
    index = ((x & (q31_t)0xFFF00000) >> 20);
    if (index >= (int32_t)(nValues - 1))
    {
      return (pYData[nValues - 1]);
    }
    else if (index < 0)
    {
      return (pYData[0]);
    }
    else
    {
      fract = (x & 0x000FFFFF) << 11;
      y0 = pYData[index];
      y1 = pYData[index + 1];
      y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
      y += ((q31_t) (((q63_t) y1 * fract) >> 32));
      return (y << 1U);
    }
  }