'bilinear interpolation with DSP CMSIS library - passing 2D array

I am struggling to obtain the correct results for the function with CMSIS DSP bilinear_interp.

I've first tried a simple linear interpolation:

  float test_table[10] ={0,1,2,3,4,5,6,7,8,9};

  arm_linear_interp_instance_f32 X = {10, 0, 2, &test_table[0]};
  float value = arm_linear_interp_f32(&X, 1.985); // returns 0.992500007

and here everything worked perfectly.

However, once I've moved to the 2D array case, my fcn returns 0. I think I might be having a problem with proper referencing of a pointer to the 2D array or navigating through the table, as in this case, I am not defining the structure with the x_start, y_start value and step size.

     float table[4][4] =
  {
    { 0.0000000,  5.0000000, 10.0000000, 15.0000000},
    { 0.0010000, -8.6118048, -8.1281505, -7.6451570},
    { 0.0020000, -8.4220894, -7.9479818, -7.4748312},
    { 0.0030000, -8.2401269, -7.7760690, -7.3137646}
  };

  arm_bilinear_interp_instance_f32 S = {4,4, &table[0][0]};
  float result = arm_bilinear_interp_f32(&S, 0.014493, 13.5312); // returns 0 

Any help would be highly appreciated.

Link to the documentation: https://arm-software.github.io/CMSIS_5/DSP/html/group__BilinearInterpolate.html



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source