| 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 | 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 | 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 | 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 | 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 | 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 |
|
|---|
| 126 | /**
|
|---|
| 127 | * @ingroup groupInterpolation
|
|---|
| 128 | */
|
|---|
| 129 |
|
|---|
| 130 | /**
|
|---|
| 131 | * @addtogroup SplineInterpolate
|
|---|
| 132 | * @{
|
|---|
| 133 | */
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | /**
|
|---|
| 137 | * @brief Processing function for the floating-point cubic spline interpolation.
|
|---|
| 138 | * @param[in] S points to an instance of the floating-point spline structure.
|
|---|
| 139 | * @param[in] xq points to the x values ot the interpolated data points.
|
|---|
| 140 | * @param[out] pDst points to the block of output data.
|
|---|
| 141 | * @param[in] blockSize number of samples of output data.
|
|---|
| 142 | */
|
|---|
| 143 | void arm_spline_f32(
|
|---|
| 144 | arm_spline_instance_f32 * S,
|
|---|
| 145 | const float32_t * xq,
|
|---|
| 146 | float32_t * pDst,
|
|---|
| 147 | uint32_t blockSize);
|
|---|
| 148 |
|
|---|
| 149 | /**
|
|---|
| 150 | * @brief Initialization function for the floating-point cubic spline interpolation.
|
|---|
| 151 | * @param[in,out] S points to an instance of the floating-point spline structure.
|
|---|
| 152 | * @param[in] type type of cubic spline interpolation (boundary conditions)
|
|---|
| 153 | * @param[in] x points to the x values of the known data points.
|
|---|
| 154 | * @param[in] y points to the y values of the known data points.
|
|---|
| 155 | * @param[in] n number of known data points.
|
|---|
| 156 | * @param[in] coeffs coefficients array for b, c, and d
|
|---|
| 157 | * @param[in] tempBuffer buffer array for internal computations
|
|---|
| 158 | */
|
|---|
| 159 | void arm_spline_init_f32(
|
|---|
| 160 | arm_spline_instance_f32 * S,
|
|---|
| 161 | arm_spline_type type,
|
|---|
| 162 | const float32_t * x,
|
|---|
| 163 | const float32_t * y,
|
|---|
| 164 | uint32_t n,
|
|---|
| 165 | float32_t * coeffs,
|
|---|
| 166 | float32_t * tempBuffer);
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | /**
|
|---|
| 170 | * @} end of SplineInterpolate group
|
|---|
| 171 | */
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | /**
|
|---|
| 176 | * @addtogroup LinearInterpolate
|
|---|
| 177 | * @{
|
|---|
| 178 | */
|
|---|
| 179 |
|
|---|
| 180 | /**
|
|---|
| 181 | * @brief Process function for the floating-point Linear Interpolation Function.
|
|---|
| 182 | * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
|
|---|
| 183 | * @param[in] x input sample to process
|
|---|
| 184 | * @return y processed output sample.
|
|---|
| 185 | *
|
|---|
| 186 | */
|
|---|
| 187 | float32_t arm_linear_interp_f32(
|
|---|
| 188 | arm_linear_interp_instance_f32 * S,
|
|---|
| 189 | float32_t x);
|
|---|
| 190 |
|
|---|
| 191 | /**
|
|---|
| 192 | *
|
|---|
| 193 | * @brief Process function for the Q31 Linear Interpolation Function.
|
|---|
| 194 | * @param[in] pYData pointer to Q31 Linear Interpolation table
|
|---|
| 195 | * @param[in] x input sample to process
|
|---|
| 196 | * @param[in] nValues number of table values
|
|---|
| 197 | * @return y processed output sample.
|
|---|
| 198 | *
|
|---|
| 199 | * \par
|
|---|
| 200 | * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
|
|---|
| 201 | * This function can support maximum of table size 2^12.
|
|---|
| 202 | *
|
|---|
| 203 | */
|
|---|
| 204 | q31_t arm_linear_interp_q31(
|
|---|
| 205 | const q31_t * pYData,
|
|---|
| 206 | q31_t x,
|
|---|
| 207 | uint32_t nValues);
|
|---|
| 208 |
|
|---|
| 209 | /**
|
|---|
| 210 | *
|
|---|
| 211 | * @brief Process function for the Q15 Linear Interpolation Function.
|
|---|
| 212 | * @param[in] pYData pointer to Q15 Linear Interpolation table
|
|---|
| 213 | * @param[in] x input sample to process
|
|---|
| 214 | * @param[in] nValues number of table values
|
|---|
| 215 | * @return y processed output sample.
|
|---|
| 216 | *
|
|---|
| 217 | * \par
|
|---|
| 218 | * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
|
|---|
| 219 | * This function can support maximum of table size 2^12.
|
|---|
| 220 | *
|
|---|
| 221 | */
|
|---|
| 222 | q15_t arm_linear_interp_q15(
|
|---|
| 223 | const q15_t * pYData,
|
|---|
| 224 | q31_t x,
|
|---|
| 225 | uint32_t nValues);
|
|---|
| 226 |
|
|---|
| 227 | /**
|
|---|
| 228 | *
|
|---|
| 229 | * @brief Process function for the Q7 Linear Interpolation Function.
|
|---|
| 230 | * @param[in] pYData pointer to Q7 Linear Interpolation table
|
|---|
| 231 | * @param[in] x input sample to process
|
|---|
| 232 | * @param[in] nValues number of table values
|
|---|
| 233 | * @return y processed output sample.
|
|---|
| 234 | *
|
|---|
| 235 | * \par
|
|---|
| 236 | * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
|
|---|
| 237 | * This function can support maximum of table size 2^12.
|
|---|
| 238 | */
|
|---|
| 239 | q7_t arm_linear_interp_q7(
|
|---|
| 240 | const q7_t * pYData,
|
|---|
| 241 | q31_t x,
|
|---|
| 242 | uint32_t nValues);
|
|---|
| 243 |
|
|---|
| 244 | /**
|
|---|
| 245 | * @} end of LinearInterpolate group
|
|---|
| 246 | */
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | /**
|
|---|
| 252 | * @ingroup groupInterpolation
|
|---|
| 253 | */
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 | /**
|
|---|
| 257 | * @addtogroup BilinearInterpolate
|
|---|
| 258 | * @{
|
|---|
| 259 | */
|
|---|
| 260 |
|
|---|
| 261 | /**
|
|---|
| 262 | * @brief Floating-point bilinear interpolation.
|
|---|
| 263 | * @param[in,out] S points to an instance of the interpolation structure.
|
|---|
| 264 | * @param[in] X interpolation coordinate.
|
|---|
| 265 | * @param[in] Y interpolation coordinate.
|
|---|
| 266 | * @return out interpolated value.
|
|---|
| 267 | */
|
|---|
| 268 | float32_t arm_bilinear_interp_f32(
|
|---|
| 269 | const arm_bilinear_interp_instance_f32 * S,
|
|---|
| 270 | float32_t X,
|
|---|
| 271 | float32_t Y);
|
|---|
| 272 |
|
|---|
| 273 | /**
|
|---|
| 274 | * @brief Q31 bilinear interpolation.
|
|---|
| 275 | * @param[in,out] S points to an instance of the interpolation structure.
|
|---|
| 276 | * @param[in] X interpolation coordinate in 12.20 format.
|
|---|
| 277 | * @param[in] Y interpolation coordinate in 12.20 format.
|
|---|
| 278 | * @return out interpolated value.
|
|---|
| 279 | */
|
|---|
| 280 | q31_t arm_bilinear_interp_q31(
|
|---|
| 281 | arm_bilinear_interp_instance_q31 * S,
|
|---|
| 282 | q31_t X,
|
|---|
| 283 | q31_t Y);
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 | /**
|
|---|
| 287 | * @brief Q15 bilinear interpolation.
|
|---|
| 288 | * @param[in,out] S points to an instance of the interpolation structure.
|
|---|
| 289 | * @param[in] X interpolation coordinate in 12.20 format.
|
|---|
| 290 | * @param[in] Y interpolation coordinate in 12.20 format.
|
|---|
| 291 | * @return out interpolated value.
|
|---|
| 292 | */
|
|---|
| 293 | q15_t arm_bilinear_interp_q15(
|
|---|
| 294 | arm_bilinear_interp_instance_q15 * S,
|
|---|
| 295 | q31_t X,
|
|---|
| 296 | q31_t Y);
|
|---|
| 297 |
|
|---|
| 298 | /**
|
|---|
| 299 | * @brief Q7 bilinear interpolation.
|
|---|
| 300 | * @param[in,out] S points to an instance of the interpolation structure.
|
|---|
| 301 | * @param[in] X interpolation coordinate in 12.20 format.
|
|---|
| 302 | * @param[in] Y interpolation coordinate in 12.20 format.
|
|---|
| 303 | * @return out interpolated value.
|
|---|
| 304 | */
|
|---|
| 305 | q7_t arm_bilinear_interp_q7(
|
|---|
| 306 | arm_bilinear_interp_instance_q7 * S,
|
|---|
| 307 | q31_t X,
|
|---|
| 308 | q31_t Y);
|
|---|
| 309 | /**
|
|---|
| 310 | * @} end of BilinearInterpolate group
|
|---|
| 311 | */
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 | #ifdef __cplusplus
|
|---|
| 316 | }
|
|---|
| 317 | #endif
|
|---|
| 318 |
|
|---|
| 319 | #endif /* ifndef _INTERPOLATION_FUNCTIONS_H_ */
|
|---|