interpolation_functions.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /******************************************************************************
  2. * @file interpolation_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: Cortex-M and Cortex-A cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. *
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the License); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. #ifndef _INTERPOLATION_FUNCTIONS_H_
  26. #define _INTERPOLATION_FUNCTIONS_H_
  27. #include "arm_math_types.h"
  28. #include "arm_math_memory.h"
  29. #include "dsp/none.h"
  30. #include "dsp/utils.h"
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #endif
  35. /**
  36. * @defgroup groupInterpolation Interpolation Functions
  37. * These functions perform 1- and 2-dimensional interpolation of data.
  38. * Linear interpolation is used for 1-dimensional data and
  39. * bilinear interpolation is used for 2-dimensional data.
  40. */
  41. /**
  42. * @brief Instance structure for the floating-point Linear Interpolate function.
  43. */
  44. typedef struct
  45. {
  46. uint32_t nValues; /**< nValues */
  47. float32_t x1; /**< x1 */
  48. float32_t xSpacing; /**< xSpacing */
  49. float32_t *pYData; /**< pointer to the table of Y values */
  50. } arm_linear_interp_instance_f32;
  51. /**
  52. * @brief Instance structure for the floating-point bilinear interpolation function.
  53. */
  54. typedef struct
  55. {
  56. uint16_t numRows; /**< number of rows in the data table. */
  57. uint16_t numCols; /**< number of columns in the data table. */
  58. float32_t *pData; /**< points to the data table. */
  59. } arm_bilinear_interp_instance_f32;
  60. /**
  61. * @brief Instance structure for the Q31 bilinear interpolation function.
  62. */
  63. typedef struct
  64. {
  65. uint16_t numRows; /**< number of rows in the data table. */
  66. uint16_t numCols; /**< number of columns in the data table. */
  67. q31_t *pData; /**< points to the data table. */
  68. } arm_bilinear_interp_instance_q31;
  69. /**
  70. * @brief Instance structure for the Q15 bilinear interpolation function.
  71. */
  72. typedef struct
  73. {
  74. uint16_t numRows; /**< number of rows in the data table. */
  75. uint16_t numCols; /**< number of columns in the data table. */
  76. q15_t *pData; /**< points to the data table. */
  77. } arm_bilinear_interp_instance_q15;
  78. /**
  79. * @brief Instance structure for the Q15 bilinear interpolation function.
  80. */
  81. typedef struct
  82. {
  83. uint16_t numRows; /**< number of rows in the data table. */
  84. uint16_t numCols; /**< number of columns in the data table. */
  85. q7_t *pData; /**< points to the data table. */
  86. } arm_bilinear_interp_instance_q7;
  87. /**
  88. * @brief Struct for specifying cubic spline type
  89. */
  90. typedef enum
  91. {
  92. ARM_SPLINE_NATURAL = 0, /**< Natural spline */
  93. ARM_SPLINE_PARABOLIC_RUNOUT = 1 /**< Parabolic runout spline */
  94. } arm_spline_type;
  95. /**
  96. * @brief Instance structure for the floating-point cubic spline interpolation.
  97. */
  98. typedef struct
  99. {
  100. arm_spline_type type; /**< Type (boundary conditions) */
  101. const float32_t * x; /**< x values */
  102. const float32_t * y; /**< y values */
  103. uint32_t n_x; /**< Number of known data points */
  104. float32_t * coeffs; /**< Coefficients buffer (b,c, and d) */
  105. } arm_spline_instance_f32;
  106. /**
  107. * @ingroup groupInterpolation
  108. */
  109. /**
  110. * @addtogroup SplineInterpolate
  111. * @{
  112. */
  113. /**
  114. * @brief Processing function for the floating-point cubic spline interpolation.
  115. * @param[in] S points to an instance of the floating-point spline structure.
  116. * @param[in] xq points to the x values ot the interpolated data points.
  117. * @param[out] pDst points to the block of output data.
  118. * @param[in] blockSize number of samples of output data.
  119. */
  120. void arm_spline_f32(
  121. arm_spline_instance_f32 * S,
  122. const float32_t * xq,
  123. float32_t * pDst,
  124. uint32_t blockSize);
  125. /**
  126. * @brief Initialization function for the floating-point cubic spline interpolation.
  127. * @param[in,out] S points to an instance of the floating-point spline structure.
  128. * @param[in] type type of cubic spline interpolation (boundary conditions)
  129. * @param[in] x points to the x values of the known data points.
  130. * @param[in] y points to the y values of the known data points.
  131. * @param[in] n number of known data points.
  132. * @param[in] coeffs coefficients array for b, c, and d
  133. * @param[in] tempBuffer buffer array for internal computations
  134. */
  135. void arm_spline_init_f32(
  136. arm_spline_instance_f32 * S,
  137. arm_spline_type type,
  138. const float32_t * x,
  139. const float32_t * y,
  140. uint32_t n,
  141. float32_t * coeffs,
  142. float32_t * tempBuffer);
  143. /**
  144. * @} end of SplineInterpolate group
  145. */
  146. /**
  147. * @addtogroup LinearInterpolate
  148. * @{
  149. */
  150. /**
  151. * @brief Process function for the floating-point Linear Interpolation Function.
  152. * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
  153. * @param[in] x input sample to process
  154. * @return y processed output sample.
  155. *
  156. */
  157. float32_t arm_linear_interp_f32(
  158. arm_linear_interp_instance_f32 * S,
  159. float32_t x);
  160. /**
  161. *
  162. * @brief Process function for the Q31 Linear Interpolation Function.
  163. * @param[in] pYData pointer to Q31 Linear Interpolation table
  164. * @param[in] x input sample to process
  165. * @param[in] nValues number of table values
  166. * @return y processed output sample.
  167. *
  168. * \par
  169. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  170. * This function can support maximum of table size 2^12.
  171. *
  172. */
  173. q31_t arm_linear_interp_q31(
  174. const q31_t * pYData,
  175. q31_t x,
  176. uint32_t nValues);
  177. /**
  178. *
  179. * @brief Process function for the Q15 Linear Interpolation Function.
  180. * @param[in] pYData pointer to Q15 Linear Interpolation table
  181. * @param[in] x input sample to process
  182. * @param[in] nValues number of table values
  183. * @return y processed output sample.
  184. *
  185. * \par
  186. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  187. * This function can support maximum of table size 2^12.
  188. *
  189. */
  190. q15_t arm_linear_interp_q15(
  191. const q15_t * pYData,
  192. q31_t x,
  193. uint32_t nValues);
  194. /**
  195. *
  196. * @brief Process function for the Q7 Linear Interpolation Function.
  197. * @param[in] pYData pointer to Q7 Linear Interpolation table
  198. * @param[in] x input sample to process
  199. * @param[in] nValues number of table values
  200. * @return y processed output sample.
  201. *
  202. * \par
  203. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  204. * This function can support maximum of table size 2^12.
  205. */
  206. q7_t arm_linear_interp_q7(
  207. const q7_t * pYData,
  208. q31_t x,
  209. uint32_t nValues);
  210. /**
  211. * @} end of LinearInterpolate group
  212. */
  213. /**
  214. * @ingroup groupInterpolation
  215. */
  216. /**
  217. * @addtogroup BilinearInterpolate
  218. * @{
  219. */
  220. /**
  221. * @brief Floating-point bilinear interpolation.
  222. * @param[in,out] S points to an instance of the interpolation structure.
  223. * @param[in] X interpolation coordinate.
  224. * @param[in] Y interpolation coordinate.
  225. * @return out interpolated value.
  226. */
  227. float32_t arm_bilinear_interp_f32(
  228. const arm_bilinear_interp_instance_f32 * S,
  229. float32_t X,
  230. float32_t Y);
  231. /**
  232. * @brief Q31 bilinear interpolation.
  233. * @param[in,out] S points to an instance of the interpolation structure.
  234. * @param[in] X interpolation coordinate in 12.20 format.
  235. * @param[in] Y interpolation coordinate in 12.20 format.
  236. * @return out interpolated value.
  237. */
  238. q31_t arm_bilinear_interp_q31(
  239. arm_bilinear_interp_instance_q31 * S,
  240. q31_t X,
  241. q31_t Y);
  242. /**
  243. * @brief Q15 bilinear interpolation.
  244. * @param[in,out] S points to an instance of the interpolation structure.
  245. * @param[in] X interpolation coordinate in 12.20 format.
  246. * @param[in] Y interpolation coordinate in 12.20 format.
  247. * @return out interpolated value.
  248. */
  249. q15_t arm_bilinear_interp_q15(
  250. arm_bilinear_interp_instance_q15 * S,
  251. q31_t X,
  252. q31_t Y);
  253. /**
  254. * @brief Q7 bilinear interpolation.
  255. * @param[in,out] S points to an instance of the interpolation structure.
  256. * @param[in] X interpolation coordinate in 12.20 format.
  257. * @param[in] Y interpolation coordinate in 12.20 format.
  258. * @return out interpolated value.
  259. */
  260. q7_t arm_bilinear_interp_q7(
  261. arm_bilinear_interp_instance_q7 * S,
  262. q31_t X,
  263. q31_t Y);
  264. /**
  265. * @} end of BilinearInterpolate group
  266. */
  267. #ifdef __cplusplus
  268. }
  269. #endif
  270. #endif /* ifndef _INTERPOLATION_FUNCTIONS_H_ */