interpolation_functions.h 9.3 KB

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