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 26 27 #ifndef _INTERPOLATION_FUNCTIONS_H_ 28 #define _INTERPOLATION_FUNCTIONS_H_ 29 30 #include "arm_math_types.h" 31 #include "arm_math_memory.h" 32 33 #include "dsp/none.h" 34 #include "dsp/utils.h" 35 36 #ifdef __cplusplus 37 extern "C" 38 { 39 #endif 40 41 42 /** 43 * @defgroup groupInterpolation Interpolation Functions 44 * These functions perform 1- and 2-dimensional interpolation of data. 45 * Linear interpolation is used for 1-dimensional data and 46 * bilinear interpolation is used for 2-dimensional data. 47 */ 48 49 50 /** 51 * @brief Instance structure for the floating-point Linear Interpolate function. 52 */ 53 typedef struct 54 { 55 uint32_t nValues; /**< nValues */ 56 float32_t x1; /**< x1 */ 57 float32_t xSpacing; /**< xSpacing */ 58 const float32_t *pYData; /**< pointer to the table of Y values */ 59 } arm_linear_interp_instance_f32; 60 61 /** 62 * @brief Instance structure for the floating-point bilinear interpolation function. 63 */ 64 typedef struct 65 { 66 uint16_t numRows; /**< number of rows in the data table. */ 67 uint16_t numCols; /**< number of columns in the data table. */ 68 const float32_t *pData; /**< points to the data table. */ 69 } arm_bilinear_interp_instance_f32; 70 71 /** 72 * @brief Instance structure for the Q31 bilinear interpolation function. 73 */ 74 typedef struct 75 { 76 uint16_t numRows; /**< number of rows in the data table. */ 77 uint16_t numCols; /**< number of columns in the data table. */ 78 const q31_t *pData; /**< points to the data table. */ 79 } arm_bilinear_interp_instance_q31; 80 81 /** 82 * @brief Instance structure for the Q15 bilinear interpolation function. 83 */ 84 typedef struct 85 { 86 uint16_t numRows; /**< number of rows in the data table. */ 87 uint16_t numCols; /**< number of columns in the data table. */ 88 const q15_t *pData; /**< points to the data table. */ 89 } arm_bilinear_interp_instance_q15; 90 91 /** 92 * @brief Instance structure for the Q15 bilinear interpolation function. 93 */ 94 typedef struct 95 { 96 uint16_t numRows; /**< number of rows in the data table. */ 97 uint16_t numCols; /**< number of columns in the data table. */ 98 const q7_t *pData; /**< points to the data table. */ 99 } arm_bilinear_interp_instance_q7; 100 101 102 /** 103 * @brief Struct for specifying cubic spline type 104 */ 105 typedef enum 106 { 107 ARM_SPLINE_NATURAL = 0, /**< Natural spline */ 108 ARM_SPLINE_PARABOLIC_RUNOUT = 1 /**< Parabolic runout spline */ 109 } arm_spline_type; 110 111 /** 112 * @brief Instance structure for the floating-point cubic spline interpolation. 113 */ 114 typedef struct 115 { 116 arm_spline_type type; /**< Type (boundary conditions) */ 117 const float32_t * x; /**< x values */ 118 const float32_t * y; /**< y values */ 119 uint32_t n_x; /**< Number of known data points */ 120 float32_t * coeffs; /**< Coefficients buffer (b,c, and d) */ 121 } arm_spline_instance_f32; 122 123 124 /** 125 * @brief Processing function for the floating-point cubic spline interpolation. 126 * @param[in] S points to an instance of the floating-point spline structure. 127 * @param[in] xq points to the x values ot the interpolated data points. 128 * @param[out] pDst points to the block of output data. 129 * @param[in] blockSize number of samples of output data. 130 */ 131 void arm_spline_f32( 132 arm_spline_instance_f32 * S, 133 const float32_t * xq, 134 float32_t * pDst, 135 uint32_t blockSize); 136 137 /** 138 * @brief Initialization function for the floating-point cubic spline interpolation. 139 * @param[in,out] S points to an instance of the floating-point spline structure. 140 * @param[in] type type of cubic spline interpolation (boundary conditions) 141 * @param[in] x points to the x values of the known data points. 142 * @param[in] y points to the y values of the known data points. 143 * @param[in] n number of known data points. 144 * @param[in] coeffs coefficients array for b, c, and d 145 * @param[in] tempBuffer buffer array for internal computations 146 */ 147 void arm_spline_init_f32( 148 arm_spline_instance_f32 * S, 149 arm_spline_type type, 150 const float32_t * x, 151 const float32_t * y, 152 uint32_t n, 153 float32_t * coeffs, 154 float32_t * tempBuffer); 155 156 157 /** 158 * @brief Process function for the floating-point Linear Interpolation Function. 159 * @param[in,out] S is an instance of the floating-point Linear Interpolation structure 160 * @param[in] x input sample to process 161 * @return y processed output sample. 162 * 163 */ 164 float32_t arm_linear_interp_f32( 165 arm_linear_interp_instance_f32 * S, 166 float32_t x); 167 168 /** 169 * 170 * @brief Process function for the Q31 Linear Interpolation Function. 171 * @param[in] pYData pointer to Q31 Linear Interpolation table 172 * @param[in] x input sample to process 173 * @param[in] nValues number of table values 174 * @return y processed output sample. 175 * 176 * \par 177 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 178 * This function can support maximum of table size 2^12. 179 * 180 */ 181 q31_t arm_linear_interp_q31( 182 const q31_t * pYData, 183 q31_t x, 184 uint32_t nValues); 185 186 /** 187 * 188 * @brief Process function for the Q15 Linear Interpolation Function. 189 * @param[in] pYData pointer to Q15 Linear Interpolation table 190 * @param[in] x input sample to process 191 * @param[in] nValues number of table values 192 * @return y processed output sample. 193 * 194 * \par 195 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 196 * This function can support maximum of table size 2^12. 197 * 198 */ 199 q15_t arm_linear_interp_q15( 200 const q15_t * pYData, 201 q31_t x, 202 uint32_t nValues); 203 204 /** 205 * 206 * @brief Process function for the Q7 Linear Interpolation Function. 207 * @param[in] pYData pointer to Q7 Linear Interpolation table 208 * @param[in] x input sample to process 209 * @param[in] nValues number of table values 210 * @return y processed output sample. 211 * 212 * \par 213 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 214 * This function can support maximum of table size 2^12. 215 */ 216 q7_t arm_linear_interp_q7( 217 const q7_t * pYData, 218 q31_t x, 219 uint32_t nValues); 220 221 /** 222 * @brief Floating-point bilinear interpolation. 223 * @param[in,out] S points to an instance of the interpolation structure. 224 * @param[in] X interpolation coordinate. 225 * @param[in] Y interpolation coordinate. 226 * @return out interpolated value. 227 */ 228 float32_t arm_bilinear_interp_f32( 229 const arm_bilinear_interp_instance_f32 * S, 230 float32_t X, 231 float32_t Y); 232 233 /** 234 * @brief Q31 bilinear interpolation. 235 * @param[in,out] S points to an instance of the interpolation structure. 236 * @param[in] X interpolation coordinate in 12.20 format. 237 * @param[in] Y interpolation coordinate in 12.20 format. 238 * @return out interpolated value. 239 */ 240 q31_t arm_bilinear_interp_q31( 241 arm_bilinear_interp_instance_q31 * S, 242 q31_t X, 243 q31_t Y); 244 245 246 /** 247 * @brief Q15 bilinear interpolation. 248 * @param[in,out] S points to an instance of the interpolation structure. 249 * @param[in] X interpolation coordinate in 12.20 format. 250 * @param[in] Y interpolation coordinate in 12.20 format. 251 * @return out interpolated value. 252 */ 253 q15_t arm_bilinear_interp_q15( 254 arm_bilinear_interp_instance_q15 * S, 255 q31_t X, 256 q31_t Y); 257 258 /** 259 * @brief Q7 bilinear interpolation. 260 * @param[in,out] S points to an instance of the interpolation structure. 261 * @param[in] X interpolation coordinate in 12.20 format. 262 * @param[in] Y interpolation coordinate in 12.20 format. 263 * @return out interpolated value. 264 */ 265 q7_t arm_bilinear_interp_q7( 266 arm_bilinear_interp_instance_q7 * S, 267 q31_t X, 268 q31_t Y); 269 270 271 #ifdef __cplusplus 272 } 273 #endif 274 275 #endif /* ifndef _INTERPOLATION_FUNCTIONS_H_ */ 276