]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Nuvoton_Code/CMSIS/Include/arm_math.h
Add M7/M4 AMP demo.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC / Nuvoton_Code / CMSIS / Include / arm_math.h
1 /* ----------------------------------------------------------------------\r
2  * Project:      CMSIS DSP Library\r
3  * Title:        arm_math.h\r
4  * Description:  Public header file for CMSIS DSP Library\r
5  *\r
6  * $Date:        27. January 2017\r
7  * $Revision:    V.1.5.1\r
8  *\r
9  * Target Processor: Cortex-M cores\r
10  * -------------------------------------------------------------------- */\r
11 /*\r
12  * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.\r
13  *\r
14  * SPDX-License-Identifier: Apache-2.0\r
15  *\r
16  * Licensed under the Apache License, Version 2.0 (the License); you may\r
17  * not use this file except in compliance with the License.\r
18  * You may obtain a copy of the License at\r
19  *\r
20  * www.apache.org/licenses/LICENSE-2.0\r
21  *\r
22  * Unless required by applicable law or agreed to in writing, software\r
23  * distributed under the License is distributed on an AS IS BASIS, WITHOUT\r
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
25  * See the License for the specific language governing permissions and\r
26  * limitations under the License.\r
27  */\r
28 \r
29 /**\r
30    \mainpage CMSIS DSP Software Library\r
31    *\r
32    * Introduction\r
33    * ------------\r
34    *\r
35    * This user manual describes the CMSIS DSP software library,\r
36    * a suite of common signal processing functions for use on Cortex-M processor based devices.\r
37    *\r
38    * The library is divided into a number of functions each covering a specific category:\r
39    * - Basic math functions\r
40    * - Fast math functions\r
41    * - Complex math functions\r
42    * - Filters\r
43    * - Matrix functions\r
44    * - Transforms\r
45    * - Motor control functions\r
46    * - Statistical functions\r
47    * - Support functions\r
48    * - Interpolation functions\r
49    *\r
50    * The library has separate functions for operating on 8-bit integers, 16-bit integers,\r
51    * 32-bit integer and 32-bit floating-point values.\r
52    *\r
53    * Using the Library\r
54    * ------------\r
55    *\r
56    * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.\r
57    * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit)\r
58    * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit)\r
59    * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit)\r
60    * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on)\r
61    * - arm_cortexM7l_math.lib (Cortex-M7, Little endian)\r
62    * - arm_cortexM7b_math.lib (Cortex-M7, Big endian)\r
63    * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit)\r
64    * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit)\r
65    * - arm_cortexM4l_math.lib (Cortex-M4, Little endian)\r
66    * - arm_cortexM4b_math.lib (Cortex-M4, Big endian)\r
67    * - arm_cortexM3l_math.lib (Cortex-M3, Little endian)\r
68    * - arm_cortexM3b_math.lib (Cortex-M3, Big endian)\r
69    * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian)\r
70    * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian)\r
71    * - arm_ARMv8MBLl_math.lib (ARMv8M Baseline, Little endian)\r
72    * - arm_ARMv8MMLl_math.lib (ARMv8M Mainline, Little endian)\r
73    * - arm_ARMv8MMLlfsp_math.lib (ARMv8M Mainline, Little endian, Single Precision Floating Point Unit)\r
74    * - arm_ARMv8MMLld_math.lib (ARMv8M Mainline, Little endian, DSP instructions)\r
75    * - arm_ARMv8MMLldfsp_math.lib (ARMv8M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit)\r
76    *\r
77    * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.\r
78    * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single\r
79    * public header file <code> arm_math.h</code> for Cortex-M cores with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.\r
80    * Define the appropriate pre processor MACRO ARM_MATH_CM7 or ARM_MATH_CM4 or  ARM_MATH_CM3 or\r
81    * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.\r
82    * For ARMv8M cores define pre processor MACRO ARM_MATH_ARMV8MBL or ARM_MATH_ARMV8MML.\r
83    * Set Pre processor MACRO __DSP_PRESENT if ARMv8M Mainline core supports DSP instructions.\r
84    * \r
85    *\r
86    * Examples\r
87    * --------\r
88    *\r
89    * The library ships with a number of examples which demonstrate how to use the library functions.\r
90    *\r
91    * Toolchain Support\r
92    * ------------\r
93    *\r
94    * The library has been developed and tested with MDK-ARM version 5.14.0.0\r
95    * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.\r
96    *\r
97    * Building the Library\r
98    * ------------\r
99    *\r
100    * The library installer contains a project file to re build libraries on MDK-ARM Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.\r
101    * - arm_cortexM_math.uvprojx\r
102    *\r
103    *\r
104    * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional pre processor MACROs detailed above.\r
105    *\r
106    * Pre-processor Macros\r
107    * ------------\r
108    *\r
109    * Each library project have differant pre-processor macros.\r
110    *\r
111    * - UNALIGNED_SUPPORT_DISABLE:\r
112    *\r
113    * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access\r
114    *\r
115    * - ARM_MATH_BIG_ENDIAN:\r
116    *\r
117    * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.\r
118    *\r
119    * - ARM_MATH_MATRIX_CHECK:\r
120    *\r
121    * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices\r
122    *\r
123    * - ARM_MATH_ROUNDING:\r
124    *\r
125    * Define macro ARM_MATH_ROUNDING for rounding on support functions\r
126    *\r
127    * - ARM_MATH_CMx:\r
128    *\r
129    * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target\r
130    * and ARM_MATH_CM0 for building library on Cortex-M0 target, ARM_MATH_CM0PLUS for building library on Cortex-M0+ target, and\r
131    * ARM_MATH_CM7 for building the library on cortex-M7.\r
132    *\r
133    * - ARM_MATH_ARMV8MxL:\r
134    *\r
135    * Define macro ARM_MATH_ARMV8MBL for building the library on ARMv8M Baseline target, ARM_MATH_ARMV8MBL for building library\r
136    * on ARMv8M Mainline target.\r
137    *\r
138    * - __FPU_PRESENT:\r
139    *\r
140    * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for floating point libraries.\r
141    *\r
142    * - __DSP_PRESENT:\r
143    *\r
144    * Initialize macro __DSP_PRESENT = 1 when ARMv8M Mainline core supports DSP instructions.\r
145    *\r
146    * <hr>\r
147    * CMSIS-DSP in ARM::CMSIS Pack\r
148    * -----------------------------\r
149    *\r
150    * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:\r
151    * |File/Folder                   |Content                                                                 |\r
152    * |------------------------------|------------------------------------------------------------------------|\r
153    * |\b CMSIS\\Documentation\\DSP  | This documentation                                                     |\r
154    * |\b CMSIS\\DSP_Lib             | Software license agreement (license.txt)                               |\r
155    * |\b CMSIS\\DSP_Lib\\Examples   | Example projects demonstrating the usage of the library functions      |\r
156    * |\b CMSIS\\DSP_Lib\\Source     | Source files for rebuilding the library                                |\r
157    *\r
158    * <hr>\r
159    * Revision History of CMSIS-DSP\r
160    * ------------\r
161    * Please refer to \ref ChangeLog_pg.\r
162    *\r
163    * Copyright Notice\r
164    * ------------\r
165    *\r
166    * Copyright (C) 2010-2015 ARM Limited. All rights reserved.\r
167    */\r
168 \r
169 \r
170 /**\r
171  * @defgroup groupMath Basic Math Functions\r
172  */\r
173 \r
174 /**\r
175  * @defgroup groupFastMath Fast Math Functions\r
176  * This set of functions provides a fast approximation to sine, cosine, and square root.\r
177  * As compared to most of the other functions in the CMSIS math library, the fast math functions\r
178  * operate on individual values and not arrays.\r
179  * There are separate functions for Q15, Q31, and floating-point data.\r
180  *\r
181  */\r
182 \r
183 /**\r
184  * @defgroup groupCmplxMath Complex Math Functions\r
185  * This set of functions operates on complex data vectors.\r
186  * The data in the complex arrays is stored in an interleaved fashion\r
187  * (real, imag, real, imag, ...).\r
188  * In the API functions, the number of samples in a complex array refers\r
189  * to the number of complex values; the array contains twice this number of\r
190  * real values.\r
191  */\r
192 \r
193 /**\r
194  * @defgroup groupFilters Filtering Functions\r
195  */\r
196 \r
197 /**\r
198  * @defgroup groupMatrix Matrix Functions\r
199  *\r
200  * This set of functions provides basic matrix math operations.\r
201  * The functions operate on matrix data structures.  For example,\r
202  * the type\r
203  * definition for the floating-point matrix structure is shown\r
204  * below:\r
205  * <pre>\r
206  *     typedef struct\r
207  *     {\r
208  *       uint16_t numRows;     // number of rows of the matrix.\r
209  *       uint16_t numCols;     // number of columns of the matrix.\r
210  *       float32_t *pData;     // points to the data of the matrix.\r
211  *     } arm_matrix_instance_f32;\r
212  * </pre>\r
213  * There are similar definitions for Q15 and Q31 data types.\r
214  *\r
215  * The structure specifies the size of the matrix and then points to\r
216  * an array of data.  The array is of size <code>numRows X numCols</code>\r
217  * and the values are arranged in row order.  That is, the\r
218  * matrix element (i, j) is stored at:\r
219  * <pre>\r
220  *     pData[i*numCols + j]\r
221  * </pre>\r
222  *\r
223  * \par Init Functions\r
224  * There is an associated initialization function for each type of matrix\r
225  * data structure.\r
226  * The initialization function sets the values of the internal structure fields.\r
227  * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>\r
228  * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types,  respectively.\r
229  *\r
230  * \par\r
231  * Use of the initialization function is optional. However, if initialization function is used\r
232  * then the instance structure cannot be placed into a const data section.\r
233  * To place the instance structure in a const data\r
234  * section, manually initialize the data structure.  For example:\r
235  * <pre>\r
236  * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>\r
237  * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>\r
238  * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>\r
239  * </pre>\r
240  * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>\r
241  * specifies the number of columns, and <code>pData</code> points to the\r
242  * data array.\r
243  *\r
244  * \par Size Checking\r
245  * By default all of the matrix functions perform size checking on the input and\r
246  * output matrices.  For example, the matrix addition function verifies that the\r
247  * two input matrices and the output matrix all have the same number of rows and\r
248  * columns.  If the size check fails the functions return:\r
249  * <pre>\r
250  *     ARM_MATH_SIZE_MISMATCH\r
251  * </pre>\r
252  * Otherwise the functions return\r
253  * <pre>\r
254  *     ARM_MATH_SUCCESS\r
255  * </pre>\r
256  * There is some overhead associated with this matrix size checking.\r
257  * The matrix size checking is enabled via the \#define\r
258  * <pre>\r
259  *     ARM_MATH_MATRIX_CHECK\r
260  * </pre>\r
261  * within the library project settings.  By default this macro is defined\r
262  * and size checking is enabled.  By changing the project settings and\r
263  * undefining this macro size checking is eliminated and the functions\r
264  * run a bit faster.  With size checking disabled the functions always\r
265  * return <code>ARM_MATH_SUCCESS</code>.\r
266  */\r
267 \r
268 /**\r
269  * @defgroup groupTransforms Transform Functions\r
270  */\r
271 \r
272 /**\r
273  * @defgroup groupController Controller Functions\r
274  */\r
275 \r
276 /**\r
277  * @defgroup groupStats Statistics Functions\r
278  */\r
279 /**\r
280  * @defgroup groupSupport Support Functions\r
281  */\r
282 \r
283 /**\r
284  * @defgroup groupInterpolation Interpolation Functions\r
285  * These functions perform 1- and 2-dimensional interpolation of data.\r
286  * Linear interpolation is used for 1-dimensional data and\r
287  * bilinear interpolation is used for 2-dimensional data.\r
288  */\r
289 \r
290 /**\r
291  * @defgroup groupExamples Examples\r
292  */\r
293 #ifndef _ARM_MATH_H\r
294 #define _ARM_MATH_H\r
295 \r
296 /* Compiler specific diagnostic adjustment */\r
297 #if   defined ( __CC_ARM )\r
298 \r
299 #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )\r
300 \r
301 #elif defined ( __GNUC__ )\r
302 #pragma GCC diagnostic push\r
303 #pragma GCC diagnostic ignored "-Wsign-conversion"\r
304 #pragma GCC diagnostic ignored "-Wconversion"\r
305 #pragma GCC diagnostic ignored "-Wunused-parameter"\r
306 \r
307 #elif defined ( __ICCARM__ )\r
308 \r
309 #elif defined ( __TI_ARM__ )\r
310 \r
311 #elif defined ( __CSMC__ )\r
312 \r
313 #elif defined ( __TASKING__ )\r
314 \r
315 #else\r
316   #error Unknown compiler\r
317 #endif\r
318 \r
319 \r
320 #define __CMSIS_GENERIC         /* disable NVIC and Systick functions */\r
321 \r
322 #if defined(ARM_MATH_CM7)\r
323   #include "core_cm7.h"\r
324   #define ARM_MATH_DSP\r
325 #elif defined (ARM_MATH_CM4)\r
326   #include "core_cm4.h"\r
327   #define ARM_MATH_DSP\r
328 #elif defined (ARM_MATH_CM3)\r
329   #include "core_cm3.h"\r
330 #elif defined (ARM_MATH_CM0)\r
331   #include "core_cm0.h"\r
332   #define ARM_MATH_CM0_FAMILY\r
333 #elif defined (ARM_MATH_CM0PLUS)\r
334   #include "core_cm0plus.h"\r
335   #define ARM_MATH_CM0_FAMILY\r
336 #elif defined (ARM_MATH_ARMV8MBL)\r
337   #include "core_armv8mbl.h"\r
338   #define ARM_MATH_CM0_FAMILY\r
339 #elif defined (ARM_MATH_ARMV8MML)\r
340   #include "core_armv8mml.h"\r
341   #if (defined (__DSP_PRESENT) && (__DSP_PRESENT == 1))\r
342     #define ARM_MATH_DSP\r
343   #endif\r
344 #else\r
345   #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS, ARM_MATH_CM0, ARM_MATH_ARMV8MBL, ARM_MATH_ARMV8MML"\r
346 #endif\r
347 \r
348 #undef  __CMSIS_GENERIC         /* enable NVIC and Systick functions */\r
349 #include "string.h"\r
350 #include "math.h"\r
351 #ifdef   __cplusplus\r
352 extern "C"\r
353 {\r
354 #endif\r
355 \r
356 \r
357   /**\r
358    * @brief Macros required for reciprocal calculation in Normalized LMS\r
359    */\r
360 \r
361 #define DELTA_Q31          (0x100)\r
362 #define DELTA_Q15          0x5\r
363 #define INDEX_MASK         0x0000003F\r
364 #ifndef PI\r
365   #define PI               3.14159265358979f\r
366 #endif\r
367 \r
368   /**\r
369    * @brief Macros required for SINE and COSINE Fast math approximations\r
370    */\r
371 \r
372 #define FAST_MATH_TABLE_SIZE  512\r
373 #define FAST_MATH_Q31_SHIFT   (32 - 10)\r
374 #define FAST_MATH_Q15_SHIFT   (16 - 10)\r
375 #define CONTROLLER_Q31_SHIFT  (32 - 9)\r
376 #define TABLE_SPACING_Q31     0x400000\r
377 #define TABLE_SPACING_Q15     0x80\r
378 \r
379   /**\r
380    * @brief Macros required for SINE and COSINE Controller functions\r
381    */\r
382   /* 1.31(q31) Fixed value of 2/360 */\r
383   /* -1 to +1 is divided into 360 values so total spacing is (2/360) */\r
384 #define INPUT_SPACING         0xB60B61\r
385 \r
386   /**\r
387    * @brief Macro for Unaligned Support\r
388    */\r
389 #ifndef UNALIGNED_SUPPORT_DISABLE\r
390     #define ALIGN4\r
391 #else\r
392   #if defined  (__GNUC__)\r
393     #define ALIGN4 __attribute__((aligned(4)))\r
394   #else\r
395     #define ALIGN4 __align(4)\r
396   #endif\r
397 #endif   /* #ifndef UNALIGNED_SUPPORT_DISABLE */\r
398 \r
399   /**\r
400    * @brief Error status returned by some functions in the library.\r
401    */\r
402 \r
403   typedef enum\r
404   {\r
405     ARM_MATH_SUCCESS = 0,                /**< No error */\r
406     ARM_MATH_ARGUMENT_ERROR = -1,        /**< One or more arguments are incorrect */\r
407     ARM_MATH_LENGTH_ERROR = -2,          /**< Length of data buffer is incorrect */\r
408     ARM_MATH_SIZE_MISMATCH = -3,         /**< Size of matrices is not compatible with the operation. */\r
409     ARM_MATH_NANINF = -4,                /**< Not-a-number (NaN) or infinity is generated */\r
410     ARM_MATH_SINGULAR = -5,              /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */\r
411     ARM_MATH_TEST_FAILURE = -6           /**< Test Failed  */\r
412   } arm_status;\r
413 \r
414   /**\r
415    * @brief 8-bit fractional data type in 1.7 format.\r
416    */\r
417   typedef int8_t q7_t;\r
418 \r
419   /**\r
420    * @brief 16-bit fractional data type in 1.15 format.\r
421    */\r
422   typedef int16_t q15_t;\r
423 \r
424   /**\r
425    * @brief 32-bit fractional data type in 1.31 format.\r
426    */\r
427   typedef int32_t q31_t;\r
428 \r
429   /**\r
430    * @brief 64-bit fractional data type in 1.63 format.\r
431    */\r
432   typedef int64_t q63_t;\r
433 \r
434   /**\r
435    * @brief 32-bit floating-point type definition.\r
436    */\r
437   typedef float float32_t;\r
438 \r
439   /**\r
440    * @brief 64-bit floating-point type definition.\r
441    */\r
442   typedef double float64_t;\r
443 \r
444   /**\r
445    * @brief definition to read/write two 16 bit values.\r
446    */\r
447 #if   defined ( __CC_ARM )\r
448   #define __SIMD32_TYPE int32_t __packed\r
449   #define CMSIS_UNUSED __attribute__((unused))\r
450   #define CMSIS_INLINE __attribute__((always_inline))\r
451 \r
452 #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )\r
453   #define __SIMD32_TYPE int32_t\r
454   #define CMSIS_UNUSED __attribute__((unused))\r
455   #define CMSIS_INLINE __attribute__((always_inline))\r
456 \r
457 #elif defined ( __GNUC__ )\r
458   #define __SIMD32_TYPE int32_t\r
459   #define CMSIS_UNUSED __attribute__((unused))\r
460   #define CMSIS_INLINE __attribute__((always_inline))\r
461 \r
462 #elif defined ( __ICCARM__ )\r
463   #define __SIMD32_TYPE int32_t __packed\r
464   #define CMSIS_UNUSED\r
465   #define CMSIS_INLINE\r
466 \r
467 #elif defined ( __TI_ARM__ )\r
468   #define __SIMD32_TYPE int32_t\r
469   #define CMSIS_UNUSED __attribute__((unused))\r
470   #define CMSIS_INLINE\r
471 \r
472 #elif defined ( __CSMC__ )\r
473   #define __SIMD32_TYPE int32_t\r
474   #define CMSIS_UNUSED\r
475   #define CMSIS_INLINE\r
476 \r
477 #elif defined ( __TASKING__ )\r
478   #define __SIMD32_TYPE __unaligned int32_t\r
479   #define CMSIS_UNUSED\r
480   #define CMSIS_INLINE\r
481 \r
482 #else\r
483   #error Unknown compiler\r
484 #endif\r
485 \r
486 #define __SIMD32(addr)        (*(__SIMD32_TYPE **) & (addr))\r
487 #define __SIMD32_CONST(addr)  ((__SIMD32_TYPE *)(addr))\r
488 #define _SIMD32_OFFSET(addr)  (*(__SIMD32_TYPE *)  (addr))\r
489 #define __SIMD64(addr)        (*(int64_t **) & (addr))\r
490 \r
491 /* #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */\r
492 #if !defined (ARM_MATH_DSP)\r
493   /**\r
494    * @brief definition to pack two 16 bit values.\r
495    */\r
496 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) <<    0) & (int32_t)0x0000FFFF) | \\r
497                                     (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000)  )\r
498 #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) <<    0) & (int32_t)0xFFFF0000) | \\r
499                                     (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF)  )\r
500 \r
501 /* #endif // defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */\r
502 #endif /* !defined (ARM_MATH_DSP) */\r
503 \r
504    /**\r
505    * @brief definition to pack four 8 bit values.\r
506    */\r
507 #ifndef ARM_MATH_BIG_ENDIAN\r
508 \r
509 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) <<  0) & (int32_t)0x000000FF) | \\r
510                                 (((int32_t)(v1) <<  8) & (int32_t)0x0000FF00) | \\r
511                                 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \\r
512                                 (((int32_t)(v3) << 24) & (int32_t)0xFF000000)  )\r
513 #else\r
514 \r
515 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) <<  0) & (int32_t)0x000000FF) | \\r
516                                 (((int32_t)(v2) <<  8) & (int32_t)0x0000FF00) | \\r
517                                 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \\r
518                                 (((int32_t)(v0) << 24) & (int32_t)0xFF000000)  )\r
519 \r
520 #endif\r
521 \r
522 \r
523   /**\r
524    * @brief Clips Q63 to Q31 values.\r
525    */\r
526   CMSIS_INLINE __STATIC_INLINE q31_t clip_q63_to_q31(\r
527   q63_t x)\r
528   {\r
529     return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?\r
530       ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;\r
531   }\r
532 \r
533   /**\r
534    * @brief Clips Q63 to Q15 values.\r
535    */\r
536   CMSIS_INLINE __STATIC_INLINE q15_t clip_q63_to_q15(\r
537   q63_t x)\r
538   {\r
539     return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?\r
540       ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);\r
541   }\r
542 \r
543   /**\r
544    * @brief Clips Q31 to Q7 values.\r
545    */\r
546   CMSIS_INLINE __STATIC_INLINE q7_t clip_q31_to_q7(\r
547   q31_t x)\r
548   {\r
549     return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?\r
550       ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;\r
551   }\r
552 \r
553   /**\r
554    * @brief Clips Q31 to Q15 values.\r
555    */\r
556   CMSIS_INLINE __STATIC_INLINE q15_t clip_q31_to_q15(\r
557   q31_t x)\r
558   {\r
559     return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?\r
560       ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;\r
561   }\r
562 \r
563   /**\r
564    * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.\r
565    */\r
566 \r
567   CMSIS_INLINE __STATIC_INLINE q63_t mult32x64(\r
568   q63_t x,\r
569   q31_t y)\r
570   {\r
571     return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +\r
572             (((q63_t) (x >> 32) * y)));\r
573   }\r
574 \r
575 /*\r
576   #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM   )\r
577   #define __CLZ __clz\r
578   #endif\r
579  */\r
580 /* note: function can be removed when all toolchain support __CLZ for Cortex-M0 */\r
581 #if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__))  )\r
582   CMSIS_INLINE __STATIC_INLINE uint32_t __CLZ(\r
583   q31_t data);\r
584 \r
585   CMSIS_INLINE __STATIC_INLINE uint32_t __CLZ(\r
586   q31_t data)\r
587   {\r
588     uint32_t count = 0;\r
589     uint32_t mask = 0x80000000;\r
590 \r
591     while ((data & mask) == 0)\r
592     {\r
593       count += 1u;\r
594       mask = mask >> 1u;\r
595     }\r
596 \r
597     return (count);\r
598   }\r
599 #endif\r
600 \r
601   /**\r
602    * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.\r
603    */\r
604 \r
605   CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q31(\r
606   q31_t in,\r
607   q31_t * dst,\r
608   q31_t * pRecipTable)\r
609   {\r
610     q31_t out;\r
611     uint32_t tempVal;\r
612     uint32_t index, i;\r
613     uint32_t signBits;\r
614 \r
615     if (in > 0)\r
616     {\r
617       signBits = ((uint32_t) (__CLZ( in) - 1));\r
618     }\r
619     else\r
620     {\r
621       signBits = ((uint32_t) (__CLZ(-in) - 1));\r
622     }\r
623 \r
624     /* Convert input sample to 1.31 format */\r
625     in = (in << signBits);\r
626 \r
627     /* calculation of index for initial approximated Val */\r
628     index = (uint32_t)(in >> 24);\r
629     index = (index & INDEX_MASK);\r
630 \r
631     /* 1.31 with exp 1 */\r
632     out = pRecipTable[index];\r
633 \r
634     /* calculation of reciprocal value */\r
635     /* running approximation for two iterations */\r
636     for (i = 0u; i < 2u; i++)\r
637     {\r
638       tempVal = (uint32_t) (((q63_t) in * out) >> 31);\r
639       tempVal = 0x7FFFFFFFu - tempVal;\r
640       /*      1.31 with exp 1 */\r
641       /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */\r
642       out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);\r
643     }\r
644 \r
645     /* write output */\r
646     *dst = out;\r
647 \r
648     /* return num of signbits of out = 1/in value */\r
649     return (signBits + 1u);\r
650   }\r
651 \r
652 \r
653   /**\r
654    * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.\r
655    */\r
656   CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q15(\r
657   q15_t in,\r
658   q15_t * dst,\r
659   q15_t * pRecipTable)\r
660   {\r
661     q15_t out = 0;\r
662     uint32_t tempVal = 0;\r
663     uint32_t index = 0, i = 0;\r
664     uint32_t signBits = 0;\r
665 \r
666     if (in > 0)\r
667     {\r
668       signBits = ((uint32_t)(__CLZ( in) - 17));\r
669     }\r
670     else\r
671     {\r
672       signBits = ((uint32_t)(__CLZ(-in) - 17));\r
673     }\r
674 \r
675     /* Convert input sample to 1.15 format */\r
676     in = (in << signBits);\r
677 \r
678     /* calculation of index for initial approximated Val */\r
679     index = (uint32_t)(in >>  8);\r
680     index = (index & INDEX_MASK);\r
681 \r
682     /*      1.15 with exp 1  */\r
683     out = pRecipTable[index];\r
684 \r
685     /* calculation of reciprocal value */\r
686     /* running approximation for two iterations */\r
687     for (i = 0u; i < 2u; i++)\r
688     {\r
689       tempVal = (uint32_t) (((q31_t) in * out) >> 15);\r
690       tempVal = 0x7FFFu - tempVal;\r
691       /*      1.15 with exp 1 */\r
692       out = (q15_t) (((q31_t) out * tempVal) >> 14);\r
693       /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */\r
694     }\r
695 \r
696     /* write output */\r
697     *dst = out;\r
698 \r
699     /* return num of signbits of out = 1/in value */\r
700     return (signBits + 1);\r
701   }\r
702 \r
703 \r
704   /*\r
705    * @brief C custom defined intrinisic function for only M0 processors\r
706    */\r
707 #if defined(ARM_MATH_CM0_FAMILY)\r
708   CMSIS_INLINE __STATIC_INLINE q31_t __SSAT(\r
709   q31_t x,\r
710   uint32_t y)\r
711   {\r
712     int32_t posMax, negMin;\r
713     uint32_t i;\r
714 \r
715     posMax = 1;\r
716     for (i = 0; i < (y - 1); i++)\r
717     {\r
718       posMax = posMax * 2;\r
719     }\r
720 \r
721     if (x > 0)\r
722     {\r
723       posMax = (posMax - 1);\r
724 \r
725       if (x > posMax)\r
726       {\r
727         x = posMax;\r
728       }\r
729     }\r
730     else\r
731     {\r
732       negMin = -posMax;\r
733 \r
734       if (x < negMin)\r
735       {\r
736         x = negMin;\r
737       }\r
738     }\r
739     return (x);\r
740   }\r
741 #endif /* end of ARM_MATH_CM0_FAMILY */\r
742 \r
743 \r
744   /*\r
745    * @brief C custom defined intrinsic function for M3 and M0 processors\r
746    */\r
747 /* #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */\r
748 #if !defined (ARM_MATH_DSP)\r
749 \r
750   /*\r
751    * @brief C custom defined QADD8 for M3 and M0 processors\r
752    */\r
753   CMSIS_INLINE __STATIC_INLINE uint32_t __QADD8(\r
754   uint32_t x,\r
755   uint32_t y)\r
756   {\r
757     q31_t r, s, t, u;\r
758 \r
759     r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;\r
760     s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;\r
761     t = __SSAT(((((q31_t)x <<  8) >> 24) + (((q31_t)y <<  8) >> 24)), 8) & (int32_t)0x000000FF;\r
762     u = __SSAT(((((q31_t)x      ) >> 24) + (((q31_t)y      ) >> 24)), 8) & (int32_t)0x000000FF;\r
763 \r
764     return ((uint32_t)((u << 24) | (t << 16) | (s <<  8) | (r      )));\r
765   }\r
766 \r
767 \r
768   /*\r
769    * @brief C custom defined QSUB8 for M3 and M0 processors\r
770    */\r
771   CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB8(\r
772   uint32_t x,\r
773   uint32_t y)\r
774   {\r
775     q31_t r, s, t, u;\r
776 \r
777     r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;\r
778     s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;\r
779     t = __SSAT(((((q31_t)x <<  8) >> 24) - (((q31_t)y <<  8) >> 24)), 8) & (int32_t)0x000000FF;\r
780     u = __SSAT(((((q31_t)x      ) >> 24) - (((q31_t)y      ) >> 24)), 8) & (int32_t)0x000000FF;\r
781 \r
782     return ((uint32_t)((u << 24) | (t << 16) | (s <<  8) | (r      )));\r
783   }\r
784 \r
785 \r
786   /*\r
787    * @brief C custom defined QADD16 for M3 and M0 processors\r
788    */\r
789   CMSIS_INLINE __STATIC_INLINE uint32_t __QADD16(\r
790   uint32_t x,\r
791   uint32_t y)\r
792   {\r
793 /*  q31_t r,     s;  without initialisation 'arm_offset_q15 test' fails  but 'intrinsic' tests pass! for armCC */\r
794     q31_t r = 0, s = 0;\r
795 \r
796     r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;\r
797     s = __SSAT(((((q31_t)x      ) >> 16) + (((q31_t)y      ) >> 16)), 16) & (int32_t)0x0000FFFF;\r
798 \r
799     return ((uint32_t)((s << 16) | (r      )));\r
800   }\r
801 \r
802 \r
803   /*\r
804    * @brief C custom defined SHADD16 for M3 and M0 processors\r
805    */\r
806   CMSIS_INLINE __STATIC_INLINE uint32_t __SHADD16(\r
807   uint32_t x,\r
808   uint32_t y)\r
809   {\r
810     q31_t r, s;\r
811 \r
812     r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
813     s = (((((q31_t)x      ) >> 16) + (((q31_t)y      ) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
814 \r
815     return ((uint32_t)((s << 16) | (r      )));\r
816   }\r
817 \r
818 \r
819   /*\r
820    * @brief C custom defined QSUB16 for M3 and M0 processors\r
821    */\r
822   CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB16(\r
823   uint32_t x,\r
824   uint32_t y)\r
825   {\r
826     q31_t r, s;\r
827 \r
828     r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;\r
829     s = __SSAT(((((q31_t)x      ) >> 16) - (((q31_t)y      ) >> 16)), 16) & (int32_t)0x0000FFFF;\r
830 \r
831     return ((uint32_t)((s << 16) | (r      )));\r
832   }\r
833 \r
834 \r
835   /*\r
836    * @brief C custom defined SHSUB16 for M3 and M0 processors\r
837    */\r
838   CMSIS_INLINE __STATIC_INLINE uint32_t __SHSUB16(\r
839   uint32_t x,\r
840   uint32_t y)\r
841   {\r
842     q31_t r, s;\r
843 \r
844     r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
845     s = (((((q31_t)x      ) >> 16) - (((q31_t)y      ) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
846 \r
847     return ((uint32_t)((s << 16) | (r      )));\r
848   }\r
849 \r
850 \r
851   /*\r
852    * @brief C custom defined QASX for M3 and M0 processors\r
853    */\r
854   CMSIS_INLINE __STATIC_INLINE uint32_t __QASX(\r
855   uint32_t x,\r
856   uint32_t y)\r
857   {\r
858     q31_t r, s;\r
859 \r
860     r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y      ) >> 16)), 16) & (int32_t)0x0000FFFF;\r
861     s = __SSAT(((((q31_t)x      ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;\r
862 \r
863     return ((uint32_t)((s << 16) | (r      )));\r
864   }\r
865 \r
866 \r
867   /*\r
868    * @brief C custom defined SHASX for M3 and M0 processors\r
869    */\r
870   CMSIS_INLINE __STATIC_INLINE uint32_t __SHASX(\r
871   uint32_t x,\r
872   uint32_t y)\r
873   {\r
874     q31_t r, s;\r
875 \r
876     r = (((((q31_t)x << 16) >> 16) - (((q31_t)y      ) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
877     s = (((((q31_t)x      ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
878 \r
879     return ((uint32_t)((s << 16) | (r      )));\r
880   }\r
881 \r
882 \r
883   /*\r
884    * @brief C custom defined QSAX for M3 and M0 processors\r
885    */\r
886   CMSIS_INLINE __STATIC_INLINE uint32_t __QSAX(\r
887   uint32_t x,\r
888   uint32_t y)\r
889   {\r
890     q31_t r, s;\r
891 \r
892     r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y      ) >> 16)), 16) & (int32_t)0x0000FFFF;\r
893     s = __SSAT(((((q31_t)x      ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;\r
894 \r
895     return ((uint32_t)((s << 16) | (r      )));\r
896   }\r
897 \r
898 \r
899   /*\r
900    * @brief C custom defined SHSAX for M3 and M0 processors\r
901    */\r
902   CMSIS_INLINE __STATIC_INLINE uint32_t __SHSAX(\r
903   uint32_t x,\r
904   uint32_t y)\r
905   {\r
906     q31_t r, s;\r
907 \r
908     r = (((((q31_t)x << 16) >> 16) + (((q31_t)y      ) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
909     s = (((((q31_t)x      ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;\r
910 \r
911     return ((uint32_t)((s << 16) | (r      )));\r
912   }\r
913 \r
914 \r
915   /*\r
916    * @brief C custom defined SMUSDX for M3 and M0 processors\r
917    */\r
918   CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSDX(\r
919   uint32_t x,\r
920   uint32_t y)\r
921   {\r
922     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y      ) >> 16)) -\r
923                        ((((q31_t)x      ) >> 16) * (((q31_t)y << 16) >> 16))   ));\r
924   }\r
925 \r
926   /*\r
927    * @brief C custom defined SMUADX for M3 and M0 processors\r
928    */\r
929   CMSIS_INLINE __STATIC_INLINE uint32_t __SMUADX(\r
930   uint32_t x,\r
931   uint32_t y)\r
932   {\r
933     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y      ) >> 16)) +\r
934                        ((((q31_t)x      ) >> 16) * (((q31_t)y << 16) >> 16))   ));\r
935   }\r
936 \r
937 \r
938   /*\r
939    * @brief C custom defined QADD for M3 and M0 processors\r
940    */\r
941   CMSIS_INLINE __STATIC_INLINE int32_t __QADD(\r
942   int32_t x,\r
943   int32_t y)\r
944   {\r
945     return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));\r
946   }\r
947 \r
948 \r
949   /*\r
950    * @brief C custom defined QSUB for M3 and M0 processors\r
951    */\r
952   CMSIS_INLINE __STATIC_INLINE int32_t __QSUB(\r
953   int32_t x,\r
954   int32_t y)\r
955   {\r
956     return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));\r
957   }\r
958 \r
959 \r
960   /*\r
961    * @brief C custom defined SMLAD for M3 and M0 processors\r
962    */\r
963   CMSIS_INLINE __STATIC_INLINE uint32_t __SMLAD(\r
964   uint32_t x,\r
965   uint32_t y,\r
966   uint32_t sum)\r
967   {\r
968     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +\r
969                        ((((q31_t)x      ) >> 16) * (((q31_t)y      ) >> 16)) +\r
970                        ( ((q31_t)sum    )                                  )   ));\r
971   }\r
972 \r
973 \r
974   /*\r
975    * @brief C custom defined SMLADX for M3 and M0 processors\r
976    */\r
977   CMSIS_INLINE __STATIC_INLINE uint32_t __SMLADX(\r
978   uint32_t x,\r
979   uint32_t y,\r
980   uint32_t sum)\r
981   {\r
982     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y      ) >> 16)) +\r
983                        ((((q31_t)x      ) >> 16) * (((q31_t)y << 16) >> 16)) +\r
984                        ( ((q31_t)sum    )                                  )   ));\r
985   }\r
986 \r
987 \r
988   /*\r
989    * @brief C custom defined SMLSDX for M3 and M0 processors\r
990    */\r
991   CMSIS_INLINE __STATIC_INLINE uint32_t __SMLSDX(\r
992   uint32_t x,\r
993   uint32_t y,\r
994   uint32_t sum)\r
995   {\r
996     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y      ) >> 16)) -\r
997                        ((((q31_t)x      ) >> 16) * (((q31_t)y << 16) >> 16)) +\r
998                        ( ((q31_t)sum    )                                  )   ));\r
999   }\r
1000 \r
1001 \r
1002   /*\r
1003    * @brief C custom defined SMLALD for M3 and M0 processors\r
1004    */\r
1005   CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALD(\r
1006   uint32_t x,\r
1007   uint32_t y,\r
1008   uint64_t sum)\r
1009   {\r
1010 /*  return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */\r
1011     return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +\r
1012                        ((((q31_t)x      ) >> 16) * (((q31_t)y      ) >> 16)) +\r
1013                        ( ((q63_t)sum    )                                  )   ));\r
1014   }\r
1015 \r
1016 \r
1017   /*\r
1018    * @brief C custom defined SMLALDX for M3 and M0 processors\r
1019    */\r
1020   CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALDX(\r
1021   uint32_t x,\r
1022   uint32_t y,\r
1023   uint64_t sum)\r
1024   {\r
1025 /*  return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */\r
1026     return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y      ) >> 16)) +\r
1027                        ((((q31_t)x      ) >> 16) * (((q31_t)y << 16) >> 16)) +\r
1028                        ( ((q63_t)sum    )                                  )   ));\r
1029   }\r
1030 \r
1031 \r
1032   /*\r
1033    * @brief C custom defined SMUAD for M3 and M0 processors\r
1034    */\r
1035   CMSIS_INLINE __STATIC_INLINE uint32_t __SMUAD(\r
1036   uint32_t x,\r
1037   uint32_t y)\r
1038   {\r
1039     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +\r
1040                        ((((q31_t)x      ) >> 16) * (((q31_t)y      ) >> 16))   ));\r
1041   }\r
1042 \r
1043 \r
1044   /*\r
1045    * @brief C custom defined SMUSD for M3 and M0 processors\r
1046    */\r
1047   CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSD(\r
1048   uint32_t x,\r
1049   uint32_t y)\r
1050   {\r
1051     return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -\r
1052                        ((((q31_t)x      ) >> 16) * (((q31_t)y      ) >> 16))   ));\r
1053   }\r
1054 \r
1055 \r
1056   /*\r
1057    * @brief C custom defined SXTB16 for M3 and M0 processors\r
1058    */\r
1059   CMSIS_INLINE __STATIC_INLINE uint32_t __SXTB16(\r
1060   uint32_t x)\r
1061   {\r
1062     return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |\r
1063                        ((((q31_t)x <<  8) >>  8) & (q31_t)0xFFFF0000)  ));\r
1064   }\r
1065 \r
1066   /*\r
1067    * @brief C custom defined SMMLA for M3 and M0 processors\r
1068    */\r
1069   CMSIS_INLINE __STATIC_INLINE int32_t __SMMLA(\r
1070   int32_t x,\r
1071   int32_t y,\r
1072   int32_t sum)\r
1073   {\r
1074     return (sum + (int32_t) (((int64_t) x * y) >> 32));\r
1075   }\r
1076 \r
1077 #if 0\r
1078   /*\r
1079    * @brief C custom defined PKHBT for unavailable DSP extension\r
1080    */\r
1081   CMSIS_INLINE __STATIC_INLINE uint32_t __PKHBT(\r
1082   uint32_t x,\r
1083   uint32_t y,\r
1084   uint32_t leftshift)\r
1085   {\r
1086     return ( ((x             ) & 0x0000FFFFUL) |\r
1087              ((y << leftshift) & 0xFFFF0000UL)  );\r
1088   }\r
1089 \r
1090   /*\r
1091    * @brief C custom defined PKHTB for unavailable DSP extension\r
1092    */\r
1093   CMSIS_INLINE __STATIC_INLINE uint32_t __PKHTB(\r
1094   uint32_t x,\r
1095   uint32_t y,\r
1096   uint32_t rightshift)\r
1097   {\r
1098     return ( ((x              ) & 0xFFFF0000UL) |\r
1099              ((y >> rightshift) & 0x0000FFFFUL)  );\r
1100   }\r
1101 #endif\r
1102 \r
1103 /* #endif // defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */\r
1104 #endif /* !defined (ARM_MATH_DSP) */\r
1105 \r
1106 \r
1107   /**\r
1108    * @brief Instance structure for the Q7 FIR filter.\r
1109    */\r
1110   typedef struct\r
1111   {\r
1112     uint16_t numTaps;        /**< number of filter coefficients in the filter. */\r
1113     q7_t *pState;            /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
1114     q7_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps.*/\r
1115   } arm_fir_instance_q7;\r
1116 \r
1117   /**\r
1118    * @brief Instance structure for the Q15 FIR filter.\r
1119    */\r
1120   typedef struct\r
1121   {\r
1122     uint16_t numTaps;         /**< number of filter coefficients in the filter. */\r
1123     q15_t *pState;            /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
1124     q15_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps.*/\r
1125   } arm_fir_instance_q15;\r
1126 \r
1127   /**\r
1128    * @brief Instance structure for the Q31 FIR filter.\r
1129    */\r
1130   typedef struct\r
1131   {\r
1132     uint16_t numTaps;         /**< number of filter coefficients in the filter. */\r
1133     q31_t *pState;            /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
1134     q31_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps. */\r
1135   } arm_fir_instance_q31;\r
1136 \r
1137   /**\r
1138    * @brief Instance structure for the floating-point FIR filter.\r
1139    */\r
1140   typedef struct\r
1141   {\r
1142     uint16_t numTaps;     /**< number of filter coefficients in the filter. */\r
1143     float32_t *pState;    /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
1144     float32_t *pCoeffs;   /**< points to the coefficient array. The array is of length numTaps. */\r
1145   } arm_fir_instance_f32;\r
1146 \r
1147 \r
1148   /**\r
1149    * @brief Processing function for the Q7 FIR filter.\r
1150    * @param[in]  S          points to an instance of the Q7 FIR filter structure.\r
1151    * @param[in]  pSrc       points to the block of input data.\r
1152    * @param[out] pDst       points to the block of output data.\r
1153    * @param[in]  blockSize  number of samples to process.\r
1154    */\r
1155   void arm_fir_q7(\r
1156   const arm_fir_instance_q7 * S,\r
1157   q7_t * pSrc,\r
1158   q7_t * pDst,\r
1159   uint32_t blockSize);\r
1160 \r
1161 \r
1162   /**\r
1163    * @brief  Initialization function for the Q7 FIR filter.\r
1164    * @param[in,out] S          points to an instance of the Q7 FIR structure.\r
1165    * @param[in]     numTaps    Number of filter coefficients in the filter.\r
1166    * @param[in]     pCoeffs    points to the filter coefficients.\r
1167    * @param[in]     pState     points to the state buffer.\r
1168    * @param[in]     blockSize  number of samples that are processed.\r
1169    */\r
1170   void arm_fir_init_q7(\r
1171   arm_fir_instance_q7 * S,\r
1172   uint16_t numTaps,\r
1173   q7_t * pCoeffs,\r
1174   q7_t * pState,\r
1175   uint32_t blockSize);\r
1176 \r
1177 \r
1178   /**\r
1179    * @brief Processing function for the Q15 FIR filter.\r
1180    * @param[in]  S          points to an instance of the Q15 FIR structure.\r
1181    * @param[in]  pSrc       points to the block of input data.\r
1182    * @param[out] pDst       points to the block of output data.\r
1183    * @param[in]  blockSize  number of samples to process.\r
1184    */\r
1185   void arm_fir_q15(\r
1186   const arm_fir_instance_q15 * S,\r
1187   q15_t * pSrc,\r
1188   q15_t * pDst,\r
1189   uint32_t blockSize);\r
1190 \r
1191 \r
1192   /**\r
1193    * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.\r
1194    * @param[in]  S          points to an instance of the Q15 FIR filter structure.\r
1195    * @param[in]  pSrc       points to the block of input data.\r
1196    * @param[out] pDst       points to the block of output data.\r
1197    * @param[in]  blockSize  number of samples to process.\r
1198    */\r
1199   void arm_fir_fast_q15(\r
1200   const arm_fir_instance_q15 * S,\r
1201   q15_t * pSrc,\r
1202   q15_t * pDst,\r
1203   uint32_t blockSize);\r
1204 \r
1205 \r
1206   /**\r
1207    * @brief  Initialization function for the Q15 FIR filter.\r
1208    * @param[in,out] S          points to an instance of the Q15 FIR filter structure.\r
1209    * @param[in]     numTaps    Number of filter coefficients in the filter. Must be even and greater than or equal to 4.\r
1210    * @param[in]     pCoeffs    points to the filter coefficients.\r
1211    * @param[in]     pState     points to the state buffer.\r
1212    * @param[in]     blockSize  number of samples that are processed at a time.\r
1213    * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if\r
1214    * <code>numTaps</code> is not a supported value.\r
1215    */\r
1216   arm_status arm_fir_init_q15(\r
1217   arm_fir_instance_q15 * S,\r
1218   uint16_t numTaps,\r
1219   q15_t * pCoeffs,\r
1220   q15_t * pState,\r
1221   uint32_t blockSize);\r
1222 \r
1223 \r
1224   /**\r
1225    * @brief Processing function for the Q31 FIR filter.\r
1226    * @param[in]  S          points to an instance of the Q31 FIR filter structure.\r
1227    * @param[in]  pSrc       points to the block of input data.\r
1228    * @param[out] pDst       points to the block of output data.\r
1229    * @param[in]  blockSize  number of samples to process.\r
1230    */\r
1231   void arm_fir_q31(\r
1232   const arm_fir_instance_q31 * S,\r
1233   q31_t * pSrc,\r
1234   q31_t * pDst,\r
1235   uint32_t blockSize);\r
1236 \r
1237 \r
1238   /**\r
1239    * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.\r
1240    * @param[in]  S          points to an instance of the Q31 FIR structure.\r
1241    * @param[in]  pSrc       points to the block of input data.\r
1242    * @param[out] pDst       points to the block of output data.\r
1243    * @param[in]  blockSize  number of samples to process.\r
1244    */\r
1245   void arm_fir_fast_q31(\r
1246   const arm_fir_instance_q31 * S,\r
1247   q31_t * pSrc,\r
1248   q31_t * pDst,\r
1249   uint32_t blockSize);\r
1250 \r
1251 \r
1252   /**\r
1253    * @brief  Initialization function for the Q31 FIR filter.\r
1254    * @param[in,out] S          points to an instance of the Q31 FIR structure.\r
1255    * @param[in]     numTaps    Number of filter coefficients in the filter.\r
1256    * @param[in]     pCoeffs    points to the filter coefficients.\r
1257    * @param[in]     pState     points to the state buffer.\r
1258    * @param[in]     blockSize  number of samples that are processed at a time.\r
1259    */\r
1260   void arm_fir_init_q31(\r
1261   arm_fir_instance_q31 * S,\r
1262   uint16_t numTaps,\r
1263   q31_t * pCoeffs,\r
1264   q31_t * pState,\r
1265   uint32_t blockSize);\r
1266 \r
1267 \r
1268   /**\r
1269    * @brief Processing function for the floating-point FIR filter.\r
1270    * @param[in]  S          points to an instance of the floating-point FIR structure.\r
1271    * @param[in]  pSrc       points to the block of input data.\r
1272    * @param[out] pDst       points to the block of output data.\r
1273    * @param[in]  blockSize  number of samples to process.\r
1274    */\r
1275   void arm_fir_f32(\r
1276   const arm_fir_instance_f32 * S,\r
1277   float32_t * pSrc,\r
1278   float32_t * pDst,\r
1279   uint32_t blockSize);\r
1280 \r
1281 \r
1282   /**\r
1283    * @brief  Initialization function for the floating-point FIR filter.\r
1284    * @param[in,out] S          points to an instance of the floating-point FIR filter structure.\r
1285    * @param[in]     numTaps    Number of filter coefficients in the filter.\r
1286    * @param[in]     pCoeffs    points to the filter coefficients.\r
1287    * @param[in]     pState     points to the state buffer.\r
1288    * @param[in]     blockSize  number of samples that are processed at a time.\r
1289    */\r
1290   void arm_fir_init_f32(\r
1291   arm_fir_instance_f32 * S,\r
1292   uint16_t numTaps,\r
1293   float32_t * pCoeffs,\r
1294   float32_t * pState,\r
1295   uint32_t blockSize);\r
1296 \r
1297 \r
1298   /**\r
1299    * @brief Instance structure for the Q15 Biquad cascade filter.\r
1300    */\r
1301   typedef struct\r
1302   {\r
1303     int8_t numStages;        /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
1304     q15_t *pState;           /**< Points to the array of state coefficients.  The array is of length 4*numStages. */\r
1305     q15_t *pCoeffs;          /**< Points to the array of coefficients.  The array is of length 5*numStages. */\r
1306     int8_t postShift;        /**< Additional shift, in bits, applied to each output sample. */\r
1307   } arm_biquad_casd_df1_inst_q15;\r
1308 \r
1309   /**\r
1310    * @brief Instance structure for the Q31 Biquad cascade filter.\r
1311    */\r
1312   typedef struct\r
1313   {\r
1314     uint32_t numStages;      /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
1315     q31_t *pState;           /**< Points to the array of state coefficients.  The array is of length 4*numStages. */\r
1316     q31_t *pCoeffs;          /**< Points to the array of coefficients.  The array is of length 5*numStages. */\r
1317     uint8_t postShift;       /**< Additional shift, in bits, applied to each output sample. */\r
1318   } arm_biquad_casd_df1_inst_q31;\r
1319 \r
1320   /**\r
1321    * @brief Instance structure for the floating-point Biquad cascade filter.\r
1322    */\r
1323   typedef struct\r
1324   {\r
1325     uint32_t numStages;      /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
1326     float32_t *pState;       /**< Points to the array of state coefficients.  The array is of length 4*numStages. */\r
1327     float32_t *pCoeffs;      /**< Points to the array of coefficients.  The array is of length 5*numStages. */\r
1328   } arm_biquad_casd_df1_inst_f32;\r
1329 \r
1330 \r
1331   /**\r
1332    * @brief Processing function for the Q15 Biquad cascade filter.\r
1333    * @param[in]  S          points to an instance of the Q15 Biquad cascade structure.\r
1334    * @param[in]  pSrc       points to the block of input data.\r
1335    * @param[out] pDst       points to the block of output data.\r
1336    * @param[in]  blockSize  number of samples to process.\r
1337    */\r
1338   void arm_biquad_cascade_df1_q15(\r
1339   const arm_biquad_casd_df1_inst_q15 * S,\r
1340   q15_t * pSrc,\r
1341   q15_t * pDst,\r
1342   uint32_t blockSize);\r
1343 \r
1344 \r
1345   /**\r
1346    * @brief  Initialization function for the Q15 Biquad cascade filter.\r
1347    * @param[in,out] S          points to an instance of the Q15 Biquad cascade structure.\r
1348    * @param[in]     numStages  number of 2nd order stages in the filter.\r
1349    * @param[in]     pCoeffs    points to the filter coefficients.\r
1350    * @param[in]     pState     points to the state buffer.\r
1351    * @param[in]     postShift  Shift to be applied to the output. Varies according to the coefficients format\r
1352    */\r
1353   void arm_biquad_cascade_df1_init_q15(\r
1354   arm_biquad_casd_df1_inst_q15 * S,\r
1355   uint8_t numStages,\r
1356   q15_t * pCoeffs,\r
1357   q15_t * pState,\r
1358   int8_t postShift);\r
1359 \r
1360 \r
1361   /**\r
1362    * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.\r
1363    * @param[in]  S          points to an instance of the Q15 Biquad cascade structure.\r
1364    * @param[in]  pSrc       points to the block of input data.\r
1365    * @param[out] pDst       points to the block of output data.\r
1366    * @param[in]  blockSize  number of samples to process.\r
1367    */\r
1368   void arm_biquad_cascade_df1_fast_q15(\r
1369   const arm_biquad_casd_df1_inst_q15 * S,\r
1370   q15_t * pSrc,\r
1371   q15_t * pDst,\r
1372   uint32_t blockSize);\r
1373 \r
1374 \r
1375   /**\r
1376    * @brief Processing function for the Q31 Biquad cascade filter\r
1377    * @param[in]  S          points to an instance of the Q31 Biquad cascade structure.\r
1378    * @param[in]  pSrc       points to the block of input data.\r
1379    * @param[out] pDst       points to the block of output data.\r
1380    * @param[in]  blockSize  number of samples to process.\r
1381    */\r
1382   void arm_biquad_cascade_df1_q31(\r
1383   const arm_biquad_casd_df1_inst_q31 * S,\r
1384   q31_t * pSrc,\r
1385   q31_t * pDst,\r
1386   uint32_t blockSize);\r
1387 \r
1388 \r
1389   /**\r
1390    * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.\r
1391    * @param[in]  S          points to an instance of the Q31 Biquad cascade structure.\r
1392    * @param[in]  pSrc       points to the block of input data.\r
1393    * @param[out] pDst       points to the block of output data.\r
1394    * @param[in]  blockSize  number of samples to process.\r
1395    */\r
1396   void arm_biquad_cascade_df1_fast_q31(\r
1397   const arm_biquad_casd_df1_inst_q31 * S,\r
1398   q31_t * pSrc,\r
1399   q31_t * pDst,\r
1400   uint32_t blockSize);\r
1401 \r
1402 \r
1403   /**\r
1404    * @brief  Initialization function for the Q31 Biquad cascade filter.\r
1405    * @param[in,out] S          points to an instance of the Q31 Biquad cascade structure.\r
1406    * @param[in]     numStages  number of 2nd order stages in the filter.\r
1407    * @param[in]     pCoeffs    points to the filter coefficients.\r
1408    * @param[in]     pState     points to the state buffer.\r
1409    * @param[in]     postShift  Shift to be applied to the output. Varies according to the coefficients format\r
1410    */\r
1411   void arm_biquad_cascade_df1_init_q31(\r
1412   arm_biquad_casd_df1_inst_q31 * S,\r
1413   uint8_t numStages,\r
1414   q31_t * pCoeffs,\r
1415   q31_t * pState,\r
1416   int8_t postShift);\r
1417 \r
1418 \r
1419   /**\r
1420    * @brief Processing function for the floating-point Biquad cascade filter.\r
1421    * @param[in]  S          points to an instance of the floating-point Biquad cascade structure.\r
1422    * @param[in]  pSrc       points to the block of input data.\r
1423    * @param[out] pDst       points to the block of output data.\r
1424    * @param[in]  blockSize  number of samples to process.\r
1425    */\r
1426   void arm_biquad_cascade_df1_f32(\r
1427   const arm_biquad_casd_df1_inst_f32 * S,\r
1428   float32_t * pSrc,\r
1429   float32_t * pDst,\r
1430   uint32_t blockSize);\r
1431 \r
1432 \r
1433   /**\r
1434    * @brief  Initialization function for the floating-point Biquad cascade filter.\r
1435    * @param[in,out] S          points to an instance of the floating-point Biquad cascade structure.\r
1436    * @param[in]     numStages  number of 2nd order stages in the filter.\r
1437    * @param[in]     pCoeffs    points to the filter coefficients.\r
1438    * @param[in]     pState     points to the state buffer.\r
1439    */\r
1440   void arm_biquad_cascade_df1_init_f32(\r
1441   arm_biquad_casd_df1_inst_f32 * S,\r
1442   uint8_t numStages,\r
1443   float32_t * pCoeffs,\r
1444   float32_t * pState);\r
1445 \r
1446 \r
1447   /**\r
1448    * @brief Instance structure for the floating-point matrix structure.\r
1449    */\r
1450   typedef struct\r
1451   {\r
1452     uint16_t numRows;     /**< number of rows of the matrix.     */\r
1453     uint16_t numCols;     /**< number of columns of the matrix.  */\r
1454     float32_t *pData;     /**< points to the data of the matrix. */\r
1455   } arm_matrix_instance_f32;\r
1456 \r
1457 \r
1458   /**\r
1459    * @brief Instance structure for the floating-point matrix structure.\r
1460    */\r
1461   typedef struct\r
1462   {\r
1463     uint16_t numRows;     /**< number of rows of the matrix.     */\r
1464     uint16_t numCols;     /**< number of columns of the matrix.  */\r
1465     float64_t *pData;     /**< points to the data of the matrix. */\r
1466   } arm_matrix_instance_f64;\r
1467 \r
1468   /**\r
1469    * @brief Instance structure for the Q15 matrix structure.\r
1470    */\r
1471   typedef struct\r
1472   {\r
1473     uint16_t numRows;     /**< number of rows of the matrix.     */\r
1474     uint16_t numCols;     /**< number of columns of the matrix.  */\r
1475     q15_t *pData;         /**< points to the data of the matrix. */\r
1476   } arm_matrix_instance_q15;\r
1477 \r
1478   /**\r
1479    * @brief Instance structure for the Q31 matrix structure.\r
1480    */\r
1481   typedef struct\r
1482   {\r
1483     uint16_t numRows;     /**< number of rows of the matrix.     */\r
1484     uint16_t numCols;     /**< number of columns of the matrix.  */\r
1485     q31_t *pData;         /**< points to the data of the matrix. */\r
1486   } arm_matrix_instance_q31;\r
1487 \r
1488 \r
1489   /**\r
1490    * @brief Floating-point matrix addition.\r
1491    * @param[in]  pSrcA  points to the first input matrix structure\r
1492    * @param[in]  pSrcB  points to the second input matrix structure\r
1493    * @param[out] pDst   points to output matrix structure\r
1494    * @return     The function returns either\r
1495    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1496    */\r
1497   arm_status arm_mat_add_f32(\r
1498   const arm_matrix_instance_f32 * pSrcA,\r
1499   const arm_matrix_instance_f32 * pSrcB,\r
1500   arm_matrix_instance_f32 * pDst);\r
1501 \r
1502 \r
1503   /**\r
1504    * @brief Q15 matrix addition.\r
1505    * @param[in]   pSrcA  points to the first input matrix structure\r
1506    * @param[in]   pSrcB  points to the second input matrix structure\r
1507    * @param[out]  pDst   points to output matrix structure\r
1508    * @return     The function returns either\r
1509    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1510    */\r
1511   arm_status arm_mat_add_q15(\r
1512   const arm_matrix_instance_q15 * pSrcA,\r
1513   const arm_matrix_instance_q15 * pSrcB,\r
1514   arm_matrix_instance_q15 * pDst);\r
1515 \r
1516 \r
1517   /**\r
1518    * @brief Q31 matrix addition.\r
1519    * @param[in]  pSrcA  points to the first input matrix structure\r
1520    * @param[in]  pSrcB  points to the second input matrix structure\r
1521    * @param[out] pDst   points to output matrix structure\r
1522    * @return     The function returns either\r
1523    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1524    */\r
1525   arm_status arm_mat_add_q31(\r
1526   const arm_matrix_instance_q31 * pSrcA,\r
1527   const arm_matrix_instance_q31 * pSrcB,\r
1528   arm_matrix_instance_q31 * pDst);\r
1529 \r
1530 \r
1531   /**\r
1532    * @brief Floating-point, complex, matrix multiplication.\r
1533    * @param[in]  pSrcA  points to the first input matrix structure\r
1534    * @param[in]  pSrcB  points to the second input matrix structure\r
1535    * @param[out] pDst   points to output matrix structure\r
1536    * @return     The function returns either\r
1537    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1538    */\r
1539   arm_status arm_mat_cmplx_mult_f32(\r
1540   const arm_matrix_instance_f32 * pSrcA,\r
1541   const arm_matrix_instance_f32 * pSrcB,\r
1542   arm_matrix_instance_f32 * pDst);\r
1543 \r
1544 \r
1545   /**\r
1546    * @brief Q15, complex,  matrix multiplication.\r
1547    * @param[in]  pSrcA  points to the first input matrix structure\r
1548    * @param[in]  pSrcB  points to the second input matrix structure\r
1549    * @param[out] pDst   points to output matrix structure\r
1550    * @return     The function returns either\r
1551    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1552    */\r
1553   arm_status arm_mat_cmplx_mult_q15(\r
1554   const arm_matrix_instance_q15 * pSrcA,\r
1555   const arm_matrix_instance_q15 * pSrcB,\r
1556   arm_matrix_instance_q15 * pDst,\r
1557   q15_t * pScratch);\r
1558 \r
1559 \r
1560   /**\r
1561    * @brief Q31, complex, matrix multiplication.\r
1562    * @param[in]  pSrcA  points to the first input matrix structure\r
1563    * @param[in]  pSrcB  points to the second input matrix structure\r
1564    * @param[out] pDst   points to output matrix structure\r
1565    * @return     The function returns either\r
1566    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1567    */\r
1568   arm_status arm_mat_cmplx_mult_q31(\r
1569   const arm_matrix_instance_q31 * pSrcA,\r
1570   const arm_matrix_instance_q31 * pSrcB,\r
1571   arm_matrix_instance_q31 * pDst);\r
1572 \r
1573 \r
1574   /**\r
1575    * @brief Floating-point matrix transpose.\r
1576    * @param[in]  pSrc  points to the input matrix\r
1577    * @param[out] pDst  points to the output matrix\r
1578    * @return    The function returns either  <code>ARM_MATH_SIZE_MISMATCH</code>\r
1579    * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1580    */\r
1581   arm_status arm_mat_trans_f32(\r
1582   const arm_matrix_instance_f32 * pSrc,\r
1583   arm_matrix_instance_f32 * pDst);\r
1584 \r
1585 \r
1586   /**\r
1587    * @brief Q15 matrix transpose.\r
1588    * @param[in]  pSrc  points to the input matrix\r
1589    * @param[out] pDst  points to the output matrix\r
1590    * @return    The function returns either  <code>ARM_MATH_SIZE_MISMATCH</code>\r
1591    * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1592    */\r
1593   arm_status arm_mat_trans_q15(\r
1594   const arm_matrix_instance_q15 * pSrc,\r
1595   arm_matrix_instance_q15 * pDst);\r
1596 \r
1597 \r
1598   /**\r
1599    * @brief Q31 matrix transpose.\r
1600    * @param[in]  pSrc  points to the input matrix\r
1601    * @param[out] pDst  points to the output matrix\r
1602    * @return    The function returns either  <code>ARM_MATH_SIZE_MISMATCH</code>\r
1603    * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1604    */\r
1605   arm_status arm_mat_trans_q31(\r
1606   const arm_matrix_instance_q31 * pSrc,\r
1607   arm_matrix_instance_q31 * pDst);\r
1608 \r
1609 \r
1610   /**\r
1611    * @brief Floating-point matrix multiplication\r
1612    * @param[in]  pSrcA  points to the first input matrix structure\r
1613    * @param[in]  pSrcB  points to the second input matrix structure\r
1614    * @param[out] pDst   points to output matrix structure\r
1615    * @return     The function returns either\r
1616    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1617    */\r
1618   arm_status arm_mat_mult_f32(\r
1619   const arm_matrix_instance_f32 * pSrcA,\r
1620   const arm_matrix_instance_f32 * pSrcB,\r
1621   arm_matrix_instance_f32 * pDst);\r
1622 \r
1623 \r
1624   /**\r
1625    * @brief Q15 matrix multiplication\r
1626    * @param[in]  pSrcA   points to the first input matrix structure\r
1627    * @param[in]  pSrcB   points to the second input matrix structure\r
1628    * @param[out] pDst    points to output matrix structure\r
1629    * @param[in]  pState  points to the array for storing intermediate results\r
1630    * @return     The function returns either\r
1631    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1632    */\r
1633   arm_status arm_mat_mult_q15(\r
1634   const arm_matrix_instance_q15 * pSrcA,\r
1635   const arm_matrix_instance_q15 * pSrcB,\r
1636   arm_matrix_instance_q15 * pDst,\r
1637   q15_t * pState);\r
1638 \r
1639 \r
1640   /**\r
1641    * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4\r
1642    * @param[in]  pSrcA   points to the first input matrix structure\r
1643    * @param[in]  pSrcB   points to the second input matrix structure\r
1644    * @param[out] pDst    points to output matrix structure\r
1645    * @param[in]  pState  points to the array for storing intermediate results\r
1646    * @return     The function returns either\r
1647    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1648    */\r
1649   arm_status arm_mat_mult_fast_q15(\r
1650   const arm_matrix_instance_q15 * pSrcA,\r
1651   const arm_matrix_instance_q15 * pSrcB,\r
1652   arm_matrix_instance_q15 * pDst,\r
1653   q15_t * pState);\r
1654 \r
1655 \r
1656   /**\r
1657    * @brief Q31 matrix multiplication\r
1658    * @param[in]  pSrcA  points to the first input matrix structure\r
1659    * @param[in]  pSrcB  points to the second input matrix structure\r
1660    * @param[out] pDst   points to output matrix structure\r
1661    * @return     The function returns either\r
1662    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1663    */\r
1664   arm_status arm_mat_mult_q31(\r
1665   const arm_matrix_instance_q31 * pSrcA,\r
1666   const arm_matrix_instance_q31 * pSrcB,\r
1667   arm_matrix_instance_q31 * pDst);\r
1668 \r
1669 \r
1670   /**\r
1671    * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4\r
1672    * @param[in]  pSrcA  points to the first input matrix structure\r
1673    * @param[in]  pSrcB  points to the second input matrix structure\r
1674    * @param[out] pDst   points to output matrix structure\r
1675    * @return     The function returns either\r
1676    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1677    */\r
1678   arm_status arm_mat_mult_fast_q31(\r
1679   const arm_matrix_instance_q31 * pSrcA,\r
1680   const arm_matrix_instance_q31 * pSrcB,\r
1681   arm_matrix_instance_q31 * pDst);\r
1682 \r
1683 \r
1684   /**\r
1685    * @brief Floating-point matrix subtraction\r
1686    * @param[in]  pSrcA  points to the first input matrix structure\r
1687    * @param[in]  pSrcB  points to the second input matrix structure\r
1688    * @param[out] pDst   points to output matrix structure\r
1689    * @return     The function returns either\r
1690    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1691    */\r
1692   arm_status arm_mat_sub_f32(\r
1693   const arm_matrix_instance_f32 * pSrcA,\r
1694   const arm_matrix_instance_f32 * pSrcB,\r
1695   arm_matrix_instance_f32 * pDst);\r
1696 \r
1697 \r
1698   /**\r
1699    * @brief Q15 matrix subtraction\r
1700    * @param[in]  pSrcA  points to the first input matrix structure\r
1701    * @param[in]  pSrcB  points to the second input matrix structure\r
1702    * @param[out] pDst   points to output matrix structure\r
1703    * @return     The function returns either\r
1704    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1705    */\r
1706   arm_status arm_mat_sub_q15(\r
1707   const arm_matrix_instance_q15 * pSrcA,\r
1708   const arm_matrix_instance_q15 * pSrcB,\r
1709   arm_matrix_instance_q15 * pDst);\r
1710 \r
1711 \r
1712   /**\r
1713    * @brief Q31 matrix subtraction\r
1714    * @param[in]  pSrcA  points to the first input matrix structure\r
1715    * @param[in]  pSrcB  points to the second input matrix structure\r
1716    * @param[out] pDst   points to output matrix structure\r
1717    * @return     The function returns either\r
1718    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1719    */\r
1720   arm_status arm_mat_sub_q31(\r
1721   const arm_matrix_instance_q31 * pSrcA,\r
1722   const arm_matrix_instance_q31 * pSrcB,\r
1723   arm_matrix_instance_q31 * pDst);\r
1724 \r
1725 \r
1726   /**\r
1727    * @brief Floating-point matrix scaling.\r
1728    * @param[in]  pSrc   points to the input matrix\r
1729    * @param[in]  scale  scale factor\r
1730    * @param[out] pDst   points to the output matrix\r
1731    * @return     The function returns either\r
1732    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1733    */\r
1734   arm_status arm_mat_scale_f32(\r
1735   const arm_matrix_instance_f32 * pSrc,\r
1736   float32_t scale,\r
1737   arm_matrix_instance_f32 * pDst);\r
1738 \r
1739 \r
1740   /**\r
1741    * @brief Q15 matrix scaling.\r
1742    * @param[in]  pSrc        points to input matrix\r
1743    * @param[in]  scaleFract  fractional portion of the scale factor\r
1744    * @param[in]  shift       number of bits to shift the result by\r
1745    * @param[out] pDst        points to output matrix\r
1746    * @return     The function returns either\r
1747    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1748    */\r
1749   arm_status arm_mat_scale_q15(\r
1750   const arm_matrix_instance_q15 * pSrc,\r
1751   q15_t scaleFract,\r
1752   int32_t shift,\r
1753   arm_matrix_instance_q15 * pDst);\r
1754 \r
1755 \r
1756   /**\r
1757    * @brief Q31 matrix scaling.\r
1758    * @param[in]  pSrc        points to input matrix\r
1759    * @param[in]  scaleFract  fractional portion of the scale factor\r
1760    * @param[in]  shift       number of bits to shift the result by\r
1761    * @param[out] pDst        points to output matrix structure\r
1762    * @return     The function returns either\r
1763    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.\r
1764    */\r
1765   arm_status arm_mat_scale_q31(\r
1766   const arm_matrix_instance_q31 * pSrc,\r
1767   q31_t scaleFract,\r
1768   int32_t shift,\r
1769   arm_matrix_instance_q31 * pDst);\r
1770 \r
1771 \r
1772   /**\r
1773    * @brief  Q31 matrix initialization.\r
1774    * @param[in,out] S         points to an instance of the floating-point matrix structure.\r
1775    * @param[in]     nRows     number of rows in the matrix.\r
1776    * @param[in]     nColumns  number of columns in the matrix.\r
1777    * @param[in]     pData     points to the matrix data array.\r
1778    */\r
1779   void arm_mat_init_q31(\r
1780   arm_matrix_instance_q31 * S,\r
1781   uint16_t nRows,\r
1782   uint16_t nColumns,\r
1783   q31_t * pData);\r
1784 \r
1785 \r
1786   /**\r
1787    * @brief  Q15 matrix initialization.\r
1788    * @param[in,out] S         points to an instance of the floating-point matrix structure.\r
1789    * @param[in]     nRows     number of rows in the matrix.\r
1790    * @param[in]     nColumns  number of columns in the matrix.\r
1791    * @param[in]     pData     points to the matrix data array.\r
1792    */\r
1793   void arm_mat_init_q15(\r
1794   arm_matrix_instance_q15 * S,\r
1795   uint16_t nRows,\r
1796   uint16_t nColumns,\r
1797   q15_t * pData);\r
1798 \r
1799 \r
1800   /**\r
1801    * @brief  Floating-point matrix initialization.\r
1802    * @param[in,out] S         points to an instance of the floating-point matrix structure.\r
1803    * @param[in]     nRows     number of rows in the matrix.\r
1804    * @param[in]     nColumns  number of columns in the matrix.\r
1805    * @param[in]     pData     points to the matrix data array.\r
1806    */\r
1807   void arm_mat_init_f32(\r
1808   arm_matrix_instance_f32 * S,\r
1809   uint16_t nRows,\r
1810   uint16_t nColumns,\r
1811   float32_t * pData);\r
1812 \r
1813 \r
1814 \r
1815   /**\r
1816    * @brief Instance structure for the Q15 PID Control.\r
1817    */\r
1818   typedef struct\r
1819   {\r
1820     q15_t A0;           /**< The derived gain, A0 = Kp + Ki + Kd . */\r
1821 #if !defined (ARM_MATH_DSP)\r
1822     q15_t A1;\r
1823     q15_t A2;\r
1824 #else\r
1825     q31_t A1;           /**< The derived gain A1 = -Kp - 2Kd | Kd.*/\r
1826 #endif\r
1827     q15_t state[3];     /**< The state array of length 3. */\r
1828     q15_t Kp;           /**< The proportional gain. */\r
1829     q15_t Ki;           /**< The integral gain. */\r
1830     q15_t Kd;           /**< The derivative gain. */\r
1831   } arm_pid_instance_q15;\r
1832 \r
1833   /**\r
1834    * @brief Instance structure for the Q31 PID Control.\r
1835    */\r
1836   typedef struct\r
1837   {\r
1838     q31_t A0;            /**< The derived gain, A0 = Kp + Ki + Kd . */\r
1839     q31_t A1;            /**< The derived gain, A1 = -Kp - 2Kd. */\r
1840     q31_t A2;            /**< The derived gain, A2 = Kd . */\r
1841     q31_t state[3];      /**< The state array of length 3. */\r
1842     q31_t Kp;            /**< The proportional gain. */\r
1843     q31_t Ki;            /**< The integral gain. */\r
1844     q31_t Kd;            /**< The derivative gain. */\r
1845   } arm_pid_instance_q31;\r
1846 \r
1847   /**\r
1848    * @brief Instance structure for the floating-point PID Control.\r
1849    */\r
1850   typedef struct\r
1851   {\r
1852     float32_t A0;          /**< The derived gain, A0 = Kp + Ki + Kd . */\r
1853     float32_t A1;          /**< The derived gain, A1 = -Kp - 2Kd. */\r
1854     float32_t A2;          /**< The derived gain, A2 = Kd . */\r
1855     float32_t state[3];    /**< The state array of length 3. */\r
1856     float32_t Kp;          /**< The proportional gain. */\r
1857     float32_t Ki;          /**< The integral gain. */\r
1858     float32_t Kd;          /**< The derivative gain. */\r
1859   } arm_pid_instance_f32;\r
1860 \r
1861 \r
1862 \r
1863   /**\r
1864    * @brief  Initialization function for the floating-point PID Control.\r
1865    * @param[in,out] S               points to an instance of the PID structure.\r
1866    * @param[in]     resetStateFlag  flag to reset the state. 0 = no change in state 1 = reset the state.\r
1867    */\r
1868   void arm_pid_init_f32(\r
1869   arm_pid_instance_f32 * S,\r
1870   int32_t resetStateFlag);\r
1871 \r
1872 \r
1873   /**\r
1874    * @brief  Reset function for the floating-point PID Control.\r
1875    * @param[in,out] S  is an instance of the floating-point PID Control structure\r
1876    */\r
1877   void arm_pid_reset_f32(\r
1878   arm_pid_instance_f32 * S);\r
1879 \r
1880 \r
1881   /**\r
1882    * @brief  Initialization function for the Q31 PID Control.\r
1883    * @param[in,out] S               points to an instance of the Q15 PID structure.\r
1884    * @param[in]     resetStateFlag  flag to reset the state. 0 = no change in state 1 = reset the state.\r
1885    */\r
1886   void arm_pid_init_q31(\r
1887   arm_pid_instance_q31 * S,\r
1888   int32_t resetStateFlag);\r
1889 \r
1890 \r
1891   /**\r
1892    * @brief  Reset function for the Q31 PID Control.\r
1893    * @param[in,out] S   points to an instance of the Q31 PID Control structure\r
1894    */\r
1895 \r
1896   void arm_pid_reset_q31(\r
1897   arm_pid_instance_q31 * S);\r
1898 \r
1899 \r
1900   /**\r
1901    * @brief  Initialization function for the Q15 PID Control.\r
1902    * @param[in,out] S               points to an instance of the Q15 PID structure.\r
1903    * @param[in]     resetStateFlag  flag to reset the state. 0 = no change in state 1 = reset the state.\r
1904    */\r
1905   void arm_pid_init_q15(\r
1906   arm_pid_instance_q15 * S,\r
1907   int32_t resetStateFlag);\r
1908 \r
1909 \r
1910   /**\r
1911    * @brief  Reset function for the Q15 PID Control.\r
1912    * @param[in,out] S  points to an instance of the q15 PID Control structure\r
1913    */\r
1914   void arm_pid_reset_q15(\r
1915   arm_pid_instance_q15 * S);\r
1916 \r
1917 \r
1918   /**\r
1919    * @brief Instance structure for the floating-point Linear Interpolate function.\r
1920    */\r
1921   typedef struct\r
1922   {\r
1923     uint32_t nValues;           /**< nValues */\r
1924     float32_t x1;               /**< x1 */\r
1925     float32_t xSpacing;         /**< xSpacing */\r
1926     float32_t *pYData;          /**< pointer to the table of Y values */\r
1927   } arm_linear_interp_instance_f32;\r
1928 \r
1929   /**\r
1930    * @brief Instance structure for the floating-point bilinear interpolation function.\r
1931    */\r
1932   typedef struct\r
1933   {\r
1934     uint16_t numRows;   /**< number of rows in the data table. */\r
1935     uint16_t numCols;   /**< number of columns in the data table. */\r
1936     float32_t *pData;   /**< points to the data table. */\r
1937   } arm_bilinear_interp_instance_f32;\r
1938 \r
1939    /**\r
1940    * @brief Instance structure for the Q31 bilinear interpolation function.\r
1941    */\r
1942   typedef struct\r
1943   {\r
1944     uint16_t numRows;   /**< number of rows in the data table. */\r
1945     uint16_t numCols;   /**< number of columns in the data table. */\r
1946     q31_t *pData;       /**< points to the data table. */\r
1947   } arm_bilinear_interp_instance_q31;\r
1948 \r
1949    /**\r
1950    * @brief Instance structure for the Q15 bilinear interpolation function.\r
1951    */\r
1952   typedef struct\r
1953   {\r
1954     uint16_t numRows;   /**< number of rows in the data table. */\r
1955     uint16_t numCols;   /**< number of columns in the data table. */\r
1956     q15_t *pData;       /**< points to the data table. */\r
1957   } arm_bilinear_interp_instance_q15;\r
1958 \r
1959    /**\r
1960    * @brief Instance structure for the Q15 bilinear interpolation function.\r
1961    */\r
1962   typedef struct\r
1963   {\r
1964     uint16_t numRows;   /**< number of rows in the data table. */\r
1965     uint16_t numCols;   /**< number of columns in the data table. */\r
1966     q7_t *pData;        /**< points to the data table. */\r
1967   } arm_bilinear_interp_instance_q7;\r
1968 \r
1969 \r
1970   /**\r
1971    * @brief Q7 vector multiplication.\r
1972    * @param[in]  pSrcA      points to the first input vector\r
1973    * @param[in]  pSrcB      points to the second input vector\r
1974    * @param[out] pDst       points to the output vector\r
1975    * @param[in]  blockSize  number of samples in each vector\r
1976    */\r
1977   void arm_mult_q7(\r
1978   q7_t * pSrcA,\r
1979   q7_t * pSrcB,\r
1980   q7_t * pDst,\r
1981   uint32_t blockSize);\r
1982 \r
1983 \r
1984   /**\r
1985    * @brief Q15 vector multiplication.\r
1986    * @param[in]  pSrcA      points to the first input vector\r
1987    * @param[in]  pSrcB      points to the second input vector\r
1988    * @param[out] pDst       points to the output vector\r
1989    * @param[in]  blockSize  number of samples in each vector\r
1990    */\r
1991   void arm_mult_q15(\r
1992   q15_t * pSrcA,\r
1993   q15_t * pSrcB,\r
1994   q15_t * pDst,\r
1995   uint32_t blockSize);\r
1996 \r
1997 \r
1998   /**\r
1999    * @brief Q31 vector multiplication.\r
2000    * @param[in]  pSrcA      points to the first input vector\r
2001    * @param[in]  pSrcB      points to the second input vector\r
2002    * @param[out] pDst       points to the output vector\r
2003    * @param[in]  blockSize  number of samples in each vector\r
2004    */\r
2005   void arm_mult_q31(\r
2006   q31_t * pSrcA,\r
2007   q31_t * pSrcB,\r
2008   q31_t * pDst,\r
2009   uint32_t blockSize);\r
2010 \r
2011 \r
2012   /**\r
2013    * @brief Floating-point vector multiplication.\r
2014    * @param[in]  pSrcA      points to the first input vector\r
2015    * @param[in]  pSrcB      points to the second input vector\r
2016    * @param[out] pDst       points to the output vector\r
2017    * @param[in]  blockSize  number of samples in each vector\r
2018    */\r
2019   void arm_mult_f32(\r
2020   float32_t * pSrcA,\r
2021   float32_t * pSrcB,\r
2022   float32_t * pDst,\r
2023   uint32_t blockSize);\r
2024 \r
2025 \r
2026   /**\r
2027    * @brief Instance structure for the Q15 CFFT/CIFFT function.\r
2028    */\r
2029   typedef struct\r
2030   {\r
2031     uint16_t fftLen;                 /**< length of the FFT. */\r
2032     uint8_t ifftFlag;                /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */\r
2033     uint8_t bitReverseFlag;          /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */\r
2034     q15_t *pTwiddle;                 /**< points to the Sin twiddle factor table. */\r
2035     uint16_t *pBitRevTable;          /**< points to the bit reversal table. */\r
2036     uint16_t twidCoefModifier;       /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2037     uint16_t bitRevFactor;           /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */\r
2038   } arm_cfft_radix2_instance_q15;\r
2039 \r
2040 /* Deprecated */\r
2041   arm_status arm_cfft_radix2_init_q15(\r
2042   arm_cfft_radix2_instance_q15 * S,\r
2043   uint16_t fftLen,\r
2044   uint8_t ifftFlag,\r
2045   uint8_t bitReverseFlag);\r
2046 \r
2047 /* Deprecated */\r
2048   void arm_cfft_radix2_q15(\r
2049   const arm_cfft_radix2_instance_q15 * S,\r
2050   q15_t * pSrc);\r
2051 \r
2052 \r
2053   /**\r
2054    * @brief Instance structure for the Q15 CFFT/CIFFT function.\r
2055    */\r
2056   typedef struct\r
2057   {\r
2058     uint16_t fftLen;                 /**< length of the FFT. */\r
2059     uint8_t ifftFlag;                /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */\r
2060     uint8_t bitReverseFlag;          /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */\r
2061     q15_t *pTwiddle;                 /**< points to the twiddle factor table. */\r
2062     uint16_t *pBitRevTable;          /**< points to the bit reversal table. */\r
2063     uint16_t twidCoefModifier;       /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2064     uint16_t bitRevFactor;           /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */\r
2065   } arm_cfft_radix4_instance_q15;\r
2066 \r
2067 /* Deprecated */\r
2068   arm_status arm_cfft_radix4_init_q15(\r
2069   arm_cfft_radix4_instance_q15 * S,\r
2070   uint16_t fftLen,\r
2071   uint8_t ifftFlag,\r
2072   uint8_t bitReverseFlag);\r
2073 \r
2074 /* Deprecated */\r
2075   void arm_cfft_radix4_q15(\r
2076   const arm_cfft_radix4_instance_q15 * S,\r
2077   q15_t * pSrc);\r
2078 \r
2079   /**\r
2080    * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.\r
2081    */\r
2082   typedef struct\r
2083   {\r
2084     uint16_t fftLen;                 /**< length of the FFT. */\r
2085     uint8_t ifftFlag;                /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */\r
2086     uint8_t bitReverseFlag;          /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */\r
2087     q31_t *pTwiddle;                 /**< points to the Twiddle factor table. */\r
2088     uint16_t *pBitRevTable;          /**< points to the bit reversal table. */\r
2089     uint16_t twidCoefModifier;       /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2090     uint16_t bitRevFactor;           /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */\r
2091   } arm_cfft_radix2_instance_q31;\r
2092 \r
2093 /* Deprecated */\r
2094   arm_status arm_cfft_radix2_init_q31(\r
2095   arm_cfft_radix2_instance_q31 * S,\r
2096   uint16_t fftLen,\r
2097   uint8_t ifftFlag,\r
2098   uint8_t bitReverseFlag);\r
2099 \r
2100 /* Deprecated */\r
2101   void arm_cfft_radix2_q31(\r
2102   const arm_cfft_radix2_instance_q31 * S,\r
2103   q31_t * pSrc);\r
2104 \r
2105   /**\r
2106    * @brief Instance structure for the Q31 CFFT/CIFFT function.\r
2107    */\r
2108   typedef struct\r
2109   {\r
2110     uint16_t fftLen;                 /**< length of the FFT. */\r
2111     uint8_t ifftFlag;                /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */\r
2112     uint8_t bitReverseFlag;          /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */\r
2113     q31_t *pTwiddle;                 /**< points to the twiddle factor table. */\r
2114     uint16_t *pBitRevTable;          /**< points to the bit reversal table. */\r
2115     uint16_t twidCoefModifier;       /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2116     uint16_t bitRevFactor;           /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */\r
2117   } arm_cfft_radix4_instance_q31;\r
2118 \r
2119 /* Deprecated */\r
2120   void arm_cfft_radix4_q31(\r
2121   const arm_cfft_radix4_instance_q31 * S,\r
2122   q31_t * pSrc);\r
2123 \r
2124 /* Deprecated */\r
2125   arm_status arm_cfft_radix4_init_q31(\r
2126   arm_cfft_radix4_instance_q31 * S,\r
2127   uint16_t fftLen,\r
2128   uint8_t ifftFlag,\r
2129   uint8_t bitReverseFlag);\r
2130 \r
2131   /**\r
2132    * @brief Instance structure for the floating-point CFFT/CIFFT function.\r
2133    */\r
2134   typedef struct\r
2135   {\r
2136     uint16_t fftLen;                   /**< length of the FFT. */\r
2137     uint8_t ifftFlag;                  /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */\r
2138     uint8_t bitReverseFlag;            /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */\r
2139     float32_t *pTwiddle;               /**< points to the Twiddle factor table. */\r
2140     uint16_t *pBitRevTable;            /**< points to the bit reversal table. */\r
2141     uint16_t twidCoefModifier;         /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2142     uint16_t bitRevFactor;             /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */\r
2143     float32_t onebyfftLen;             /**< value of 1/fftLen. */\r
2144   } arm_cfft_radix2_instance_f32;\r
2145 \r
2146 /* Deprecated */\r
2147   arm_status arm_cfft_radix2_init_f32(\r
2148   arm_cfft_radix2_instance_f32 * S,\r
2149   uint16_t fftLen,\r
2150   uint8_t ifftFlag,\r
2151   uint8_t bitReverseFlag);\r
2152 \r
2153 /* Deprecated */\r
2154   void arm_cfft_radix2_f32(\r
2155   const arm_cfft_radix2_instance_f32 * S,\r
2156   float32_t * pSrc);\r
2157 \r
2158   /**\r
2159    * @brief Instance structure for the floating-point CFFT/CIFFT function.\r
2160    */\r
2161   typedef struct\r
2162   {\r
2163     uint16_t fftLen;                   /**< length of the FFT. */\r
2164     uint8_t ifftFlag;                  /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */\r
2165     uint8_t bitReverseFlag;            /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */\r
2166     float32_t *pTwiddle;               /**< points to the Twiddle factor table. */\r
2167     uint16_t *pBitRevTable;            /**< points to the bit reversal table. */\r
2168     uint16_t twidCoefModifier;         /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2169     uint16_t bitRevFactor;             /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */\r
2170     float32_t onebyfftLen;             /**< value of 1/fftLen. */\r
2171   } arm_cfft_radix4_instance_f32;\r
2172 \r
2173 /* Deprecated */\r
2174   arm_status arm_cfft_radix4_init_f32(\r
2175   arm_cfft_radix4_instance_f32 * S,\r
2176   uint16_t fftLen,\r
2177   uint8_t ifftFlag,\r
2178   uint8_t bitReverseFlag);\r
2179 \r
2180 /* Deprecated */\r
2181   void arm_cfft_radix4_f32(\r
2182   const arm_cfft_radix4_instance_f32 * S,\r
2183   float32_t * pSrc);\r
2184 \r
2185   /**\r
2186    * @brief Instance structure for the fixed-point CFFT/CIFFT function.\r
2187    */\r
2188   typedef struct\r
2189   {\r
2190     uint16_t fftLen;                   /**< length of the FFT. */\r
2191     const q15_t *pTwiddle;             /**< points to the Twiddle factor table. */\r
2192     const uint16_t *pBitRevTable;      /**< points to the bit reversal table. */\r
2193     uint16_t bitRevLength;             /**< bit reversal table length. */\r
2194   } arm_cfft_instance_q15;\r
2195 \r
2196 void arm_cfft_q15(\r
2197     const arm_cfft_instance_q15 * S,\r
2198     q15_t * p1,\r
2199     uint8_t ifftFlag,\r
2200     uint8_t bitReverseFlag);\r
2201 \r
2202   /**\r
2203    * @brief Instance structure for the fixed-point CFFT/CIFFT function.\r
2204    */\r
2205   typedef struct\r
2206   {\r
2207     uint16_t fftLen;                   /**< length of the FFT. */\r
2208     const q31_t *pTwiddle;             /**< points to the Twiddle factor table. */\r
2209     const uint16_t *pBitRevTable;      /**< points to the bit reversal table. */\r
2210     uint16_t bitRevLength;             /**< bit reversal table length. */\r
2211   } arm_cfft_instance_q31;\r
2212 \r
2213 void arm_cfft_q31(\r
2214     const arm_cfft_instance_q31 * S,\r
2215     q31_t * p1,\r
2216     uint8_t ifftFlag,\r
2217     uint8_t bitReverseFlag);\r
2218 \r
2219   /**\r
2220    * @brief Instance structure for the floating-point CFFT/CIFFT function.\r
2221    */\r
2222   typedef struct\r
2223   {\r
2224     uint16_t fftLen;                   /**< length of the FFT. */\r
2225     const float32_t *pTwiddle;         /**< points to the Twiddle factor table. */\r
2226     const uint16_t *pBitRevTable;      /**< points to the bit reversal table. */\r
2227     uint16_t bitRevLength;             /**< bit reversal table length. */\r
2228   } arm_cfft_instance_f32;\r
2229 \r
2230   void arm_cfft_f32(\r
2231   const arm_cfft_instance_f32 * S,\r
2232   float32_t * p1,\r
2233   uint8_t ifftFlag,\r
2234   uint8_t bitReverseFlag);\r
2235 \r
2236   /**\r
2237    * @brief Instance structure for the Q15 RFFT/RIFFT function.\r
2238    */\r
2239   typedef struct\r
2240   {\r
2241     uint32_t fftLenReal;                      /**< length of the real FFT. */\r
2242     uint8_t ifftFlagR;                        /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */\r
2243     uint8_t bitReverseFlagR;                  /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */\r
2244     uint32_t twidCoefRModifier;               /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2245     q15_t *pTwiddleAReal;                     /**< points to the real twiddle factor table. */\r
2246     q15_t *pTwiddleBReal;                     /**< points to the imag twiddle factor table. */\r
2247     const arm_cfft_instance_q15 *pCfft;       /**< points to the complex FFT instance. */\r
2248   } arm_rfft_instance_q15;\r
2249 \r
2250   arm_status arm_rfft_init_q15(\r
2251   arm_rfft_instance_q15 * S,\r
2252   uint32_t fftLenReal,\r
2253   uint32_t ifftFlagR,\r
2254   uint32_t bitReverseFlag);\r
2255 \r
2256   void arm_rfft_q15(\r
2257   const arm_rfft_instance_q15 * S,\r
2258   q15_t * pSrc,\r
2259   q15_t * pDst);\r
2260 \r
2261   /**\r
2262    * @brief Instance structure for the Q31 RFFT/RIFFT function.\r
2263    */\r
2264   typedef struct\r
2265   {\r
2266     uint32_t fftLenReal;                        /**< length of the real FFT. */\r
2267     uint8_t ifftFlagR;                          /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */\r
2268     uint8_t bitReverseFlagR;                    /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */\r
2269     uint32_t twidCoefRModifier;                 /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2270     q31_t *pTwiddleAReal;                       /**< points to the real twiddle factor table. */\r
2271     q31_t *pTwiddleBReal;                       /**< points to the imag twiddle factor table. */\r
2272     const arm_cfft_instance_q31 *pCfft;         /**< points to the complex FFT instance. */\r
2273   } arm_rfft_instance_q31;\r
2274 \r
2275   arm_status arm_rfft_init_q31(\r
2276   arm_rfft_instance_q31 * S,\r
2277   uint32_t fftLenReal,\r
2278   uint32_t ifftFlagR,\r
2279   uint32_t bitReverseFlag);\r
2280 \r
2281   void arm_rfft_q31(\r
2282   const arm_rfft_instance_q31 * S,\r
2283   q31_t * pSrc,\r
2284   q31_t * pDst);\r
2285 \r
2286   /**\r
2287    * @brief Instance structure for the floating-point RFFT/RIFFT function.\r
2288    */\r
2289   typedef struct\r
2290   {\r
2291     uint32_t fftLenReal;                        /**< length of the real FFT. */\r
2292     uint16_t fftLenBy2;                         /**< length of the complex FFT. */\r
2293     uint8_t ifftFlagR;                          /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */\r
2294     uint8_t bitReverseFlagR;                    /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */\r
2295     uint32_t twidCoefRModifier;                     /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */\r
2296     float32_t *pTwiddleAReal;                   /**< points to the real twiddle factor table. */\r
2297     float32_t *pTwiddleBReal;                   /**< points to the imag twiddle factor table. */\r
2298     arm_cfft_radix4_instance_f32 *pCfft;        /**< points to the complex FFT instance. */\r
2299   } arm_rfft_instance_f32;\r
2300 \r
2301   arm_status arm_rfft_init_f32(\r
2302   arm_rfft_instance_f32 * S,\r
2303   arm_cfft_radix4_instance_f32 * S_CFFT,\r
2304   uint32_t fftLenReal,\r
2305   uint32_t ifftFlagR,\r
2306   uint32_t bitReverseFlag);\r
2307 \r
2308   void arm_rfft_f32(\r
2309   const arm_rfft_instance_f32 * S,\r
2310   float32_t * pSrc,\r
2311   float32_t * pDst);\r
2312 \r
2313   /**\r
2314    * @brief Instance structure for the floating-point RFFT/RIFFT function.\r
2315    */\r
2316 typedef struct\r
2317   {\r
2318     arm_cfft_instance_f32 Sint;      /**< Internal CFFT structure. */\r
2319     uint16_t fftLenRFFT;             /**< length of the real sequence */\r
2320     float32_t * pTwiddleRFFT;        /**< Twiddle factors real stage  */\r
2321   } arm_rfft_fast_instance_f32 ;\r
2322 \r
2323 arm_status arm_rfft_fast_init_f32 (\r
2324    arm_rfft_fast_instance_f32 * S,\r
2325    uint16_t fftLen);\r
2326 \r
2327 void arm_rfft_fast_f32(\r
2328   arm_rfft_fast_instance_f32 * S,\r
2329   float32_t * p, float32_t * pOut,\r
2330   uint8_t ifftFlag);\r
2331 \r
2332   /**\r
2333    * @brief Instance structure for the floating-point DCT4/IDCT4 function.\r
2334    */\r
2335   typedef struct\r
2336   {\r
2337     uint16_t N;                          /**< length of the DCT4. */\r
2338     uint16_t Nby2;                       /**< half of the length of the DCT4. */\r
2339     float32_t normalize;                 /**< normalizing factor. */\r
2340     float32_t *pTwiddle;                 /**< points to the twiddle factor table. */\r
2341     float32_t *pCosFactor;               /**< points to the cosFactor table. */\r
2342     arm_rfft_instance_f32 *pRfft;        /**< points to the real FFT instance. */\r
2343     arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */\r
2344   } arm_dct4_instance_f32;\r
2345 \r
2346 \r
2347   /**\r
2348    * @brief  Initialization function for the floating-point DCT4/IDCT4.\r
2349    * @param[in,out] S          points to an instance of floating-point DCT4/IDCT4 structure.\r
2350    * @param[in]     S_RFFT     points to an instance of floating-point RFFT/RIFFT structure.\r
2351    * @param[in]     S_CFFT     points to an instance of floating-point CFFT/CIFFT structure.\r
2352    * @param[in]     N          length of the DCT4.\r
2353    * @param[in]     Nby2       half of the length of the DCT4.\r
2354    * @param[in]     normalize  normalizing factor.\r
2355    * @return      arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length.\r
2356    */\r
2357   arm_status arm_dct4_init_f32(\r
2358   arm_dct4_instance_f32 * S,\r
2359   arm_rfft_instance_f32 * S_RFFT,\r
2360   arm_cfft_radix4_instance_f32 * S_CFFT,\r
2361   uint16_t N,\r
2362   uint16_t Nby2,\r
2363   float32_t normalize);\r
2364 \r
2365 \r
2366   /**\r
2367    * @brief Processing function for the floating-point DCT4/IDCT4.\r
2368    * @param[in]     S              points to an instance of the floating-point DCT4/IDCT4 structure.\r
2369    * @param[in]     pState         points to state buffer.\r
2370    * @param[in,out] pInlineBuffer  points to the in-place input and output buffer.\r
2371    */\r
2372   void arm_dct4_f32(\r
2373   const arm_dct4_instance_f32 * S,\r
2374   float32_t * pState,\r
2375   float32_t * pInlineBuffer);\r
2376 \r
2377 \r
2378   /**\r
2379    * @brief Instance structure for the Q31 DCT4/IDCT4 function.\r
2380    */\r
2381   typedef struct\r
2382   {\r
2383     uint16_t N;                          /**< length of the DCT4. */\r
2384     uint16_t Nby2;                       /**< half of the length of the DCT4. */\r
2385     q31_t normalize;                     /**< normalizing factor. */\r
2386     q31_t *pTwiddle;                     /**< points to the twiddle factor table. */\r
2387     q31_t *pCosFactor;                   /**< points to the cosFactor table. */\r
2388     arm_rfft_instance_q31 *pRfft;        /**< points to the real FFT instance. */\r
2389     arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */\r
2390   } arm_dct4_instance_q31;\r
2391 \r
2392 \r
2393   /**\r
2394    * @brief  Initialization function for the Q31 DCT4/IDCT4.\r
2395    * @param[in,out] S          points to an instance of Q31 DCT4/IDCT4 structure.\r
2396    * @param[in]     S_RFFT     points to an instance of Q31 RFFT/RIFFT structure\r
2397    * @param[in]     S_CFFT     points to an instance of Q31 CFFT/CIFFT structure\r
2398    * @param[in]     N          length of the DCT4.\r
2399    * @param[in]     Nby2       half of the length of the DCT4.\r
2400    * @param[in]     normalize  normalizing factor.\r
2401    * @return      arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.\r
2402    */\r
2403   arm_status arm_dct4_init_q31(\r
2404   arm_dct4_instance_q31 * S,\r
2405   arm_rfft_instance_q31 * S_RFFT,\r
2406   arm_cfft_radix4_instance_q31 * S_CFFT,\r
2407   uint16_t N,\r
2408   uint16_t Nby2,\r
2409   q31_t normalize);\r
2410 \r
2411 \r
2412   /**\r
2413    * @brief Processing function for the Q31 DCT4/IDCT4.\r
2414    * @param[in]     S              points to an instance of the Q31 DCT4 structure.\r
2415    * @param[in]     pState         points to state buffer.\r
2416    * @param[in,out] pInlineBuffer  points to the in-place input and output buffer.\r
2417    */\r
2418   void arm_dct4_q31(\r
2419   const arm_dct4_instance_q31 * S,\r
2420   q31_t * pState,\r
2421   q31_t * pInlineBuffer);\r
2422 \r
2423 \r
2424   /**\r
2425    * @brief Instance structure for the Q15 DCT4/IDCT4 function.\r
2426    */\r
2427   typedef struct\r
2428   {\r
2429     uint16_t N;                          /**< length of the DCT4. */\r
2430     uint16_t Nby2;                       /**< half of the length of the DCT4. */\r
2431     q15_t normalize;                     /**< normalizing factor. */\r
2432     q15_t *pTwiddle;                     /**< points to the twiddle factor table. */\r
2433     q15_t *pCosFactor;                   /**< points to the cosFactor table. */\r
2434     arm_rfft_instance_q15 *pRfft;        /**< points to the real FFT instance. */\r
2435     arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */\r
2436   } arm_dct4_instance_q15;\r
2437 \r
2438 \r
2439   /**\r
2440    * @brief  Initialization function for the Q15 DCT4/IDCT4.\r
2441    * @param[in,out] S          points to an instance of Q15 DCT4/IDCT4 structure.\r
2442    * @param[in]     S_RFFT     points to an instance of Q15 RFFT/RIFFT structure.\r
2443    * @param[in]     S_CFFT     points to an instance of Q15 CFFT/CIFFT structure.\r
2444    * @param[in]     N          length of the DCT4.\r
2445    * @param[in]     Nby2       half of the length of the DCT4.\r
2446    * @param[in]     normalize  normalizing factor.\r
2447    * @return      arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.\r
2448    */\r
2449   arm_status arm_dct4_init_q15(\r
2450   arm_dct4_instance_q15 * S,\r
2451   arm_rfft_instance_q15 * S_RFFT,\r
2452   arm_cfft_radix4_instance_q15 * S_CFFT,\r
2453   uint16_t N,\r
2454   uint16_t Nby2,\r
2455   q15_t normalize);\r
2456 \r
2457 \r
2458   /**\r
2459    * @brief Processing function for the Q15 DCT4/IDCT4.\r
2460    * @param[in]     S              points to an instance of the Q15 DCT4 structure.\r
2461    * @param[in]     pState         points to state buffer.\r
2462    * @param[in,out] pInlineBuffer  points to the in-place input and output buffer.\r
2463    */\r
2464   void arm_dct4_q15(\r
2465   const arm_dct4_instance_q15 * S,\r
2466   q15_t * pState,\r
2467   q15_t * pInlineBuffer);\r
2468 \r
2469 \r
2470   /**\r
2471    * @brief Floating-point vector addition.\r
2472    * @param[in]  pSrcA      points to the first input vector\r
2473    * @param[in]  pSrcB      points to the second input vector\r
2474    * @param[out] pDst       points to the output vector\r
2475    * @param[in]  blockSize  number of samples in each vector\r
2476    */\r
2477   void arm_add_f32(\r
2478   float32_t * pSrcA,\r
2479   float32_t * pSrcB,\r
2480   float32_t * pDst,\r
2481   uint32_t blockSize);\r
2482 \r
2483 \r
2484   /**\r
2485    * @brief Q7 vector addition.\r
2486    * @param[in]  pSrcA      points to the first input vector\r
2487    * @param[in]  pSrcB      points to the second input vector\r
2488    * @param[out] pDst       points to the output vector\r
2489    * @param[in]  blockSize  number of samples in each vector\r
2490    */\r
2491   void arm_add_q7(\r
2492   q7_t * pSrcA,\r
2493   q7_t * pSrcB,\r
2494   q7_t * pDst,\r
2495   uint32_t blockSize);\r
2496 \r
2497 \r
2498   /**\r
2499    * @brief Q15 vector addition.\r
2500    * @param[in]  pSrcA      points to the first input vector\r
2501    * @param[in]  pSrcB      points to the second input vector\r
2502    * @param[out] pDst       points to the output vector\r
2503    * @param[in]  blockSize  number of samples in each vector\r
2504    */\r
2505   void arm_add_q15(\r
2506   q15_t * pSrcA,\r
2507   q15_t * pSrcB,\r
2508   q15_t * pDst,\r
2509   uint32_t blockSize);\r
2510 \r
2511 \r
2512   /**\r
2513    * @brief Q31 vector addition.\r
2514    * @param[in]  pSrcA      points to the first input vector\r
2515    * @param[in]  pSrcB      points to the second input vector\r
2516    * @param[out] pDst       points to the output vector\r
2517    * @param[in]  blockSize  number of samples in each vector\r
2518    */\r
2519   void arm_add_q31(\r
2520   q31_t * pSrcA,\r
2521   q31_t * pSrcB,\r
2522   q31_t * pDst,\r
2523   uint32_t blockSize);\r
2524 \r
2525 \r
2526   /**\r
2527    * @brief Floating-point vector subtraction.\r
2528    * @param[in]  pSrcA      points to the first input vector\r
2529    * @param[in]  pSrcB      points to the second input vector\r
2530    * @param[out] pDst       points to the output vector\r
2531    * @param[in]  blockSize  number of samples in each vector\r
2532    */\r
2533   void arm_sub_f32(\r
2534   float32_t * pSrcA,\r
2535   float32_t * pSrcB,\r
2536   float32_t * pDst,\r
2537   uint32_t blockSize);\r
2538 \r
2539 \r
2540   /**\r
2541    * @brief Q7 vector subtraction.\r
2542    * @param[in]  pSrcA      points to the first input vector\r
2543    * @param[in]  pSrcB      points to the second input vector\r
2544    * @param[out] pDst       points to the output vector\r
2545    * @param[in]  blockSize  number of samples in each vector\r
2546    */\r
2547   void arm_sub_q7(\r
2548   q7_t * pSrcA,\r
2549   q7_t * pSrcB,\r
2550   q7_t * pDst,\r
2551   uint32_t blockSize);\r
2552 \r
2553 \r
2554   /**\r
2555    * @brief Q15 vector subtraction.\r
2556    * @param[in]  pSrcA      points to the first input vector\r
2557    * @param[in]  pSrcB      points to the second input vector\r
2558    * @param[out] pDst       points to the output vector\r
2559    * @param[in]  blockSize  number of samples in each vector\r
2560    */\r
2561   void arm_sub_q15(\r
2562   q15_t * pSrcA,\r
2563   q15_t * pSrcB,\r
2564   q15_t * pDst,\r
2565   uint32_t blockSize);\r
2566 \r
2567 \r
2568   /**\r
2569    * @brief Q31 vector subtraction.\r
2570    * @param[in]  pSrcA      points to the first input vector\r
2571    * @param[in]  pSrcB      points to the second input vector\r
2572    * @param[out] pDst       points to the output vector\r
2573    * @param[in]  blockSize  number of samples in each vector\r
2574    */\r
2575   void arm_sub_q31(\r
2576   q31_t * pSrcA,\r
2577   q31_t * pSrcB,\r
2578   q31_t * pDst,\r
2579   uint32_t blockSize);\r
2580 \r
2581 \r
2582   /**\r
2583    * @brief Multiplies a floating-point vector by a scalar.\r
2584    * @param[in]  pSrc       points to the input vector\r
2585    * @param[in]  scale      scale factor to be applied\r
2586    * @param[out] pDst       points to the output vector\r
2587    * @param[in]  blockSize  number of samples in the vector\r
2588    */\r
2589   void arm_scale_f32(\r
2590   float32_t * pSrc,\r
2591   float32_t scale,\r
2592   float32_t * pDst,\r
2593   uint32_t blockSize);\r
2594 \r
2595 \r
2596   /**\r
2597    * @brief Multiplies a Q7 vector by a scalar.\r
2598    * @param[in]  pSrc        points to the input vector\r
2599    * @param[in]  scaleFract  fractional portion of the scale value\r
2600    * @param[in]  shift       number of bits to shift the result by\r
2601    * @param[out] pDst        points to the output vector\r
2602    * @param[in]  blockSize   number of samples in the vector\r
2603    */\r
2604   void arm_scale_q7(\r
2605   q7_t * pSrc,\r
2606   q7_t scaleFract,\r
2607   int8_t shift,\r
2608   q7_t * pDst,\r
2609   uint32_t blockSize);\r
2610 \r
2611 \r
2612   /**\r
2613    * @brief Multiplies a Q15 vector by a scalar.\r
2614    * @param[in]  pSrc        points to the input vector\r
2615    * @param[in]  scaleFract  fractional portion of the scale value\r
2616    * @param[in]  shift       number of bits to shift the result by\r
2617    * @param[out] pDst        points to the output vector\r
2618    * @param[in]  blockSize   number of samples in the vector\r
2619    */\r
2620   void arm_scale_q15(\r
2621   q15_t * pSrc,\r
2622   q15_t scaleFract,\r
2623   int8_t shift,\r
2624   q15_t * pDst,\r
2625   uint32_t blockSize);\r
2626 \r
2627 \r
2628   /**\r
2629    * @brief Multiplies a Q31 vector by a scalar.\r
2630    * @param[in]  pSrc        points to the input vector\r
2631    * @param[in]  scaleFract  fractional portion of the scale value\r
2632    * @param[in]  shift       number of bits to shift the result by\r
2633    * @param[out] pDst        points to the output vector\r
2634    * @param[in]  blockSize   number of samples in the vector\r
2635    */\r
2636   void arm_scale_q31(\r
2637   q31_t * pSrc,\r
2638   q31_t scaleFract,\r
2639   int8_t shift,\r
2640   q31_t * pDst,\r
2641   uint32_t blockSize);\r
2642 \r
2643 \r
2644   /**\r
2645    * @brief Q7 vector absolute value.\r
2646    * @param[in]  pSrc       points to the input buffer\r
2647    * @param[out] pDst       points to the output buffer\r
2648    * @param[in]  blockSize  number of samples in each vector\r
2649    */\r
2650   void arm_abs_q7(\r
2651   q7_t * pSrc,\r
2652   q7_t * pDst,\r
2653   uint32_t blockSize);\r
2654 \r
2655 \r
2656   /**\r
2657    * @brief Floating-point vector absolute value.\r
2658    * @param[in]  pSrc       points to the input buffer\r
2659    * @param[out] pDst       points to the output buffer\r
2660    * @param[in]  blockSize  number of samples in each vector\r
2661    */\r
2662   void arm_abs_f32(\r
2663   float32_t * pSrc,\r
2664   float32_t * pDst,\r
2665   uint32_t blockSize);\r
2666 \r
2667 \r
2668   /**\r
2669    * @brief Q15 vector absolute value.\r
2670    * @param[in]  pSrc       points to the input buffer\r
2671    * @param[out] pDst       points to the output buffer\r
2672    * @param[in]  blockSize  number of samples in each vector\r
2673    */\r
2674   void arm_abs_q15(\r
2675   q15_t * pSrc,\r
2676   q15_t * pDst,\r
2677   uint32_t blockSize);\r
2678 \r
2679 \r
2680   /**\r
2681    * @brief Q31 vector absolute value.\r
2682    * @param[in]  pSrc       points to the input buffer\r
2683    * @param[out] pDst       points to the output buffer\r
2684    * @param[in]  blockSize  number of samples in each vector\r
2685    */\r
2686   void arm_abs_q31(\r
2687   q31_t * pSrc,\r
2688   q31_t * pDst,\r
2689   uint32_t blockSize);\r
2690 \r
2691 \r
2692   /**\r
2693    * @brief Dot product of floating-point vectors.\r
2694    * @param[in]  pSrcA      points to the first input vector\r
2695    * @param[in]  pSrcB      points to the second input vector\r
2696    * @param[in]  blockSize  number of samples in each vector\r
2697    * @param[out] result     output result returned here\r
2698    */\r
2699   void arm_dot_prod_f32(\r
2700   float32_t * pSrcA,\r
2701   float32_t * pSrcB,\r
2702   uint32_t blockSize,\r
2703   float32_t * result);\r
2704 \r
2705 \r
2706   /**\r
2707    * @brief Dot product of Q7 vectors.\r
2708    * @param[in]  pSrcA      points to the first input vector\r
2709    * @param[in]  pSrcB      points to the second input vector\r
2710    * @param[in]  blockSize  number of samples in each vector\r
2711    * @param[out] result     output result returned here\r
2712    */\r
2713   void arm_dot_prod_q7(\r
2714   q7_t * pSrcA,\r
2715   q7_t * pSrcB,\r
2716   uint32_t blockSize,\r
2717   q31_t * result);\r
2718 \r
2719 \r
2720   /**\r
2721    * @brief Dot product of Q15 vectors.\r
2722    * @param[in]  pSrcA      points to the first input vector\r
2723    * @param[in]  pSrcB      points to the second input vector\r
2724    * @param[in]  blockSize  number of samples in each vector\r
2725    * @param[out] result     output result returned here\r
2726    */\r
2727   void arm_dot_prod_q15(\r
2728   q15_t * pSrcA,\r
2729   q15_t * pSrcB,\r
2730   uint32_t blockSize,\r
2731   q63_t * result);\r
2732 \r
2733 \r
2734   /**\r
2735    * @brief Dot product of Q31 vectors.\r
2736    * @param[in]  pSrcA      points to the first input vector\r
2737    * @param[in]  pSrcB      points to the second input vector\r
2738    * @param[in]  blockSize  number of samples in each vector\r
2739    * @param[out] result     output result returned here\r
2740    */\r
2741   void arm_dot_prod_q31(\r
2742   q31_t * pSrcA,\r
2743   q31_t * pSrcB,\r
2744   uint32_t blockSize,\r
2745   q63_t * result);\r
2746 \r
2747 \r
2748   /**\r
2749    * @brief  Shifts the elements of a Q7 vector a specified number of bits.\r
2750    * @param[in]  pSrc       points to the input vector\r
2751    * @param[in]  shiftBits  number of bits to shift.  A positive value shifts left; a negative value shifts right.\r
2752    * @param[out] pDst       points to the output vector\r
2753    * @param[in]  blockSize  number of samples in the vector\r
2754    */\r
2755   void arm_shift_q7(\r
2756   q7_t * pSrc,\r
2757   int8_t shiftBits,\r
2758   q7_t * pDst,\r
2759   uint32_t blockSize);\r
2760 \r
2761 \r
2762   /**\r
2763    * @brief  Shifts the elements of a Q15 vector a specified number of bits.\r
2764    * @param[in]  pSrc       points to the input vector\r
2765    * @param[in]  shiftBits  number of bits to shift.  A positive value shifts left; a negative value shifts right.\r
2766    * @param[out] pDst       points to the output vector\r
2767    * @param[in]  blockSize  number of samples in the vector\r
2768    */\r
2769   void arm_shift_q15(\r
2770   q15_t * pSrc,\r
2771   int8_t shiftBits,\r
2772   q15_t * pDst,\r
2773   uint32_t blockSize);\r
2774 \r
2775 \r
2776   /**\r
2777    * @brief  Shifts the elements of a Q31 vector a specified number of bits.\r
2778    * @param[in]  pSrc       points to the input vector\r
2779    * @param[in]  shiftBits  number of bits to shift.  A positive value shifts left; a negative value shifts right.\r
2780    * @param[out] pDst       points to the output vector\r
2781    * @param[in]  blockSize  number of samples in the vector\r
2782    */\r
2783   void arm_shift_q31(\r
2784   q31_t * pSrc,\r
2785   int8_t shiftBits,\r
2786   q31_t * pDst,\r
2787   uint32_t blockSize);\r
2788 \r
2789 \r
2790   /**\r
2791    * @brief  Adds a constant offset to a floating-point vector.\r
2792    * @param[in]  pSrc       points to the input vector\r
2793    * @param[in]  offset     is the offset to be added\r
2794    * @param[out] pDst       points to the output vector\r
2795    * @param[in]  blockSize  number of samples in the vector\r
2796    */\r
2797   void arm_offset_f32(\r
2798   float32_t * pSrc,\r
2799   float32_t offset,\r
2800   float32_t * pDst,\r
2801   uint32_t blockSize);\r
2802 \r
2803 \r
2804   /**\r
2805    * @brief  Adds a constant offset to a Q7 vector.\r
2806    * @param[in]  pSrc       points to the input vector\r
2807    * @param[in]  offset     is the offset to be added\r
2808    * @param[out] pDst       points to the output vector\r
2809    * @param[in]  blockSize  number of samples in the vector\r
2810    */\r
2811   void arm_offset_q7(\r
2812   q7_t * pSrc,\r
2813   q7_t offset,\r
2814   q7_t * pDst,\r
2815   uint32_t blockSize);\r
2816 \r
2817 \r
2818   /**\r
2819    * @brief  Adds a constant offset to a Q15 vector.\r
2820    * @param[in]  pSrc       points to the input vector\r
2821    * @param[in]  offset     is the offset to be added\r
2822    * @param[out] pDst       points to the output vector\r
2823    * @param[in]  blockSize  number of samples in the vector\r
2824    */\r
2825   void arm_offset_q15(\r
2826   q15_t * pSrc,\r
2827   q15_t offset,\r
2828   q15_t * pDst,\r
2829   uint32_t blockSize);\r
2830 \r
2831 \r
2832   /**\r
2833    * @brief  Adds a constant offset to a Q31 vector.\r
2834    * @param[in]  pSrc       points to the input vector\r
2835    * @param[in]  offset     is the offset to be added\r
2836    * @param[out] pDst       points to the output vector\r
2837    * @param[in]  blockSize  number of samples in the vector\r
2838    */\r
2839   void arm_offset_q31(\r
2840   q31_t * pSrc,\r
2841   q31_t offset,\r
2842   q31_t * pDst,\r
2843   uint32_t blockSize);\r
2844 \r
2845 \r
2846   /**\r
2847    * @brief  Negates the elements of a floating-point vector.\r
2848    * @param[in]  pSrc       points to the input vector\r
2849    * @param[out] pDst       points to the output vector\r
2850    * @param[in]  blockSize  number of samples in the vector\r
2851    */\r
2852   void arm_negate_f32(\r
2853   float32_t * pSrc,\r
2854   float32_t * pDst,\r
2855   uint32_t blockSize);\r
2856 \r
2857 \r
2858   /**\r
2859    * @brief  Negates the elements of a Q7 vector.\r
2860    * @param[in]  pSrc       points to the input vector\r
2861    * @param[out] pDst       points to the output vector\r
2862    * @param[in]  blockSize  number of samples in the vector\r
2863    */\r
2864   void arm_negate_q7(\r
2865   q7_t * pSrc,\r
2866   q7_t * pDst,\r
2867   uint32_t blockSize);\r
2868 \r
2869 \r
2870   /**\r
2871    * @brief  Negates the elements of a Q15 vector.\r
2872    * @param[in]  pSrc       points to the input vector\r
2873    * @param[out] pDst       points to the output vector\r
2874    * @param[in]  blockSize  number of samples in the vector\r
2875    */\r
2876   void arm_negate_q15(\r
2877   q15_t * pSrc,\r
2878   q15_t * pDst,\r
2879   uint32_t blockSize);\r
2880 \r
2881 \r
2882   /**\r
2883    * @brief  Negates the elements of a Q31 vector.\r
2884    * @param[in]  pSrc       points to the input vector\r
2885    * @param[out] pDst       points to the output vector\r
2886    * @param[in]  blockSize  number of samples in the vector\r
2887    */\r
2888   void arm_negate_q31(\r
2889   q31_t * pSrc,\r
2890   q31_t * pDst,\r
2891   uint32_t blockSize);\r
2892 \r
2893 \r
2894   /**\r
2895    * @brief  Copies the elements of a floating-point vector.\r
2896    * @param[in]  pSrc       input pointer\r
2897    * @param[out] pDst       output pointer\r
2898    * @param[in]  blockSize  number of samples to process\r
2899    */\r
2900   void arm_copy_f32(\r
2901   float32_t * pSrc,\r
2902   float32_t * pDst,\r
2903   uint32_t blockSize);\r
2904 \r
2905 \r
2906   /**\r
2907    * @brief  Copies the elements of a Q7 vector.\r
2908    * @param[in]  pSrc       input pointer\r
2909    * @param[out] pDst       output pointer\r
2910    * @param[in]  blockSize  number of samples to process\r
2911    */\r
2912   void arm_copy_q7(\r
2913   q7_t * pSrc,\r
2914   q7_t * pDst,\r
2915   uint32_t blockSize);\r
2916 \r
2917 \r
2918   /**\r
2919    * @brief  Copies the elements of a Q15 vector.\r
2920    * @param[in]  pSrc       input pointer\r
2921    * @param[out] pDst       output pointer\r
2922    * @param[in]  blockSize  number of samples to process\r
2923    */\r
2924   void arm_copy_q15(\r
2925   q15_t * pSrc,\r
2926   q15_t * pDst,\r
2927   uint32_t blockSize);\r
2928 \r
2929 \r
2930   /**\r
2931    * @brief  Copies the elements of a Q31 vector.\r
2932    * @param[in]  pSrc       input pointer\r
2933    * @param[out] pDst       output pointer\r
2934    * @param[in]  blockSize  number of samples to process\r
2935    */\r
2936   void arm_copy_q31(\r
2937   q31_t * pSrc,\r
2938   q31_t * pDst,\r
2939   uint32_t blockSize);\r
2940 \r
2941 \r
2942   /**\r
2943    * @brief  Fills a constant value into a floating-point vector.\r
2944    * @param[in]  value      input value to be filled\r
2945    * @param[out] pDst       output pointer\r
2946    * @param[in]  blockSize  number of samples to process\r
2947    */\r
2948   void arm_fill_f32(\r
2949   float32_t value,\r
2950   float32_t * pDst,\r
2951   uint32_t blockSize);\r
2952 \r
2953 \r
2954   /**\r
2955    * @brief  Fills a constant value into a Q7 vector.\r
2956    * @param[in]  value      input value to be filled\r
2957    * @param[out] pDst       output pointer\r
2958    * @param[in]  blockSize  number of samples to process\r
2959    */\r
2960   void arm_fill_q7(\r
2961   q7_t value,\r
2962   q7_t * pDst,\r
2963   uint32_t blockSize);\r
2964 \r
2965 \r
2966   /**\r
2967    * @brief  Fills a constant value into a Q15 vector.\r
2968    * @param[in]  value      input value to be filled\r
2969    * @param[out] pDst       output pointer\r
2970    * @param[in]  blockSize  number of samples to process\r
2971    */\r
2972   void arm_fill_q15(\r
2973   q15_t value,\r
2974   q15_t * pDst,\r
2975   uint32_t blockSize);\r
2976 \r
2977 \r
2978   /**\r
2979    * @brief  Fills a constant value into a Q31 vector.\r
2980    * @param[in]  value      input value to be filled\r
2981    * @param[out] pDst       output pointer\r
2982    * @param[in]  blockSize  number of samples to process\r
2983    */\r
2984   void arm_fill_q31(\r
2985   q31_t value,\r
2986   q31_t * pDst,\r
2987   uint32_t blockSize);\r
2988 \r
2989 \r
2990 /**\r
2991  * @brief Convolution of floating-point sequences.\r
2992  * @param[in]  pSrcA    points to the first input sequence.\r
2993  * @param[in]  srcALen  length of the first input sequence.\r
2994  * @param[in]  pSrcB    points to the second input sequence.\r
2995  * @param[in]  srcBLen  length of the second input sequence.\r
2996  * @param[out] pDst     points to the location where the output result is written.  Length srcALen+srcBLen-1.\r
2997  */\r
2998   void arm_conv_f32(\r
2999   float32_t * pSrcA,\r
3000   uint32_t srcALen,\r
3001   float32_t * pSrcB,\r
3002   uint32_t srcBLen,\r
3003   float32_t * pDst);\r
3004 \r
3005 \r
3006   /**\r
3007    * @brief Convolution of Q15 sequences.\r
3008    * @param[in]  pSrcA      points to the first input sequence.\r
3009    * @param[in]  srcALen    length of the first input sequence.\r
3010    * @param[in]  pSrcB      points to the second input sequence.\r
3011    * @param[in]  srcBLen    length of the second input sequence.\r
3012    * @param[out] pDst       points to the block of output data  Length srcALen+srcBLen-1.\r
3013    * @param[in]  pScratch1  points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
3014    * @param[in]  pScratch2  points to scratch buffer of size min(srcALen, srcBLen).\r
3015    */\r
3016   void arm_conv_opt_q15(\r
3017   q15_t * pSrcA,\r
3018   uint32_t srcALen,\r
3019   q15_t * pSrcB,\r
3020   uint32_t srcBLen,\r
3021   q15_t * pDst,\r
3022   q15_t * pScratch1,\r
3023   q15_t * pScratch2);\r
3024 \r
3025 \r
3026 /**\r
3027  * @brief Convolution of Q15 sequences.\r
3028  * @param[in]  pSrcA    points to the first input sequence.\r
3029  * @param[in]  srcALen  length of the first input sequence.\r
3030  * @param[in]  pSrcB    points to the second input sequence.\r
3031  * @param[in]  srcBLen  length of the second input sequence.\r
3032  * @param[out] pDst     points to the location where the output result is written.  Length srcALen+srcBLen-1.\r
3033  */\r
3034   void arm_conv_q15(\r
3035   q15_t * pSrcA,\r
3036   uint32_t srcALen,\r
3037   q15_t * pSrcB,\r
3038   uint32_t srcBLen,\r
3039   q15_t * pDst);\r
3040 \r
3041 \r
3042   /**\r
3043    * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4\r
3044    * @param[in]  pSrcA    points to the first input sequence.\r
3045    * @param[in]  srcALen  length of the first input sequence.\r
3046    * @param[in]  pSrcB    points to the second input sequence.\r
3047    * @param[in]  srcBLen  length of the second input sequence.\r
3048    * @param[out] pDst     points to the block of output data  Length srcALen+srcBLen-1.\r
3049    */\r
3050   void arm_conv_fast_q15(\r
3051           q15_t * pSrcA,\r
3052           uint32_t srcALen,\r
3053           q15_t * pSrcB,\r
3054           uint32_t srcBLen,\r
3055           q15_t * pDst);\r
3056 \r
3057 \r
3058   /**\r
3059    * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4\r
3060    * @param[in]  pSrcA      points to the first input sequence.\r
3061    * @param[in]  srcALen    length of the first input sequence.\r
3062    * @param[in]  pSrcB      points to the second input sequence.\r
3063    * @param[in]  srcBLen    length of the second input sequence.\r
3064    * @param[out] pDst       points to the block of output data  Length srcALen+srcBLen-1.\r
3065    * @param[in]  pScratch1  points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
3066    * @param[in]  pScratch2  points to scratch buffer of size min(srcALen, srcBLen).\r
3067    */\r
3068   void arm_conv_fast_opt_q15(\r
3069   q15_t * pSrcA,\r
3070   uint32_t srcALen,\r
3071   q15_t * pSrcB,\r
3072   uint32_t srcBLen,\r
3073   q15_t * pDst,\r
3074   q15_t * pScratch1,\r
3075   q15_t * pScratch2);\r
3076 \r
3077 \r
3078   /**\r
3079    * @brief Convolution of Q31 sequences.\r
3080    * @param[in]  pSrcA    points to the first input sequence.\r
3081    * @param[in]  srcALen  length of the first input sequence.\r
3082    * @param[in]  pSrcB    points to the second input sequence.\r
3083    * @param[in]  srcBLen  length of the second input sequence.\r
3084    * @param[out] pDst     points to the block of output data  Length srcALen+srcBLen-1.\r
3085    */\r
3086   void arm_conv_q31(\r
3087   q31_t * pSrcA,\r
3088   uint32_t srcALen,\r
3089   q31_t * pSrcB,\r
3090   uint32_t srcBLen,\r
3091   q31_t * pDst);\r
3092 \r
3093 \r
3094   /**\r
3095    * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4\r
3096    * @param[in]  pSrcA    points to the first input sequence.\r
3097    * @param[in]  srcALen  length of the first input sequence.\r
3098    * @param[in]  pSrcB    points to the second input sequence.\r
3099    * @param[in]  srcBLen  length of the second input sequence.\r
3100    * @param[out] pDst     points to the block of output data  Length srcALen+srcBLen-1.\r
3101    */\r
3102   void arm_conv_fast_q31(\r
3103   q31_t * pSrcA,\r
3104   uint32_t srcALen,\r
3105   q31_t * pSrcB,\r
3106   uint32_t srcBLen,\r
3107   q31_t * pDst);\r
3108 \r
3109 \r
3110     /**\r
3111    * @brief Convolution of Q7 sequences.\r
3112    * @param[in]  pSrcA      points to the first input sequence.\r
3113    * @param[in]  srcALen    length of the first input sequence.\r
3114    * @param[in]  pSrcB      points to the second input sequence.\r
3115    * @param[in]  srcBLen    length of the second input sequence.\r
3116    * @param[out] pDst       points to the block of output data  Length srcALen+srcBLen-1.\r
3117    * @param[in]  pScratch1  points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
3118    * @param[in]  pScratch2  points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).\r
3119    */\r
3120   void arm_conv_opt_q7(\r
3121   q7_t * pSrcA,\r
3122   uint32_t srcALen,\r
3123   q7_t * pSrcB,\r
3124   uint32_t srcBLen,\r
3125   q7_t * pDst,\r
3126   q15_t * pScratch1,\r
3127   q15_t * pScratch2);\r
3128 \r
3129 \r
3130   /**\r
3131    * @brief Convolution of Q7 sequences.\r
3132    * @param[in]  pSrcA    points to the first input sequence.\r
3133    * @param[in]  srcALen  length of the first input sequence.\r
3134    * @param[in]  pSrcB    points to the second input sequence.\r
3135    * @param[in]  srcBLen  length of the second input sequence.\r
3136    * @param[out] pDst     points to the block of output data  Length srcALen+srcBLen-1.\r
3137    */\r
3138   void arm_conv_q7(\r
3139   q7_t * pSrcA,\r
3140   uint32_t srcALen,\r
3141   q7_t * pSrcB,\r
3142   uint32_t srcBLen,\r
3143   q7_t * pDst);\r
3144 \r
3145 \r
3146   /**\r
3147    * @brief Partial convolution of floating-point sequences.\r
3148    * @param[in]  pSrcA       points to the first input sequence.\r
3149    * @param[in]  srcALen     length of the first input sequence.\r
3150    * @param[in]  pSrcB       points to the second input sequence.\r
3151    * @param[in]  srcBLen     length of the second input sequence.\r
3152    * @param[out] pDst        points to the block of output data\r
3153    * @param[in]  firstIndex  is the first output sample to start with.\r
3154    * @param[in]  numPoints   is the number of output points to be computed.\r
3155    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3156    */\r
3157   arm_status arm_conv_partial_f32(\r
3158   float32_t * pSrcA,\r
3159   uint32_t srcALen,\r
3160   float32_t * pSrcB,\r
3161   uint32_t srcBLen,\r
3162   float32_t * pDst,\r
3163   uint32_t firstIndex,\r
3164   uint32_t numPoints);\r
3165 \r
3166 \r
3167   /**\r
3168    * @brief Partial convolution of Q15 sequences.\r
3169    * @param[in]  pSrcA       points to the first input sequence.\r
3170    * @param[in]  srcALen     length of the first input sequence.\r
3171    * @param[in]  pSrcB       points to the second input sequence.\r
3172    * @param[in]  srcBLen     length of the second input sequence.\r
3173    * @param[out] pDst        points to the block of output data\r
3174    * @param[in]  firstIndex  is the first output sample to start with.\r
3175    * @param[in]  numPoints   is the number of output points to be computed.\r
3176    * @param[in]  pScratch1   points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
3177    * @param[in]  pScratch2   points to scratch buffer of size min(srcALen, srcBLen).\r
3178    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3179    */\r
3180   arm_status arm_conv_partial_opt_q15(\r
3181   q15_t * pSrcA,\r
3182   uint32_t srcALen,\r
3183   q15_t * pSrcB,\r
3184   uint32_t srcBLen,\r
3185   q15_t * pDst,\r
3186   uint32_t firstIndex,\r
3187   uint32_t numPoints,\r
3188   q15_t * pScratch1,\r
3189   q15_t * pScratch2);\r
3190 \r
3191 \r
3192   /**\r
3193    * @brief Partial convolution of Q15 sequences.\r
3194    * @param[in]  pSrcA       points to the first input sequence.\r
3195    * @param[in]  srcALen     length of the first input sequence.\r
3196    * @param[in]  pSrcB       points to the second input sequence.\r
3197    * @param[in]  srcBLen     length of the second input sequence.\r
3198    * @param[out] pDst        points to the block of output data\r
3199    * @param[in]  firstIndex  is the first output sample to start with.\r
3200    * @param[in]  numPoints   is the number of output points to be computed.\r
3201    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3202    */\r
3203   arm_status arm_conv_partial_q15(\r
3204   q15_t * pSrcA,\r
3205   uint32_t srcALen,\r
3206   q15_t * pSrcB,\r
3207   uint32_t srcBLen,\r
3208   q15_t * pDst,\r
3209   uint32_t firstIndex,\r
3210   uint32_t numPoints);\r
3211 \r
3212 \r
3213   /**\r
3214    * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4\r
3215    * @param[in]  pSrcA       points to the first input sequence.\r
3216    * @param[in]  srcALen     length of the first input sequence.\r
3217    * @param[in]  pSrcB       points to the second input sequence.\r
3218    * @param[in]  srcBLen     length of the second input sequence.\r
3219    * @param[out] pDst        points to the block of output data\r
3220    * @param[in]  firstIndex  is the first output sample to start with.\r
3221    * @param[in]  numPoints   is the number of output points to be computed.\r
3222    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3223    */\r
3224   arm_status arm_conv_partial_fast_q15(\r
3225   q15_t * pSrcA,\r
3226   uint32_t srcALen,\r
3227   q15_t * pSrcB,\r
3228   uint32_t srcBLen,\r
3229   q15_t * pDst,\r
3230   uint32_t firstIndex,\r
3231   uint32_t numPoints);\r
3232 \r
3233 \r
3234   /**\r
3235    * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4\r
3236    * @param[in]  pSrcA       points to the first input sequence.\r
3237    * @param[in]  srcALen     length of the first input sequence.\r
3238    * @param[in]  pSrcB       points to the second input sequence.\r
3239    * @param[in]  srcBLen     length of the second input sequence.\r
3240    * @param[out] pDst        points to the block of output data\r
3241    * @param[in]  firstIndex  is the first output sample to start with.\r
3242    * @param[in]  numPoints   is the number of output points to be computed.\r
3243    * @param[in]  pScratch1   points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
3244    * @param[in]  pScratch2   points to scratch buffer of size min(srcALen, srcBLen).\r
3245    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3246    */\r
3247   arm_status arm_conv_partial_fast_opt_q15(\r
3248   q15_t * pSrcA,\r
3249   uint32_t srcALen,\r
3250   q15_t * pSrcB,\r
3251   uint32_t srcBLen,\r
3252   q15_t * pDst,\r
3253   uint32_t firstIndex,\r
3254   uint32_t numPoints,\r
3255   q15_t * pScratch1,\r
3256   q15_t * pScratch2);\r
3257 \r
3258 \r
3259   /**\r
3260    * @brief Partial convolution of Q31 sequences.\r
3261    * @param[in]  pSrcA       points to the first input sequence.\r
3262    * @param[in]  srcALen     length of the first input sequence.\r
3263    * @param[in]  pSrcB       points to the second input sequence.\r
3264    * @param[in]  srcBLen     length of the second input sequence.\r
3265    * @param[out] pDst        points to the block of output data\r
3266    * @param[in]  firstIndex  is the first output sample to start with.\r
3267    * @param[in]  numPoints   is the number of output points to be computed.\r
3268    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3269    */\r
3270   arm_status arm_conv_partial_q31(\r
3271   q31_t * pSrcA,\r
3272   uint32_t srcALen,\r
3273   q31_t * pSrcB,\r
3274   uint32_t srcBLen,\r
3275   q31_t * pDst,\r
3276   uint32_t firstIndex,\r
3277   uint32_t numPoints);\r
3278 \r
3279 \r
3280   /**\r
3281    * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4\r
3282    * @param[in]  pSrcA       points to the first input sequence.\r
3283    * @param[in]  srcALen     length of the first input sequence.\r
3284    * @param[in]  pSrcB       points to the second input sequence.\r
3285    * @param[in]  srcBLen     length of the second input sequence.\r
3286    * @param[out] pDst        points to the block of output data\r
3287    * @param[in]  firstIndex  is the first output sample to start with.\r
3288    * @param[in]  numPoints   is the number of output points to be computed.\r
3289    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3290    */\r
3291   arm_status arm_conv_partial_fast_q31(\r
3292   q31_t * pSrcA,\r
3293   uint32_t srcALen,\r
3294   q31_t * pSrcB,\r
3295   uint32_t srcBLen,\r
3296   q31_t * pDst,\r
3297   uint32_t firstIndex,\r
3298   uint32_t numPoints);\r
3299 \r
3300 \r
3301   /**\r
3302    * @brief Partial convolution of Q7 sequences\r
3303    * @param[in]  pSrcA       points to the first input sequence.\r
3304    * @param[in]  srcALen     length of the first input sequence.\r
3305    * @param[in]  pSrcB       points to the second input sequence.\r
3306    * @param[in]  srcBLen     length of the second input sequence.\r
3307    * @param[out] pDst        points to the block of output data\r
3308    * @param[in]  firstIndex  is the first output sample to start with.\r
3309    * @param[in]  numPoints   is the number of output points to be computed.\r
3310    * @param[in]  pScratch1   points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
3311    * @param[in]  pScratch2   points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).\r
3312    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3313    */\r
3314   arm_status arm_conv_partial_opt_q7(\r
3315   q7_t * pSrcA,\r
3316   uint32_t srcALen,\r
3317   q7_t * pSrcB,\r
3318   uint32_t srcBLen,\r
3319   q7_t * pDst,\r
3320   uint32_t firstIndex,\r
3321   uint32_t numPoints,\r
3322   q15_t * pScratch1,\r
3323   q15_t * pScratch2);\r
3324 \r
3325 \r
3326 /**\r
3327    * @brief Partial convolution of Q7 sequences.\r
3328    * @param[in]  pSrcA       points to the first input sequence.\r
3329    * @param[in]  srcALen     length of the first input sequence.\r
3330    * @param[in]  pSrcB       points to the second input sequence.\r
3331    * @param[in]  srcBLen     length of the second input sequence.\r
3332    * @param[out] pDst        points to the block of output data\r
3333    * @param[in]  firstIndex  is the first output sample to start with.\r
3334    * @param[in]  numPoints   is the number of output points to be computed.\r
3335    * @return  Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].\r
3336    */\r
3337   arm_status arm_conv_partial_q7(\r
3338   q7_t * pSrcA,\r
3339   uint32_t srcALen,\r
3340   q7_t * pSrcB,\r
3341   uint32_t srcBLen,\r
3342   q7_t * pDst,\r
3343   uint32_t firstIndex,\r
3344   uint32_t numPoints);\r
3345 \r
3346 \r
3347   /**\r
3348    * @brief Instance structure for the Q15 FIR decimator.\r
3349    */\r
3350   typedef struct\r
3351   {\r
3352     uint8_t M;                  /**< decimation factor. */\r
3353     uint16_t numTaps;           /**< number of coefficients in the filter. */\r
3354     q15_t *pCoeffs;             /**< points to the coefficient array. The array is of length numTaps.*/\r
3355     q15_t *pState;              /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
3356   } arm_fir_decimate_instance_q15;\r
3357 \r
3358   /**\r
3359    * @brief Instance structure for the Q31 FIR decimator.\r
3360    */\r
3361   typedef struct\r
3362   {\r
3363     uint8_t M;                  /**< decimation factor. */\r
3364     uint16_t numTaps;           /**< number of coefficients in the filter. */\r
3365     q31_t *pCoeffs;             /**< points to the coefficient array. The array is of length numTaps.*/\r
3366     q31_t *pState;              /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
3367   } arm_fir_decimate_instance_q31;\r
3368 \r
3369   /**\r
3370    * @brief Instance structure for the floating-point FIR decimator.\r
3371    */\r
3372   typedef struct\r
3373   {\r
3374     uint8_t M;                  /**< decimation factor. */\r
3375     uint16_t numTaps;           /**< number of coefficients in the filter. */\r
3376     float32_t *pCoeffs;         /**< points to the coefficient array. The array is of length numTaps.*/\r
3377     float32_t *pState;          /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
3378   } arm_fir_decimate_instance_f32;\r
3379 \r
3380 \r
3381   /**\r
3382    * @brief Processing function for the floating-point FIR decimator.\r
3383    * @param[in]  S          points to an instance of the floating-point FIR decimator structure.\r
3384    * @param[in]  pSrc       points to the block of input data.\r
3385    * @param[out] pDst       points to the block of output data\r
3386    * @param[in]  blockSize  number of input samples to process per call.\r
3387    */\r
3388   void arm_fir_decimate_f32(\r
3389   const arm_fir_decimate_instance_f32 * S,\r
3390   float32_t * pSrc,\r
3391   float32_t * pDst,\r
3392   uint32_t blockSize);\r
3393 \r
3394 \r
3395   /**\r
3396    * @brief  Initialization function for the floating-point FIR decimator.\r
3397    * @param[in,out] S          points to an instance of the floating-point FIR decimator structure.\r
3398    * @param[in]     numTaps    number of coefficients in the filter.\r
3399    * @param[in]     M          decimation factor.\r
3400    * @param[in]     pCoeffs    points to the filter coefficients.\r
3401    * @param[in]     pState     points to the state buffer.\r
3402    * @param[in]     blockSize  number of input samples to process per call.\r
3403    * @return    The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if\r
3404    * <code>blockSize</code> is not a multiple of <code>M</code>.\r
3405    */\r
3406   arm_status arm_fir_decimate_init_f32(\r
3407   arm_fir_decimate_instance_f32 * S,\r
3408   uint16_t numTaps,\r
3409   uint8_t M,\r
3410   float32_t * pCoeffs,\r
3411   float32_t * pState,\r
3412   uint32_t blockSize);\r
3413 \r
3414 \r
3415   /**\r
3416    * @brief Processing function for the Q15 FIR decimator.\r
3417    * @param[in]  S          points to an instance of the Q15 FIR decimator structure.\r
3418    * @param[in]  pSrc       points to the block of input data.\r
3419    * @param[out] pDst       points to the block of output data\r
3420    * @param[in]  blockSize  number of input samples to process per call.\r
3421    */\r
3422   void arm_fir_decimate_q15(\r
3423   const arm_fir_decimate_instance_q15 * S,\r
3424   q15_t * pSrc,\r
3425   q15_t * pDst,\r
3426   uint32_t blockSize);\r
3427 \r
3428 \r
3429   /**\r
3430    * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.\r
3431    * @param[in]  S          points to an instance of the Q15 FIR decimator structure.\r
3432    * @param[in]  pSrc       points to the block of input data.\r
3433    * @param[out] pDst       points to the block of output data\r
3434    * @param[in]  blockSize  number of input samples to process per call.\r
3435    */\r
3436   void arm_fir_decimate_fast_q15(\r
3437   const arm_fir_decimate_instance_q15 * S,\r
3438   q15_t * pSrc,\r
3439   q15_t * pDst,\r
3440   uint32_t blockSize);\r
3441 \r
3442 \r
3443   /**\r
3444    * @brief  Initialization function for the Q15 FIR decimator.\r
3445    * @param[in,out] S          points to an instance of the Q15 FIR decimator structure.\r
3446    * @param[in]     numTaps    number of coefficients in the filter.\r
3447    * @param[in]     M          decimation factor.\r
3448    * @param[in]     pCoeffs    points to the filter coefficients.\r
3449    * @param[in]     pState     points to the state buffer.\r
3450    * @param[in]     blockSize  number of input samples to process per call.\r
3451    * @return    The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if\r
3452    * <code>blockSize</code> is not a multiple of <code>M</code>.\r
3453    */\r
3454   arm_status arm_fir_decimate_init_q15(\r
3455   arm_fir_decimate_instance_q15 * S,\r
3456   uint16_t numTaps,\r
3457   uint8_t M,\r
3458   q15_t * pCoeffs,\r
3459   q15_t * pState,\r
3460   uint32_t blockSize);\r
3461 \r
3462 \r
3463   /**\r
3464    * @brief Processing function for the Q31 FIR decimator.\r
3465    * @param[in]  S     points to an instance of the Q31 FIR decimator structure.\r
3466    * @param[in]  pSrc  points to the block of input data.\r
3467    * @param[out] pDst  points to the block of output data\r
3468    * @param[in] blockSize number of input samples to process per call.\r
3469    */\r
3470   void arm_fir_decimate_q31(\r
3471   const arm_fir_decimate_instance_q31 * S,\r
3472   q31_t * pSrc,\r
3473   q31_t * pDst,\r
3474   uint32_t blockSize);\r
3475 \r
3476   /**\r
3477    * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.\r
3478    * @param[in]  S          points to an instance of the Q31 FIR decimator structure.\r
3479    * @param[in]  pSrc       points to the block of input data.\r
3480    * @param[out] pDst       points to the block of output data\r
3481    * @param[in]  blockSize  number of input samples to process per call.\r
3482    */\r
3483   void arm_fir_decimate_fast_q31(\r
3484   arm_fir_decimate_instance_q31 * S,\r
3485   q31_t * pSrc,\r
3486   q31_t * pDst,\r
3487   uint32_t blockSize);\r
3488 \r
3489 \r
3490   /**\r
3491    * @brief  Initialization function for the Q31 FIR decimator.\r
3492    * @param[in,out] S          points to an instance of the Q31 FIR decimator structure.\r
3493    * @param[in]     numTaps    number of coefficients in the filter.\r
3494    * @param[in]     M          decimation factor.\r
3495    * @param[in]     pCoeffs    points to the filter coefficients.\r
3496    * @param[in]     pState     points to the state buffer.\r
3497    * @param[in]     blockSize  number of input samples to process per call.\r
3498    * @return    The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if\r
3499    * <code>blockSize</code> is not a multiple of <code>M</code>.\r
3500    */\r
3501   arm_status arm_fir_decimate_init_q31(\r
3502   arm_fir_decimate_instance_q31 * S,\r
3503   uint16_t numTaps,\r
3504   uint8_t M,\r
3505   q31_t * pCoeffs,\r
3506   q31_t * pState,\r
3507   uint32_t blockSize);\r
3508 \r
3509 \r
3510   /**\r
3511    * @brief Instance structure for the Q15 FIR interpolator.\r
3512    */\r
3513   typedef struct\r
3514   {\r
3515     uint8_t L;                      /**< upsample factor. */\r
3516     uint16_t phaseLength;           /**< length of each polyphase filter component. */\r
3517     q15_t *pCoeffs;                 /**< points to the coefficient array. The array is of length L*phaseLength. */\r
3518     q15_t *pState;                  /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */\r
3519   } arm_fir_interpolate_instance_q15;\r
3520 \r
3521   /**\r
3522    * @brief Instance structure for the Q31 FIR interpolator.\r
3523    */\r
3524   typedef struct\r
3525   {\r
3526     uint8_t L;                      /**< upsample factor. */\r
3527     uint16_t phaseLength;           /**< length of each polyphase filter component. */\r
3528     q31_t *pCoeffs;                 /**< points to the coefficient array. The array is of length L*phaseLength. */\r
3529     q31_t *pState;                  /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */\r
3530   } arm_fir_interpolate_instance_q31;\r
3531 \r
3532   /**\r
3533    * @brief Instance structure for the floating-point FIR interpolator.\r
3534    */\r
3535   typedef struct\r
3536   {\r
3537     uint8_t L;                     /**< upsample factor. */\r
3538     uint16_t phaseLength;          /**< length of each polyphase filter component. */\r
3539     float32_t *pCoeffs;            /**< points to the coefficient array. The array is of length L*phaseLength. */\r
3540     float32_t *pState;             /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */\r
3541   } arm_fir_interpolate_instance_f32;\r
3542 \r
3543 \r
3544   /**\r
3545    * @brief Processing function for the Q15 FIR interpolator.\r
3546    * @param[in]  S          points to an instance of the Q15 FIR interpolator structure.\r
3547    * @param[in]  pSrc       points to the block of input data.\r
3548    * @param[out] pDst       points to the block of output data.\r
3549    * @param[in]  blockSize  number of input samples to process per call.\r
3550    */\r
3551   void arm_fir_interpolate_q15(\r
3552   const arm_fir_interpolate_instance_q15 * S,\r
3553   q15_t * pSrc,\r
3554   q15_t * pDst,\r
3555   uint32_t blockSize);\r
3556 \r
3557 \r
3558   /**\r
3559    * @brief  Initialization function for the Q15 FIR interpolator.\r
3560    * @param[in,out] S          points to an instance of the Q15 FIR interpolator structure.\r
3561    * @param[in]     L          upsample factor.\r
3562    * @param[in]     numTaps    number of filter coefficients in the filter.\r
3563    * @param[in]     pCoeffs    points to the filter coefficient buffer.\r
3564    * @param[in]     pState     points to the state buffer.\r
3565    * @param[in]     blockSize  number of input samples to process per call.\r
3566    * @return        The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if\r
3567    * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.\r
3568    */\r
3569   arm_status arm_fir_interpolate_init_q15(\r
3570   arm_fir_interpolate_instance_q15 * S,\r
3571   uint8_t L,\r
3572   uint16_t numTaps,\r
3573   q15_t * pCoeffs,\r
3574   q15_t * pState,\r
3575   uint32_t blockSize);\r
3576 \r
3577 \r
3578   /**\r
3579    * @brief Processing function for the Q31 FIR interpolator.\r
3580    * @param[in]  S          points to an instance of the Q15 FIR interpolator structure.\r
3581    * @param[in]  pSrc       points to the block of input data.\r
3582    * @param[out] pDst       points to the block of output data.\r
3583    * @param[in]  blockSize  number of input samples to process per call.\r
3584    */\r
3585   void arm_fir_interpolate_q31(\r
3586   const arm_fir_interpolate_instance_q31 * S,\r
3587   q31_t * pSrc,\r
3588   q31_t * pDst,\r
3589   uint32_t blockSize);\r
3590 \r
3591 \r
3592   /**\r
3593    * @brief  Initialization function for the Q31 FIR interpolator.\r
3594    * @param[in,out] S          points to an instance of the Q31 FIR interpolator structure.\r
3595    * @param[in]     L          upsample factor.\r
3596    * @param[in]     numTaps    number of filter coefficients in the filter.\r
3597    * @param[in]     pCoeffs    points to the filter coefficient buffer.\r
3598    * @param[in]     pState     points to the state buffer.\r
3599    * @param[in]     blockSize  number of input samples to process per call.\r
3600    * @return        The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if\r
3601    * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.\r
3602    */\r
3603   arm_status arm_fir_interpolate_init_q31(\r
3604   arm_fir_interpolate_instance_q31 * S,\r
3605   uint8_t L,\r
3606   uint16_t numTaps,\r
3607   q31_t * pCoeffs,\r
3608   q31_t * pState,\r
3609   uint32_t blockSize);\r
3610 \r
3611 \r
3612   /**\r
3613    * @brief Processing function for the floating-point FIR interpolator.\r
3614    * @param[in]  S          points to an instance of the floating-point FIR interpolator structure.\r
3615    * @param[in]  pSrc       points to the block of input data.\r
3616    * @param[out] pDst       points to the block of output data.\r
3617    * @param[in]  blockSize  number of input samples to process per call.\r
3618    */\r
3619   void arm_fir_interpolate_f32(\r
3620   const arm_fir_interpolate_instance_f32 * S,\r
3621   float32_t * pSrc,\r
3622   float32_t * pDst,\r
3623   uint32_t blockSize);\r
3624 \r
3625 \r
3626   /**\r
3627    * @brief  Initialization function for the floating-point FIR interpolator.\r
3628    * @param[in,out] S          points to an instance of the floating-point FIR interpolator structure.\r
3629    * @param[in]     L          upsample factor.\r
3630    * @param[in]     numTaps    number of filter coefficients in the filter.\r
3631    * @param[in]     pCoeffs    points to the filter coefficient buffer.\r
3632    * @param[in]     pState     points to the state buffer.\r
3633    * @param[in]     blockSize  number of input samples to process per call.\r
3634    * @return        The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if\r
3635    * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.\r
3636    */\r
3637   arm_status arm_fir_interpolate_init_f32(\r
3638   arm_fir_interpolate_instance_f32 * S,\r
3639   uint8_t L,\r
3640   uint16_t numTaps,\r
3641   float32_t * pCoeffs,\r
3642   float32_t * pState,\r
3643   uint32_t blockSize);\r
3644 \r
3645 \r
3646   /**\r
3647    * @brief Instance structure for the high precision Q31 Biquad cascade filter.\r
3648    */\r
3649   typedef struct\r
3650   {\r
3651     uint8_t numStages;       /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
3652     q63_t *pState;           /**< points to the array of state coefficients.  The array is of length 4*numStages. */\r
3653     q31_t *pCoeffs;          /**< points to the array of coefficients.  The array is of length 5*numStages. */\r
3654     uint8_t postShift;       /**< additional shift, in bits, applied to each output sample. */\r
3655   } arm_biquad_cas_df1_32x64_ins_q31;\r
3656 \r
3657 \r
3658   /**\r
3659    * @param[in]  S          points to an instance of the high precision Q31 Biquad cascade filter structure.\r
3660    * @param[in]  pSrc       points to the block of input data.\r
3661    * @param[out] pDst       points to the block of output data\r
3662    * @param[in]  blockSize  number of samples to process.\r
3663    */\r
3664   void arm_biquad_cas_df1_32x64_q31(\r
3665   const arm_biquad_cas_df1_32x64_ins_q31 * S,\r
3666   q31_t * pSrc,\r
3667   q31_t * pDst,\r
3668   uint32_t blockSize);\r
3669 \r
3670 \r
3671   /**\r
3672    * @param[in,out] S          points to an instance of the high precision Q31 Biquad cascade filter structure.\r
3673    * @param[in]     numStages  number of 2nd order stages in the filter.\r
3674    * @param[in]     pCoeffs    points to the filter coefficients.\r
3675    * @param[in]     pState     points to the state buffer.\r
3676    * @param[in]     postShift  shift to be applied to the output. Varies according to the coefficients format\r
3677    */\r
3678   void arm_biquad_cas_df1_32x64_init_q31(\r
3679   arm_biquad_cas_df1_32x64_ins_q31 * S,\r
3680   uint8_t numStages,\r
3681   q31_t * pCoeffs,\r
3682   q63_t * pState,\r
3683   uint8_t postShift);\r
3684 \r
3685 \r
3686   /**\r
3687    * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.\r
3688    */\r
3689   typedef struct\r
3690   {\r
3691     uint8_t numStages;         /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
3692     float32_t *pState;         /**< points to the array of state coefficients.  The array is of length 2*numStages. */\r
3693     float32_t *pCoeffs;        /**< points to the array of coefficients.  The array is of length 5*numStages. */\r
3694   } arm_biquad_cascade_df2T_instance_f32;\r
3695 \r
3696   /**\r
3697    * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.\r
3698    */\r
3699   typedef struct\r
3700   {\r
3701     uint8_t numStages;         /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
3702     float32_t *pState;         /**< points to the array of state coefficients.  The array is of length 4*numStages. */\r
3703     float32_t *pCoeffs;        /**< points to the array of coefficients.  The array is of length 5*numStages. */\r
3704   } arm_biquad_cascade_stereo_df2T_instance_f32;\r
3705 \r
3706   /**\r
3707    * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.\r
3708    */\r
3709   typedef struct\r
3710   {\r
3711     uint8_t numStages;         /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */\r
3712     float64_t *pState;         /**< points to the array of state coefficients.  The array is of length 2*numStages. */\r
3713     float64_t *pCoeffs;        /**< points to the array of coefficients.  The array is of length 5*numStages. */\r
3714   } arm_biquad_cascade_df2T_instance_f64;\r
3715 \r
3716 \r
3717   /**\r
3718    * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.\r
3719    * @param[in]  S          points to an instance of the filter data structure.\r
3720    * @param[in]  pSrc       points to the block of input data.\r
3721    * @param[out] pDst       points to the block of output data\r
3722    * @param[in]  blockSize  number of samples to process.\r
3723    */\r
3724   void arm_biquad_cascade_df2T_f32(\r
3725   const arm_biquad_cascade_df2T_instance_f32 * S,\r
3726   float32_t * pSrc,\r
3727   float32_t * pDst,\r
3728   uint32_t blockSize);\r
3729 \r
3730 \r
3731   /**\r
3732    * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels\r
3733    * @param[in]  S          points to an instance of the filter data structure.\r
3734    * @param[in]  pSrc       points to the block of input data.\r
3735    * @param[out] pDst       points to the block of output data\r
3736    * @param[in]  blockSize  number of samples to process.\r
3737    */\r
3738   void arm_biquad_cascade_stereo_df2T_f32(\r
3739   const arm_biquad_cascade_stereo_df2T_instance_f32 * S,\r
3740   float32_t * pSrc,\r
3741   float32_t * pDst,\r
3742   uint32_t blockSize);\r
3743 \r
3744 \r
3745   /**\r
3746    * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.\r
3747    * @param[in]  S          points to an instance of the filter data structure.\r
3748    * @param[in]  pSrc       points to the block of input data.\r
3749    * @param[out] pDst       points to the block of output data\r
3750    * @param[in]  blockSize  number of samples to process.\r
3751    */\r
3752   void arm_biquad_cascade_df2T_f64(\r
3753   const arm_biquad_cascade_df2T_instance_f64 * S,\r
3754   float64_t * pSrc,\r
3755   float64_t * pDst,\r
3756   uint32_t blockSize);\r
3757 \r
3758 \r
3759   /**\r
3760    * @brief  Initialization function for the floating-point transposed direct form II Biquad cascade filter.\r
3761    * @param[in,out] S          points to an instance of the filter data structure.\r
3762    * @param[in]     numStages  number of 2nd order stages in the filter.\r
3763    * @param[in]     pCoeffs    points to the filter coefficients.\r
3764    * @param[in]     pState     points to the state buffer.\r
3765    */\r
3766   void arm_biquad_cascade_df2T_init_f32(\r
3767   arm_biquad_cascade_df2T_instance_f32 * S,\r
3768   uint8_t numStages,\r
3769   float32_t * pCoeffs,\r
3770   float32_t * pState);\r
3771 \r
3772 \r
3773   /**\r
3774    * @brief  Initialization function for the floating-point transposed direct form II Biquad cascade filter.\r
3775    * @param[in,out] S          points to an instance of the filter data structure.\r
3776    * @param[in]     numStages  number of 2nd order stages in the filter.\r
3777    * @param[in]     pCoeffs    points to the filter coefficients.\r
3778    * @param[in]     pState     points to the state buffer.\r
3779    */\r
3780   void arm_biquad_cascade_stereo_df2T_init_f32(\r
3781   arm_biquad_cascade_stereo_df2T_instance_f32 * S,\r
3782   uint8_t numStages,\r
3783   float32_t * pCoeffs,\r
3784   float32_t * pState);\r
3785 \r
3786 \r
3787   /**\r
3788    * @brief  Initialization function for the floating-point transposed direct form II Biquad cascade filter.\r
3789    * @param[in,out] S          points to an instance of the filter data structure.\r
3790    * @param[in]     numStages  number of 2nd order stages in the filter.\r
3791    * @param[in]     pCoeffs    points to the filter coefficients.\r
3792    * @param[in]     pState     points to the state buffer.\r
3793    */\r
3794   void arm_biquad_cascade_df2T_init_f64(\r
3795   arm_biquad_cascade_df2T_instance_f64 * S,\r
3796   uint8_t numStages,\r
3797   float64_t * pCoeffs,\r
3798   float64_t * pState);\r
3799 \r
3800 \r
3801   /**\r
3802    * @brief Instance structure for the Q15 FIR lattice filter.\r
3803    */\r
3804   typedef struct\r
3805   {\r
3806     uint16_t numStages;                  /**< number of filter stages. */\r
3807     q15_t *pState;                       /**< points to the state variable array. The array is of length numStages. */\r
3808     q15_t *pCoeffs;                      /**< points to the coefficient array. The array is of length numStages. */\r
3809   } arm_fir_lattice_instance_q15;\r
3810 \r
3811   /**\r
3812    * @brief Instance structure for the Q31 FIR lattice filter.\r
3813    */\r
3814   typedef struct\r
3815   {\r
3816     uint16_t numStages;                  /**< number of filter stages. */\r
3817     q31_t *pState;                       /**< points to the state variable array. The array is of length numStages. */\r
3818     q31_t *pCoeffs;                      /**< points to the coefficient array. The array is of length numStages. */\r
3819   } arm_fir_lattice_instance_q31;\r
3820 \r
3821   /**\r
3822    * @brief Instance structure for the floating-point FIR lattice filter.\r
3823    */\r
3824   typedef struct\r
3825   {\r
3826     uint16_t numStages;                  /**< number of filter stages. */\r
3827     float32_t *pState;                   /**< points to the state variable array. The array is of length numStages. */\r
3828     float32_t *pCoeffs;                  /**< points to the coefficient array. The array is of length numStages. */\r
3829   } arm_fir_lattice_instance_f32;\r
3830 \r
3831 \r
3832   /**\r
3833    * @brief Initialization function for the Q15 FIR lattice filter.\r
3834    * @param[in] S          points to an instance of the Q15 FIR lattice structure.\r
3835    * @param[in] numStages  number of filter stages.\r
3836    * @param[in] pCoeffs    points to the coefficient buffer.  The array is of length numStages.\r
3837    * @param[in] pState     points to the state buffer.  The array is of length numStages.\r
3838    */\r
3839   void arm_fir_lattice_init_q15(\r
3840   arm_fir_lattice_instance_q15 * S,\r
3841   uint16_t numStages,\r
3842   q15_t * pCoeffs,\r
3843   q15_t * pState);\r
3844 \r
3845 \r
3846   /**\r
3847    * @brief Processing function for the Q15 FIR lattice filter.\r
3848    * @param[in]  S          points to an instance of the Q15 FIR lattice structure.\r
3849    * @param[in]  pSrc       points to the block of input data.\r
3850    * @param[out] pDst       points to the block of output data.\r
3851    * @param[in]  blockSize  number of samples to process.\r
3852    */\r
3853   void arm_fir_lattice_q15(\r
3854   const arm_fir_lattice_instance_q15 * S,\r
3855   q15_t * pSrc,\r
3856   q15_t * pDst,\r
3857   uint32_t blockSize);\r
3858 \r
3859 \r
3860   /**\r
3861    * @brief Initialization function for the Q31 FIR lattice filter.\r
3862    * @param[in] S          points to an instance of the Q31 FIR lattice structure.\r
3863    * @param[in] numStages  number of filter stages.\r
3864    * @param[in] pCoeffs    points to the coefficient buffer.  The array is of length numStages.\r
3865    * @param[in] pState     points to the state buffer.   The array is of length numStages.\r
3866    */\r
3867   void arm_fir_lattice_init_q31(\r
3868   arm_fir_lattice_instance_q31 * S,\r
3869   uint16_t numStages,\r
3870   q31_t * pCoeffs,\r
3871   q31_t * pState);\r
3872 \r
3873 \r
3874   /**\r
3875    * @brief Processing function for the Q31 FIR lattice filter.\r
3876    * @param[in]  S          points to an instance of the Q31 FIR lattice structure.\r
3877    * @param[in]  pSrc       points to the block of input data.\r
3878    * @param[out] pDst       points to the block of output data\r
3879    * @param[in]  blockSize  number of samples to process.\r
3880    */\r
3881   void arm_fir_lattice_q31(\r
3882   const arm_fir_lattice_instance_q31 * S,\r
3883   q31_t * pSrc,\r
3884   q31_t * pDst,\r
3885   uint32_t blockSize);\r
3886 \r
3887 \r
3888 /**\r
3889  * @brief Initialization function for the floating-point FIR lattice filter.\r
3890  * @param[in] S          points to an instance of the floating-point FIR lattice structure.\r
3891  * @param[in] numStages  number of filter stages.\r
3892  * @param[in] pCoeffs    points to the coefficient buffer.  The array is of length numStages.\r
3893  * @param[in] pState     points to the state buffer.  The array is of length numStages.\r
3894  */\r
3895   void arm_fir_lattice_init_f32(\r
3896   arm_fir_lattice_instance_f32 * S,\r
3897   uint16_t numStages,\r
3898   float32_t * pCoeffs,\r
3899   float32_t * pState);\r
3900 \r
3901 \r
3902   /**\r
3903    * @brief Processing function for the floating-point FIR lattice filter.\r
3904    * @param[in]  S          points to an instance of the floating-point FIR lattice structure.\r
3905    * @param[in]  pSrc       points to the block of input data.\r
3906    * @param[out] pDst       points to the block of output data\r
3907    * @param[in]  blockSize  number of samples to process.\r
3908    */\r
3909   void arm_fir_lattice_f32(\r
3910   const arm_fir_lattice_instance_f32 * S,\r
3911   float32_t * pSrc,\r
3912   float32_t * pDst,\r
3913   uint32_t blockSize);\r
3914 \r
3915 \r
3916   /**\r
3917    * @brief Instance structure for the Q15 IIR lattice filter.\r
3918    */\r
3919   typedef struct\r
3920   {\r
3921     uint16_t numStages;                  /**< number of stages in the filter. */\r
3922     q15_t *pState;                       /**< points to the state variable array. The array is of length numStages+blockSize. */\r
3923     q15_t *pkCoeffs;                     /**< points to the reflection coefficient array. The array is of length numStages. */\r
3924     q15_t *pvCoeffs;                     /**< points to the ladder coefficient array. The array is of length numStages+1. */\r
3925   } arm_iir_lattice_instance_q15;\r
3926 \r
3927   /**\r
3928    * @brief Instance structure for the Q31 IIR lattice filter.\r
3929    */\r
3930   typedef struct\r
3931   {\r
3932     uint16_t numStages;                  /**< number of stages in the filter. */\r
3933     q31_t *pState;                       /**< points to the state variable array. The array is of length numStages+blockSize. */\r
3934     q31_t *pkCoeffs;                     /**< points to the reflection coefficient array. The array is of length numStages. */\r
3935     q31_t *pvCoeffs;                     /**< points to the ladder coefficient array. The array is of length numStages+1. */\r
3936   } arm_iir_lattice_instance_q31;\r
3937 \r
3938   /**\r
3939    * @brief Instance structure for the floating-point IIR lattice filter.\r
3940    */\r
3941   typedef struct\r
3942   {\r
3943     uint16_t numStages;                  /**< number of stages in the filter. */\r
3944     float32_t *pState;                   /**< points to the state variable array. The array is of length numStages+blockSize. */\r
3945     float32_t *pkCoeffs;                 /**< points to the reflection coefficient array. The array is of length numStages. */\r
3946     float32_t *pvCoeffs;                 /**< points to the ladder coefficient array. The array is of length numStages+1. */\r
3947   } arm_iir_lattice_instance_f32;\r
3948 \r
3949 \r
3950   /**\r
3951    * @brief Processing function for the floating-point IIR lattice filter.\r
3952    * @param[in]  S          points to an instance of the floating-point IIR lattice structure.\r
3953    * @param[in]  pSrc       points to the block of input data.\r
3954    * @param[out] pDst       points to the block of output data.\r
3955    * @param[in]  blockSize  number of samples to process.\r
3956    */\r
3957   void arm_iir_lattice_f32(\r
3958   const arm_iir_lattice_instance_f32 * S,\r
3959   float32_t * pSrc,\r
3960   float32_t * pDst,\r
3961   uint32_t blockSize);\r
3962 \r
3963 \r
3964   /**\r
3965    * @brief Initialization function for the floating-point IIR lattice filter.\r
3966    * @param[in] S          points to an instance of the floating-point IIR lattice structure.\r
3967    * @param[in] numStages  number of stages in the filter.\r
3968    * @param[in] pkCoeffs   points to the reflection coefficient buffer.  The array is of length numStages.\r
3969    * @param[in] pvCoeffs   points to the ladder coefficient buffer.  The array is of length numStages+1.\r
3970    * @param[in] pState     points to the state buffer.  The array is of length numStages+blockSize-1.\r
3971    * @param[in] blockSize  number of samples to process.\r
3972    */\r
3973   void arm_iir_lattice_init_f32(\r
3974   arm_iir_lattice_instance_f32 * S,\r
3975   uint16_t numStages,\r
3976   float32_t * pkCoeffs,\r
3977   float32_t * pvCoeffs,\r
3978   float32_t * pState,\r
3979   uint32_t blockSize);\r
3980 \r
3981 \r
3982   /**\r
3983    * @brief Processing function for the Q31 IIR lattice filter.\r
3984    * @param[in]  S          points to an instance of the Q31 IIR lattice structure.\r
3985    * @param[in]  pSrc       points to the block of input data.\r
3986    * @param[out] pDst       points to the block of output data.\r
3987    * @param[in]  blockSize  number of samples to process.\r
3988    */\r
3989   void arm_iir_lattice_q31(\r
3990   const arm_iir_lattice_instance_q31 * S,\r
3991   q31_t * pSrc,\r
3992   q31_t * pDst,\r
3993   uint32_t blockSize);\r
3994 \r
3995 \r
3996   /**\r
3997    * @brief Initialization function for the Q31 IIR lattice filter.\r
3998    * @param[in] S          points to an instance of the Q31 IIR lattice structure.\r
3999    * @param[in] numStages  number of stages in the filter.\r
4000    * @param[in] pkCoeffs   points to the reflection coefficient buffer.  The array is of length numStages.\r
4001    * @param[in] pvCoeffs   points to the ladder coefficient buffer.  The array is of length numStages+1.\r
4002    * @param[in] pState     points to the state buffer.  The array is of length numStages+blockSize.\r
4003    * @param[in] blockSize  number of samples to process.\r
4004    */\r
4005   void arm_iir_lattice_init_q31(\r
4006   arm_iir_lattice_instance_q31 * S,\r
4007   uint16_t numStages,\r
4008   q31_t * pkCoeffs,\r
4009   q31_t * pvCoeffs,\r
4010   q31_t * pState,\r
4011   uint32_t blockSize);\r
4012 \r
4013 \r
4014   /**\r
4015    * @brief Processing function for the Q15 IIR lattice filter.\r
4016    * @param[in]  S          points to an instance of the Q15 IIR lattice structure.\r
4017    * @param[in]  pSrc       points to the block of input data.\r
4018    * @param[out] pDst       points to the block of output data.\r
4019    * @param[in]  blockSize  number of samples to process.\r
4020    */\r
4021   void arm_iir_lattice_q15(\r
4022   const arm_iir_lattice_instance_q15 * S,\r
4023   q15_t * pSrc,\r
4024   q15_t * pDst,\r
4025   uint32_t blockSize);\r
4026 \r
4027 \r
4028 /**\r
4029  * @brief Initialization function for the Q15 IIR lattice filter.\r
4030  * @param[in] S          points to an instance of the fixed-point Q15 IIR lattice structure.\r
4031  * @param[in] numStages  number of stages in the filter.\r
4032  * @param[in] pkCoeffs   points to reflection coefficient buffer.  The array is of length numStages.\r
4033  * @param[in] pvCoeffs   points to ladder coefficient buffer.  The array is of length numStages+1.\r
4034  * @param[in] pState     points to state buffer.  The array is of length numStages+blockSize.\r
4035  * @param[in] blockSize  number of samples to process per call.\r
4036  */\r
4037   void arm_iir_lattice_init_q15(\r
4038   arm_iir_lattice_instance_q15 * S,\r
4039   uint16_t numStages,\r
4040   q15_t * pkCoeffs,\r
4041   q15_t * pvCoeffs,\r
4042   q15_t * pState,\r
4043   uint32_t blockSize);\r
4044 \r
4045 \r
4046   /**\r
4047    * @brief Instance structure for the floating-point LMS filter.\r
4048    */\r
4049   typedef struct\r
4050   {\r
4051     uint16_t numTaps;    /**< number of coefficients in the filter. */\r
4052     float32_t *pState;   /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
4053     float32_t *pCoeffs;  /**< points to the coefficient array. The array is of length numTaps. */\r
4054     float32_t mu;        /**< step size that controls filter coefficient updates. */\r
4055   } arm_lms_instance_f32;\r
4056 \r
4057 \r
4058   /**\r
4059    * @brief Processing function for floating-point LMS filter.\r
4060    * @param[in]  S          points to an instance of the floating-point LMS filter structure.\r
4061    * @param[in]  pSrc       points to the block of input data.\r
4062    * @param[in]  pRef       points to the block of reference data.\r
4063    * @param[out] pOut       points to the block of output data.\r
4064    * @param[out] pErr       points to the block of error data.\r
4065    * @param[in]  blockSize  number of samples to process.\r
4066    */\r
4067   void arm_lms_f32(\r
4068   const arm_lms_instance_f32 * S,\r
4069   float32_t * pSrc,\r
4070   float32_t * pRef,\r
4071   float32_t * pOut,\r
4072   float32_t * pErr,\r
4073   uint32_t blockSize);\r
4074 \r
4075 \r
4076   /**\r
4077    * @brief Initialization function for floating-point LMS filter.\r
4078    * @param[in] S          points to an instance of the floating-point LMS filter structure.\r
4079    * @param[in] numTaps    number of filter coefficients.\r
4080    * @param[in] pCoeffs    points to the coefficient buffer.\r
4081    * @param[in] pState     points to state buffer.\r
4082    * @param[in] mu         step size that controls filter coefficient updates.\r
4083    * @param[in] blockSize  number of samples to process.\r
4084    */\r
4085   void arm_lms_init_f32(\r
4086   arm_lms_instance_f32 * S,\r
4087   uint16_t numTaps,\r
4088   float32_t * pCoeffs,\r
4089   float32_t * pState,\r
4090   float32_t mu,\r
4091   uint32_t blockSize);\r
4092 \r
4093 \r
4094   /**\r
4095    * @brief Instance structure for the Q15 LMS filter.\r
4096    */\r
4097   typedef struct\r
4098   {\r
4099     uint16_t numTaps;    /**< number of coefficients in the filter. */\r
4100     q15_t *pState;       /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
4101     q15_t *pCoeffs;      /**< points to the coefficient array. The array is of length numTaps. */\r
4102     q15_t mu;            /**< step size that controls filter coefficient updates. */\r
4103     uint32_t postShift;  /**< bit shift applied to coefficients. */\r
4104   } arm_lms_instance_q15;\r
4105 \r
4106 \r
4107   /**\r
4108    * @brief Initialization function for the Q15 LMS filter.\r
4109    * @param[in] S          points to an instance of the Q15 LMS filter structure.\r
4110    * @param[in] numTaps    number of filter coefficients.\r
4111    * @param[in] pCoeffs    points to the coefficient buffer.\r
4112    * @param[in] pState     points to the state buffer.\r
4113    * @param[in] mu         step size that controls filter coefficient updates.\r
4114    * @param[in] blockSize  number of samples to process.\r
4115    * @param[in] postShift  bit shift applied to coefficients.\r
4116    */\r
4117   void arm_lms_init_q15(\r
4118   arm_lms_instance_q15 * S,\r
4119   uint16_t numTaps,\r
4120   q15_t * pCoeffs,\r
4121   q15_t * pState,\r
4122   q15_t mu,\r
4123   uint32_t blockSize,\r
4124   uint32_t postShift);\r
4125 \r
4126 \r
4127   /**\r
4128    * @brief Processing function for Q15 LMS filter.\r
4129    * @param[in]  S          points to an instance of the Q15 LMS filter structure.\r
4130    * @param[in]  pSrc       points to the block of input data.\r
4131    * @param[in]  pRef       points to the block of reference data.\r
4132    * @param[out] pOut       points to the block of output data.\r
4133    * @param[out] pErr       points to the block of error data.\r
4134    * @param[in]  blockSize  number of samples to process.\r
4135    */\r
4136   void arm_lms_q15(\r
4137   const arm_lms_instance_q15 * S,\r
4138   q15_t * pSrc,\r
4139   q15_t * pRef,\r
4140   q15_t * pOut,\r
4141   q15_t * pErr,\r
4142   uint32_t blockSize);\r
4143 \r
4144 \r
4145   /**\r
4146    * @brief Instance structure for the Q31 LMS filter.\r
4147    */\r
4148   typedef struct\r
4149   {\r
4150     uint16_t numTaps;    /**< number of coefficients in the filter. */\r
4151     q31_t *pState;       /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
4152     q31_t *pCoeffs;      /**< points to the coefficient array. The array is of length numTaps. */\r
4153     q31_t mu;            /**< step size that controls filter coefficient updates. */\r
4154     uint32_t postShift;  /**< bit shift applied to coefficients. */\r
4155   } arm_lms_instance_q31;\r
4156 \r
4157 \r
4158   /**\r
4159    * @brief Processing function for Q31 LMS filter.\r
4160    * @param[in]  S          points to an instance of the Q15 LMS filter structure.\r
4161    * @param[in]  pSrc       points to the block of input data.\r
4162    * @param[in]  pRef       points to the block of reference data.\r
4163    * @param[out] pOut       points to the block of output data.\r
4164    * @param[out] pErr       points to the block of error data.\r
4165    * @param[in]  blockSize  number of samples to process.\r
4166    */\r
4167   void arm_lms_q31(\r
4168   const arm_lms_instance_q31 * S,\r
4169   q31_t * pSrc,\r
4170   q31_t * pRef,\r
4171   q31_t * pOut,\r
4172   q31_t * pErr,\r
4173   uint32_t blockSize);\r
4174 \r
4175 \r
4176   /**\r
4177    * @brief Initialization function for Q31 LMS filter.\r
4178    * @param[in] S          points to an instance of the Q31 LMS filter structure.\r
4179    * @param[in] numTaps    number of filter coefficients.\r
4180    * @param[in] pCoeffs    points to coefficient buffer.\r
4181    * @param[in] pState     points to state buffer.\r
4182    * @param[in] mu         step size that controls filter coefficient updates.\r
4183    * @param[in] blockSize  number of samples to process.\r
4184    * @param[in] postShift  bit shift applied to coefficients.\r
4185    */\r
4186   void arm_lms_init_q31(\r
4187   arm_lms_instance_q31 * S,\r
4188   uint16_t numTaps,\r
4189   q31_t * pCoeffs,\r
4190   q31_t * pState,\r
4191   q31_t mu,\r
4192   uint32_t blockSize,\r
4193   uint32_t postShift);\r
4194 \r
4195 \r
4196   /**\r
4197    * @brief Instance structure for the floating-point normalized LMS filter.\r
4198    */\r
4199   typedef struct\r
4200   {\r
4201     uint16_t numTaps;     /**< number of coefficients in the filter. */\r
4202     float32_t *pState;    /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
4203     float32_t *pCoeffs;   /**< points to the coefficient array. The array is of length numTaps. */\r
4204     float32_t mu;         /**< step size that control filter coefficient updates. */\r
4205     float32_t energy;     /**< saves previous frame energy. */\r
4206     float32_t x0;         /**< saves previous input sample. */\r
4207   } arm_lms_norm_instance_f32;\r
4208 \r
4209 \r
4210   /**\r
4211    * @brief Processing function for floating-point normalized LMS filter.\r
4212    * @param[in]  S          points to an instance of the floating-point normalized LMS filter structure.\r
4213    * @param[in]  pSrc       points to the block of input data.\r
4214    * @param[in]  pRef       points to the block of reference data.\r
4215    * @param[out] pOut       points to the block of output data.\r
4216    * @param[out] pErr       points to the block of error data.\r
4217    * @param[in]  blockSize  number of samples to process.\r
4218    */\r
4219   void arm_lms_norm_f32(\r
4220   arm_lms_norm_instance_f32 * S,\r
4221   float32_t * pSrc,\r
4222   float32_t * pRef,\r
4223   float32_t * pOut,\r
4224   float32_t * pErr,\r
4225   uint32_t blockSize);\r
4226 \r
4227 \r
4228   /**\r
4229    * @brief Initialization function for floating-point normalized LMS filter.\r
4230    * @param[in] S          points to an instance of the floating-point LMS filter structure.\r
4231    * @param[in] numTaps    number of filter coefficients.\r
4232    * @param[in] pCoeffs    points to coefficient buffer.\r
4233    * @param[in] pState     points to state buffer.\r
4234    * @param[in] mu         step size that controls filter coefficient updates.\r
4235    * @param[in] blockSize  number of samples to process.\r
4236    */\r
4237   void arm_lms_norm_init_f32(\r
4238   arm_lms_norm_instance_f32 * S,\r
4239   uint16_t numTaps,\r
4240   float32_t * pCoeffs,\r
4241   float32_t * pState,\r
4242   float32_t mu,\r
4243   uint32_t blockSize);\r
4244 \r
4245 \r
4246   /**\r
4247    * @brief Instance structure for the Q31 normalized LMS filter.\r
4248    */\r
4249   typedef struct\r
4250   {\r
4251     uint16_t numTaps;     /**< number of coefficients in the filter. */\r
4252     q31_t *pState;        /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
4253     q31_t *pCoeffs;       /**< points to the coefficient array. The array is of length numTaps. */\r
4254     q31_t mu;             /**< step size that controls filter coefficient updates. */\r
4255     uint8_t postShift;    /**< bit shift applied to coefficients. */\r
4256     q31_t *recipTable;    /**< points to the reciprocal initial value table. */\r
4257     q31_t energy;         /**< saves previous frame energy. */\r
4258     q31_t x0;             /**< saves previous input sample. */\r
4259   } arm_lms_norm_instance_q31;\r
4260 \r
4261 \r
4262   /**\r
4263    * @brief Processing function for Q31 normalized LMS filter.\r
4264    * @param[in]  S          points to an instance of the Q31 normalized LMS filter structure.\r
4265    * @param[in]  pSrc       points to the block of input data.\r
4266    * @param[in]  pRef       points to the block of reference data.\r
4267    * @param[out] pOut       points to the block of output data.\r
4268    * @param[out] pErr       points to the block of error data.\r
4269    * @param[in]  blockSize  number of samples to process.\r
4270    */\r
4271   void arm_lms_norm_q31(\r
4272   arm_lms_norm_instance_q31 * S,\r
4273   q31_t * pSrc,\r
4274   q31_t * pRef,\r
4275   q31_t * pOut,\r
4276   q31_t * pErr,\r
4277   uint32_t blockSize);\r
4278 \r
4279 \r
4280   /**\r
4281    * @brief Initialization function for Q31 normalized LMS filter.\r
4282    * @param[in] S          points to an instance of the Q31 normalized LMS filter structure.\r
4283    * @param[in] numTaps    number of filter coefficients.\r
4284    * @param[in] pCoeffs    points to coefficient buffer.\r
4285    * @param[in] pState     points to state buffer.\r
4286    * @param[in] mu         step size that controls filter coefficient updates.\r
4287    * @param[in] blockSize  number of samples to process.\r
4288    * @param[in] postShift  bit shift applied to coefficients.\r
4289    */\r
4290   void arm_lms_norm_init_q31(\r
4291   arm_lms_norm_instance_q31 * S,\r
4292   uint16_t numTaps,\r
4293   q31_t * pCoeffs,\r
4294   q31_t * pState,\r
4295   q31_t mu,\r
4296   uint32_t blockSize,\r
4297   uint8_t postShift);\r
4298 \r
4299 \r
4300   /**\r
4301    * @brief Instance structure for the Q15 normalized LMS filter.\r
4302    */\r
4303   typedef struct\r
4304   {\r
4305     uint16_t numTaps;     /**< Number of coefficients in the filter. */\r
4306     q15_t *pState;        /**< points to the state variable array. The array is of length numTaps+blockSize-1. */\r
4307     q15_t *pCoeffs;       /**< points to the coefficient array. The array is of length numTaps. */\r
4308     q15_t mu;             /**< step size that controls filter coefficient updates. */\r
4309     uint8_t postShift;    /**< bit shift applied to coefficients. */\r
4310     q15_t *recipTable;    /**< Points to the reciprocal initial value table. */\r
4311     q15_t energy;         /**< saves previous frame energy. */\r
4312     q15_t x0;             /**< saves previous input sample. */\r
4313   } arm_lms_norm_instance_q15;\r
4314 \r
4315 \r
4316   /**\r
4317    * @brief Processing function for Q15 normalized LMS filter.\r
4318    * @param[in]  S          points to an instance of the Q15 normalized LMS filter structure.\r
4319    * @param[in]  pSrc       points to the block of input data.\r
4320    * @param[in]  pRef       points to the block of reference data.\r
4321    * @param[out] pOut       points to the block of output data.\r
4322    * @param[out] pErr       points to the block of error data.\r
4323    * @param[in]  blockSize  number of samples to process.\r
4324    */\r
4325   void arm_lms_norm_q15(\r
4326   arm_lms_norm_instance_q15 * S,\r
4327   q15_t * pSrc,\r
4328   q15_t * pRef,\r
4329   q15_t * pOut,\r
4330   q15_t * pErr,\r
4331   uint32_t blockSize);\r
4332 \r
4333 \r
4334   /**\r
4335    * @brief Initialization function for Q15 normalized LMS filter.\r
4336    * @param[in] S          points to an instance of the Q15 normalized LMS filter structure.\r
4337    * @param[in] numTaps    number of filter coefficients.\r
4338    * @param[in] pCoeffs    points to coefficient buffer.\r
4339    * @param[in] pState     points to state buffer.\r
4340    * @param[in] mu         step size that controls filter coefficient updates.\r
4341    * @param[in] blockSize  number of samples to process.\r
4342    * @param[in] postShift  bit shift applied to coefficients.\r
4343    */\r
4344   void arm_lms_norm_init_q15(\r
4345   arm_lms_norm_instance_q15 * S,\r
4346   uint16_t numTaps,\r
4347   q15_t * pCoeffs,\r
4348   q15_t * pState,\r
4349   q15_t mu,\r
4350   uint32_t blockSize,\r
4351   uint8_t postShift);\r
4352 \r
4353 \r
4354   /**\r
4355    * @brief Correlation of floating-point sequences.\r
4356    * @param[in]  pSrcA    points to the first input sequence.\r
4357    * @param[in]  srcALen  length of the first input sequence.\r
4358    * @param[in]  pSrcB    points to the second input sequence.\r
4359    * @param[in]  srcBLen  length of the second input sequence.\r
4360    * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4361    */\r
4362   void arm_correlate_f32(\r
4363   float32_t * pSrcA,\r
4364   uint32_t srcALen,\r
4365   float32_t * pSrcB,\r
4366   uint32_t srcBLen,\r
4367   float32_t * pDst);\r
4368 \r
4369 \r
4370    /**\r
4371    * @brief Correlation of Q15 sequences\r
4372    * @param[in]  pSrcA     points to the first input sequence.\r
4373    * @param[in]  srcALen   length of the first input sequence.\r
4374    * @param[in]  pSrcB     points to the second input sequence.\r
4375    * @param[in]  srcBLen   length of the second input sequence.\r
4376    * @param[out] pDst      points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4377    * @param[in]  pScratch  points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
4378    */\r
4379   void arm_correlate_opt_q15(\r
4380   q15_t * pSrcA,\r
4381   uint32_t srcALen,\r
4382   q15_t * pSrcB,\r
4383   uint32_t srcBLen,\r
4384   q15_t * pDst,\r
4385   q15_t * pScratch);\r
4386 \r
4387 \r
4388   /**\r
4389    * @brief Correlation of Q15 sequences.\r
4390    * @param[in]  pSrcA    points to the first input sequence.\r
4391    * @param[in]  srcALen  length of the first input sequence.\r
4392    * @param[in]  pSrcB    points to the second input sequence.\r
4393    * @param[in]  srcBLen  length of the second input sequence.\r
4394    * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4395    */\r
4396 \r
4397   void arm_correlate_q15(\r
4398   q15_t * pSrcA,\r
4399   uint32_t srcALen,\r
4400   q15_t * pSrcB,\r
4401   uint32_t srcBLen,\r
4402   q15_t * pDst);\r
4403 \r
4404 \r
4405   /**\r
4406    * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.\r
4407    * @param[in]  pSrcA    points to the first input sequence.\r
4408    * @param[in]  srcALen  length of the first input sequence.\r
4409    * @param[in]  pSrcB    points to the second input sequence.\r
4410    * @param[in]  srcBLen  length of the second input sequence.\r
4411    * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4412    */\r
4413 \r
4414   void arm_correlate_fast_q15(\r
4415   q15_t * pSrcA,\r
4416   uint32_t srcALen,\r
4417   q15_t * pSrcB,\r
4418   uint32_t srcBLen,\r
4419   q15_t * pDst);\r
4420 \r
4421 \r
4422   /**\r
4423    * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.\r
4424    * @param[in]  pSrcA     points to the first input sequence.\r
4425    * @param[in]  srcALen   length of the first input sequence.\r
4426    * @param[in]  pSrcB     points to the second input sequence.\r
4427    * @param[in]  srcBLen   length of the second input sequence.\r
4428    * @param[out] pDst      points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4429    * @param[in]  pScratch  points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
4430    */\r
4431   void arm_correlate_fast_opt_q15(\r
4432   q15_t * pSrcA,\r
4433   uint32_t srcALen,\r
4434   q15_t * pSrcB,\r
4435   uint32_t srcBLen,\r
4436   q15_t * pDst,\r
4437   q15_t * pScratch);\r
4438 \r
4439 \r
4440   /**\r
4441    * @brief Correlation of Q31 sequences.\r
4442    * @param[in]  pSrcA    points to the first input sequence.\r
4443    * @param[in]  srcALen  length of the first input sequence.\r
4444    * @param[in]  pSrcB    points to the second input sequence.\r
4445    * @param[in]  srcBLen  length of the second input sequence.\r
4446    * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4447    */\r
4448   void arm_correlate_q31(\r
4449   q31_t * pSrcA,\r
4450   uint32_t srcALen,\r
4451   q31_t * pSrcB,\r
4452   uint32_t srcBLen,\r
4453   q31_t * pDst);\r
4454 \r
4455 \r
4456   /**\r
4457    * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4\r
4458    * @param[in]  pSrcA    points to the first input sequence.\r
4459    * @param[in]  srcALen  length of the first input sequence.\r
4460    * @param[in]  pSrcB    points to the second input sequence.\r
4461    * @param[in]  srcBLen  length of the second input sequence.\r
4462    * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4463    */\r
4464   void arm_correlate_fast_q31(\r
4465   q31_t * pSrcA,\r
4466   uint32_t srcALen,\r
4467   q31_t * pSrcB,\r
4468   uint32_t srcBLen,\r
4469   q31_t * pDst);\r
4470 \r
4471 \r
4472  /**\r
4473    * @brief Correlation of Q7 sequences.\r
4474    * @param[in]  pSrcA      points to the first input sequence.\r
4475    * @param[in]  srcALen    length of the first input sequence.\r
4476    * @param[in]  pSrcB      points to the second input sequence.\r
4477    * @param[in]  srcBLen    length of the second input sequence.\r
4478    * @param[out] pDst       points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4479    * @param[in]  pScratch1  points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.\r
4480    * @param[in]  pScratch2  points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).\r
4481    */\r
4482   void arm_correlate_opt_q7(\r
4483   q7_t * pSrcA,\r
4484   uint32_t srcALen,\r
4485   q7_t * pSrcB,\r
4486   uint32_t srcBLen,\r
4487   q7_t * pDst,\r
4488   q15_t * pScratch1,\r
4489   q15_t * pScratch2);\r
4490 \r
4491 \r
4492   /**\r
4493    * @brief Correlation of Q7 sequences.\r
4494    * @param[in]  pSrcA    points to the first input sequence.\r
4495    * @param[in]  srcALen  length of the first input sequence.\r
4496    * @param[in]  pSrcB    points to the second input sequence.\r
4497    * @param[in]  srcBLen  length of the second input sequence.\r
4498    * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.\r
4499    */\r
4500   void arm_correlate_q7(\r
4501   q7_t * pSrcA,\r
4502   uint32_t srcALen,\r
4503   q7_t * pSrcB,\r
4504   uint32_t srcBLen,\r
4505   q7_t * pDst);\r
4506 \r
4507 \r
4508   /**\r
4509    * @brief Instance structure for the floating-point sparse FIR filter.\r
4510    */\r
4511   typedef struct\r
4512   {\r
4513     uint16_t numTaps;             /**< number of coefficients in the filter. */\r
4514     uint16_t stateIndex;          /**< state buffer index.  Points to the oldest sample in the state buffer. */\r
4515     float32_t *pState;            /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */\r
4516     float32_t *pCoeffs;           /**< points to the coefficient array. The array is of length numTaps.*/\r
4517     uint16_t maxDelay;            /**< maximum offset specified by the pTapDelay array. */\r
4518     int32_t *pTapDelay;           /**< points to the array of delay values.  The array is of length numTaps. */\r
4519   } arm_fir_sparse_instance_f32;\r
4520 \r
4521   /**\r
4522    * @brief Instance structure for the Q31 sparse FIR filter.\r
4523    */\r
4524   typedef struct\r
4525   {\r
4526     uint16_t numTaps;             /**< number of coefficients in the filter. */\r
4527     uint16_t stateIndex;          /**< state buffer index.  Points to the oldest sample in the state buffer. */\r
4528     q31_t *pState;                /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */\r
4529     q31_t *pCoeffs;               /**< points to the coefficient array. The array is of length numTaps.*/\r
4530     uint16_t maxDelay;            /**< maximum offset specified by the pTapDelay array. */\r
4531     int32_t *pTapDelay;           /**< points to the array of delay values.  The array is of length numTaps. */\r
4532   } arm_fir_sparse_instance_q31;\r
4533 \r
4534   /**\r
4535    * @brief Instance structure for the Q15 sparse FIR filter.\r
4536    */\r
4537   typedef struct\r
4538   {\r
4539     uint16_t numTaps;             /**< number of coefficients in the filter. */\r
4540     uint16_t stateIndex;          /**< state buffer index.  Points to the oldest sample in the state buffer. */\r
4541     q15_t *pState;                /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */\r
4542     q15_t *pCoeffs;               /**< points to the coefficient array. The array is of length numTaps.*/\r
4543     uint16_t maxDelay;            /**< maximum offset specified by the pTapDelay array. */\r
4544     int32_t *pTapDelay;           /**< points to the array of delay values.  The array is of length numTaps. */\r
4545   } arm_fir_sparse_instance_q15;\r
4546 \r
4547   /**\r
4548    * @brief Instance structure for the Q7 sparse FIR filter.\r
4549    */\r
4550   typedef struct\r
4551   {\r
4552     uint16_t numTaps;             /**< number of coefficients in the filter. */\r
4553     uint16_t stateIndex;          /**< state buffer index.  Points to the oldest sample in the state buffer. */\r
4554     q7_t *pState;                 /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */\r
4555     q7_t *pCoeffs;                /**< points to the coefficient array. The array is of length numTaps.*/\r
4556     uint16_t maxDelay;            /**< maximum offset specified by the pTapDelay array. */\r
4557     int32_t *pTapDelay;           /**< points to the array of delay values.  The array is of length numTaps. */\r
4558   } arm_fir_sparse_instance_q7;\r
4559 \r
4560 \r
4561   /**\r
4562    * @brief Processing function for the floating-point sparse FIR filter.\r
4563    * @param[in]  S           points to an instance of the floating-point sparse FIR structure.\r
4564    * @param[in]  pSrc        points to the block of input data.\r
4565    * @param[out] pDst        points to the block of output data\r
4566    * @param[in]  pScratchIn  points to a temporary buffer of size blockSize.\r
4567    * @param[in]  blockSize   number of input samples to process per call.\r
4568    */\r
4569   void arm_fir_sparse_f32(\r
4570   arm_fir_sparse_instance_f32 * S,\r
4571   float32_t * pSrc,\r
4572   float32_t * pDst,\r
4573   float32_t * pScratchIn,\r
4574   uint32_t blockSize);\r
4575 \r
4576 \r
4577   /**\r
4578    * @brief  Initialization function for the floating-point sparse FIR filter.\r
4579    * @param[in,out] S          points to an instance of the floating-point sparse FIR structure.\r
4580    * @param[in]     numTaps    number of nonzero coefficients in the filter.\r
4581    * @param[in]     pCoeffs    points to the array of filter coefficients.\r
4582    * @param[in]     pState     points to the state buffer.\r
4583    * @param[in]     pTapDelay  points to the array of offset times.\r
4584    * @param[in]     maxDelay   maximum offset time supported.\r
4585    * @param[in]     blockSize  number of samples that will be processed per block.\r
4586    */\r
4587   void arm_fir_sparse_init_f32(\r
4588   arm_fir_sparse_instance_f32 * S,\r
4589   uint16_t numTaps,\r
4590   float32_t * pCoeffs,\r
4591   float32_t * pState,\r
4592   int32_t * pTapDelay,\r
4593   uint16_t maxDelay,\r
4594   uint32_t blockSize);\r
4595 \r
4596 \r
4597   /**\r
4598    * @brief Processing function for the Q31 sparse FIR filter.\r
4599    * @param[in]  S           points to an instance of the Q31 sparse FIR structure.\r
4600    * @param[in]  pSrc        points to the block of input data.\r
4601    * @param[out] pDst        points to the block of output data\r
4602    * @param[in]  pScratchIn  points to a temporary buffer of size blockSize.\r
4603    * @param[in]  blockSize   number of input samples to process per call.\r
4604    */\r
4605   void arm_fir_sparse_q31(\r
4606   arm_fir_sparse_instance_q31 * S,\r
4607   q31_t * pSrc,\r
4608   q31_t * pDst,\r
4609   q31_t * pScratchIn,\r
4610   uint32_t blockSize);\r
4611 \r
4612 \r
4613   /**\r
4614    * @brief  Initialization function for the Q31 sparse FIR filter.\r
4615    * @param[in,out] S          points to an instance of the Q31 sparse FIR structure.\r
4616    * @param[in]     numTaps    number of nonzero coefficients in the filter.\r
4617    * @param[in]     pCoeffs    points to the array of filter coefficients.\r
4618    * @param[in]     pState     points to the state buffer.\r
4619    * @param[in]     pTapDelay  points to the array of offset times.\r
4620    * @param[in]     maxDelay   maximum offset time supported.\r
4621    * @param[in]     blockSize  number of samples that will be processed per block.\r
4622    */\r
4623   void arm_fir_sparse_init_q31(\r
4624   arm_fir_sparse_instance_q31 * S,\r
4625   uint16_t numTaps,\r
4626   q31_t * pCoeffs,\r
4627   q31_t * pState,\r
4628   int32_t * pTapDelay,\r
4629   uint16_t maxDelay,\r
4630   uint32_t blockSize);\r
4631 \r
4632 \r
4633   /**\r
4634    * @brief Processing function for the Q15 sparse FIR filter.\r
4635    * @param[in]  S            points to an instance of the Q15 sparse FIR structure.\r
4636    * @param[in]  pSrc         points to the block of input data.\r
4637    * @param[out] pDst         points to the block of output data\r
4638    * @param[in]  pScratchIn   points to a temporary buffer of size blockSize.\r
4639    * @param[in]  pScratchOut  points to a temporary buffer of size blockSize.\r
4640    * @param[in]  blockSize    number of input samples to process per call.\r
4641    */\r
4642   void arm_fir_sparse_q15(\r
4643   arm_fir_sparse_instance_q15 * S,\r
4644   q15_t * pSrc,\r
4645   q15_t * pDst,\r
4646   q15_t * pScratchIn,\r
4647   q31_t * pScratchOut,\r
4648   uint32_t blockSize);\r
4649 \r
4650 \r
4651   /**\r
4652    * @brief  Initialization function for the Q15 sparse FIR filter.\r
4653    * @param[in,out] S          points to an instance of the Q15 sparse FIR structure.\r
4654    * @param[in]     numTaps    number of nonzero coefficients in the filter.\r
4655    * @param[in]     pCoeffs    points to the array of filter coefficients.\r
4656    * @param[in]     pState     points to the state buffer.\r
4657    * @param[in]     pTapDelay  points to the array of offset times.\r
4658    * @param[in]     maxDelay   maximum offset time supported.\r
4659    * @param[in]     blockSize  number of samples that will be processed per block.\r
4660    */\r
4661   void arm_fir_sparse_init_q15(\r
4662   arm_fir_sparse_instance_q15 * S,\r
4663   uint16_t numTaps,\r
4664   q15_t * pCoeffs,\r
4665   q15_t * pState,\r
4666   int32_t * pTapDelay,\r
4667   uint16_t maxDelay,\r
4668   uint32_t blockSize);\r
4669 \r
4670 \r
4671   /**\r
4672    * @brief Processing function for the Q7 sparse FIR filter.\r
4673    * @param[in]  S            points to an instance of the Q7 sparse FIR structure.\r
4674    * @param[in]  pSrc         points to the block of input data.\r
4675    * @param[out] pDst         points to the block of output data\r
4676    * @param[in]  pScratchIn   points to a temporary buffer of size blockSize.\r
4677    * @param[in]  pScratchOut  points to a temporary buffer of size blockSize.\r
4678    * @param[in]  blockSize    number of input samples to process per call.\r
4679    */\r
4680   void arm_fir_sparse_q7(\r
4681   arm_fir_sparse_instance_q7 * S,\r
4682   q7_t * pSrc,\r
4683   q7_t * pDst,\r
4684   q7_t * pScratchIn,\r
4685   q31_t * pScratchOut,\r
4686   uint32_t blockSize);\r
4687 \r
4688 \r
4689   /**\r
4690    * @brief  Initialization function for the Q7 sparse FIR filter.\r
4691    * @param[in,out] S          points to an instance of the Q7 sparse FIR structure.\r
4692    * @param[in]     numTaps    number of nonzero coefficients in the filter.\r
4693    * @param[in]     pCoeffs    points to the array of filter coefficients.\r
4694    * @param[in]     pState     points to the state buffer.\r
4695    * @param[in]     pTapDelay  points to the array of offset times.\r
4696    * @param[in]     maxDelay   maximum offset time supported.\r
4697    * @param[in]     blockSize  number of samples that will be processed per block.\r
4698    */\r
4699   void arm_fir_sparse_init_q7(\r
4700   arm_fir_sparse_instance_q7 * S,\r
4701   uint16_t numTaps,\r
4702   q7_t * pCoeffs,\r
4703   q7_t * pState,\r
4704   int32_t * pTapDelay,\r
4705   uint16_t maxDelay,\r
4706   uint32_t blockSize);\r
4707 \r
4708 \r
4709   /**\r
4710    * @brief  Floating-point sin_cos function.\r
4711    * @param[in]  theta   input value in degrees\r
4712    * @param[out] pSinVal  points to the processed sine output.\r
4713    * @param[out] pCosVal  points to the processed cos output.\r
4714    */\r
4715   void arm_sin_cos_f32(\r
4716   float32_t theta,\r
4717   float32_t * pSinVal,\r
4718   float32_t * pCosVal);\r
4719 \r
4720 \r
4721   /**\r
4722    * @brief  Q31 sin_cos function.\r
4723    * @param[in]  theta    scaled input value in degrees\r
4724    * @param[out] pSinVal  points to the processed sine output.\r
4725    * @param[out] pCosVal  points to the processed cosine output.\r
4726    */\r
4727   void arm_sin_cos_q31(\r
4728   q31_t theta,\r
4729   q31_t * pSinVal,\r
4730   q31_t * pCosVal);\r
4731 \r
4732 \r
4733   /**\r
4734    * @brief  Floating-point complex conjugate.\r
4735    * @param[in]  pSrc        points to the input vector\r
4736    * @param[out] pDst        points to the output vector\r
4737    * @param[in]  numSamples  number of complex samples in each vector\r
4738    */\r
4739   void arm_cmplx_conj_f32(\r
4740   float32_t * pSrc,\r
4741   float32_t * pDst,\r
4742   uint32_t numSamples);\r
4743 \r
4744   /**\r
4745    * @brief  Q31 complex conjugate.\r
4746    * @param[in]  pSrc        points to the input vector\r
4747    * @param[out] pDst        points to the output vector\r
4748    * @param[in]  numSamples  number of complex samples in each vector\r
4749    */\r
4750   void arm_cmplx_conj_q31(\r
4751   q31_t * pSrc,\r
4752   q31_t * pDst,\r
4753   uint32_t numSamples);\r
4754 \r
4755 \r
4756   /**\r
4757    * @brief  Q15 complex conjugate.\r
4758    * @param[in]  pSrc        points to the input vector\r
4759    * @param[out] pDst        points to the output vector\r
4760    * @param[in]  numSamples  number of complex samples in each vector\r
4761    */\r
4762   void arm_cmplx_conj_q15(\r
4763   q15_t * pSrc,\r
4764   q15_t * pDst,\r
4765   uint32_t numSamples);\r
4766 \r
4767 \r
4768   /**\r
4769    * @brief  Floating-point complex magnitude squared\r
4770    * @param[in]  pSrc        points to the complex input vector\r
4771    * @param[out] pDst        points to the real output vector\r
4772    * @param[in]  numSamples  number of complex samples in the input vector\r
4773    */\r
4774   void arm_cmplx_mag_squared_f32(\r
4775   float32_t * pSrc,\r
4776   float32_t * pDst,\r
4777   uint32_t numSamples);\r
4778 \r
4779 \r
4780   /**\r
4781    * @brief  Q31 complex magnitude squared\r
4782    * @param[in]  pSrc        points to the complex input vector\r
4783    * @param[out] pDst        points to the real output vector\r
4784    * @param[in]  numSamples  number of complex samples in the input vector\r
4785    */\r
4786   void arm_cmplx_mag_squared_q31(\r
4787   q31_t * pSrc,\r
4788   q31_t * pDst,\r
4789   uint32_t numSamples);\r
4790 \r
4791 \r
4792   /**\r
4793    * @brief  Q15 complex magnitude squared\r
4794    * @param[in]  pSrc        points to the complex input vector\r
4795    * @param[out] pDst        points to the real output vector\r
4796    * @param[in]  numSamples  number of complex samples in the input vector\r
4797    */\r
4798   void arm_cmplx_mag_squared_q15(\r
4799   q15_t * pSrc,\r
4800   q15_t * pDst,\r
4801   uint32_t numSamples);\r
4802 \r
4803 \r
4804  /**\r
4805    * @ingroup groupController\r
4806    */\r
4807 \r
4808   /**\r
4809    * @defgroup PID PID Motor Control\r
4810    *\r
4811    * A Proportional Integral Derivative (PID) controller is a generic feedback control\r
4812    * loop mechanism widely used in industrial control systems.\r
4813    * A PID controller is the most commonly used type of feedback controller.\r
4814    *\r
4815    * This set of functions implements (PID) controllers\r
4816    * for Q15, Q31, and floating-point data types.  The functions operate on a single sample\r
4817    * of data and each call to the function returns a single processed value.\r
4818    * <code>S</code> points to an instance of the PID control data structure.  <code>in</code>\r
4819    * is the input sample value. The functions return the output value.\r
4820    *\r
4821    * \par Algorithm:\r
4822    * <pre>\r
4823    *    y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]\r
4824    *    A0 = Kp + Ki + Kd\r
4825    *    A1 = (-Kp ) - (2 * Kd )\r
4826    *    A2 = Kd  </pre>\r
4827    *\r
4828    * \par\r
4829    * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant\r
4830    *\r
4831    * \par\r
4832    * \image html PID.gif "Proportional Integral Derivative Controller"\r
4833    *\r
4834    * \par\r
4835    * The PID controller calculates an "error" value as the difference between\r
4836    * the measured output and the reference input.\r
4837    * The controller attempts to minimize the error by adjusting the process control inputs.\r
4838    * The proportional value determines the reaction to the current error,\r
4839    * the integral value determines the reaction based on the sum of recent errors,\r
4840    * and the derivative value determines the reaction based on the rate at which the error has been changing.\r
4841    *\r
4842    * \par Instance Structure\r
4843    * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.\r
4844    * A separate instance structure must be defined for each PID Controller.\r
4845    * There are separate instance structure declarations for each of the 3 supported data types.\r
4846    *\r
4847    * \par Reset Functions\r
4848    * There is also an associated reset function for each data type which clears the state array.\r
4849    *\r
4850    * \par Initialization Functions\r
4851    * There is also an associated initialization function for each data type.\r
4852    * The initialization function performs the following operations:\r
4853    * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.\r
4854    * - Zeros out the values in the state buffer.\r
4855    *\r
4856    * \par\r
4857    * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.\r
4858    *\r
4859    * \par Fixed-Point Behavior\r
4860    * Care must be taken when using the fixed-point versions of the PID Controller functions.\r
4861    * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.\r
4862    * Refer to the function specific documentation below for usage guidelines.\r
4863    */\r
4864 \r
4865   /**\r
4866    * @addtogroup PID\r
4867    * @{\r
4868    */\r
4869 \r
4870   /**\r
4871    * @brief  Process function for the floating-point PID Control.\r
4872    * @param[in,out] S   is an instance of the floating-point PID Control structure\r
4873    * @param[in]     in  input sample to process\r
4874    * @return out processed output sample.\r
4875    */\r
4876   CMSIS_INLINE __STATIC_INLINE float32_t arm_pid_f32(\r
4877   arm_pid_instance_f32 * S,\r
4878   float32_t in)\r
4879   {\r
4880     float32_t out;\r
4881 \r
4882     /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]  */\r
4883     out = (S->A0 * in) +\r
4884       (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);\r
4885 \r
4886     /* Update state */\r
4887     S->state[1] = S->state[0];\r
4888     S->state[0] = in;\r
4889     S->state[2] = out;\r
4890 \r
4891     /* return to application */\r
4892     return (out);\r
4893 \r
4894   }\r
4895 \r
4896   /**\r
4897    * @brief  Process function for the Q31 PID Control.\r
4898    * @param[in,out] S  points to an instance of the Q31 PID Control structure\r
4899    * @param[in]     in  input sample to process\r
4900    * @return out processed output sample.\r
4901    *\r
4902    * <b>Scaling and Overflow Behavior:</b>\r
4903    * \par\r
4904    * The function is implemented using an internal 64-bit accumulator.\r
4905    * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.\r
4906    * Thus, if the accumulator result overflows it wraps around rather than clip.\r
4907    * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.\r
4908    * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.\r
4909    */\r
4910   CMSIS_INLINE __STATIC_INLINE q31_t arm_pid_q31(\r
4911   arm_pid_instance_q31 * S,\r
4912   q31_t in)\r
4913   {\r
4914     q63_t acc;\r
4915     q31_t out;\r
4916 \r
4917     /* acc = A0 * x[n]  */\r
4918     acc = (q63_t) S->A0 * in;\r
4919 \r
4920     /* acc += A1 * x[n-1] */\r
4921     acc += (q63_t) S->A1 * S->state[0];\r
4922 \r
4923     /* acc += A2 * x[n-2]  */\r
4924     acc += (q63_t) S->A2 * S->state[1];\r
4925 \r
4926     /* convert output to 1.31 format to add y[n-1] */\r
4927     out = (q31_t) (acc >> 31u);\r
4928 \r
4929     /* out += y[n-1] */\r
4930     out += S->state[2];\r
4931 \r
4932     /* Update state */\r
4933     S->state[1] = S->state[0];\r
4934     S->state[0] = in;\r
4935     S->state[2] = out;\r
4936 \r
4937     /* return to application */\r
4938     return (out);\r
4939   }\r
4940 \r
4941 \r
4942   /**\r
4943    * @brief  Process function for the Q15 PID Control.\r
4944    * @param[in,out] S   points to an instance of the Q15 PID Control structure\r
4945    * @param[in]     in  input sample to process\r
4946    * @return out processed output sample.\r
4947    *\r
4948    * <b>Scaling and Overflow Behavior:</b>\r
4949    * \par\r
4950    * The function is implemented using a 64-bit internal accumulator.\r
4951    * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.\r
4952    * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.\r
4953    * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.\r
4954    * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.\r
4955    * Lastly, the accumulator is saturated to yield a result in 1.15 format.\r
4956    */\r
4957   CMSIS_INLINE __STATIC_INLINE q15_t arm_pid_q15(\r
4958   arm_pid_instance_q15 * S,\r
4959   q15_t in)\r
4960   {\r
4961     q63_t acc;\r
4962     q15_t out;\r
4963 \r
4964 #if defined (ARM_MATH_DSP)\r
4965     __SIMD32_TYPE *vstate;\r
4966 \r
4967     /* Implementation of PID controller */\r
4968 \r
4969     /* acc = A0 * x[n]  */\r
4970     acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);\r
4971 \r
4972     /* acc += A1 * x[n-1] + A2 * x[n-2]  */\r
4973     vstate = __SIMD32_CONST(S->state);\r
4974     acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (uint64_t)acc);\r
4975 #else\r
4976     /* acc = A0 * x[n]  */\r
4977     acc = ((q31_t) S->A0) * in;\r
4978 \r
4979     /* acc += A1 * x[n-1] + A2 * x[n-2]  */\r
4980     acc += (q31_t) S->A1 * S->state[0];\r
4981     acc += (q31_t) S->A2 * S->state[1];\r
4982 #endif\r
4983 \r
4984     /* acc += y[n-1] */\r
4985     acc += (q31_t) S->state[2] << 15;\r
4986 \r
4987     /* saturate the output */\r
4988     out = (q15_t) (__SSAT((acc >> 15), 16));\r
4989 \r
4990     /* Update state */\r
4991     S->state[1] = S->state[0];\r
4992     S->state[0] = in;\r
4993     S->state[2] = out;\r
4994 \r
4995     /* return to application */\r
4996     return (out);\r
4997   }\r
4998 \r
4999   /**\r
5000    * @} end of PID group\r
5001    */\r
5002 \r
5003 \r
5004   /**\r
5005    * @brief Floating-point matrix inverse.\r
5006    * @param[in]  src   points to the instance of the input floating-point matrix structure.\r
5007    * @param[out] dst   points to the instance of the output floating-point matrix structure.\r
5008    * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.\r
5009    * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.\r
5010    */\r
5011   arm_status arm_mat_inverse_f32(\r
5012   const arm_matrix_instance_f32 * src,\r
5013   arm_matrix_instance_f32 * dst);\r
5014 \r
5015 \r
5016   /**\r
5017    * @brief Floating-point matrix inverse.\r
5018    * @param[in]  src   points to the instance of the input floating-point matrix structure.\r
5019    * @param[out] dst   points to the instance of the output floating-point matrix structure.\r
5020    * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.\r
5021    * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.\r
5022    */\r
5023   arm_status arm_mat_inverse_f64(\r
5024   const arm_matrix_instance_f64 * src,\r
5025   arm_matrix_instance_f64 * dst);\r
5026 \r
5027 \r
5028 \r
5029   /**\r
5030    * @ingroup groupController\r
5031    */\r
5032 \r
5033   /**\r
5034    * @defgroup clarke Vector Clarke Transform\r
5035    * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.\r
5036    * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents\r
5037    * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.\r
5038    * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below\r
5039    * \image html clarke.gif Stator current space vector and its components in (a,b).\r
5040    * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>\r
5041    * can be calculated using only <code>Ia</code> and <code>Ib</code>.\r
5042    *\r
5043    * The function operates on a single sample of data and each call to the function returns the processed output.\r
5044    * The library provides separate functions for Q31 and floating-point data types.\r
5045    * \par Algorithm\r
5046    * \image html clarkeFormula.gif\r
5047    * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and\r
5048    * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.\r
5049    * \par Fixed-Point Behavior\r
5050    * Care must be taken when using the Q31 version of the Clarke transform.\r
5051    * In particular, the overflow and saturation behavior of the accumulator used must be considered.\r
5052    * Refer to the function specific documentation below for usage guidelines.\r
5053    */\r
5054 \r
5055   /**\r
5056    * @addtogroup clarke\r
5057    * @{\r
5058    */\r
5059 \r
5060   /**\r
5061    *\r
5062    * @brief  Floating-point Clarke transform\r
5063    * @param[in]  Ia       input three-phase coordinate <code>a</code>\r
5064    * @param[in]  Ib       input three-phase coordinate <code>b</code>\r
5065    * @param[out] pIalpha  points to output two-phase orthogonal vector axis alpha\r
5066    * @param[out] pIbeta   points to output two-phase orthogonal vector axis beta\r
5067    */\r
5068   CMSIS_INLINE __STATIC_INLINE void arm_clarke_f32(\r
5069   float32_t Ia,\r
5070   float32_t Ib,\r
5071   float32_t * pIalpha,\r
5072   float32_t * pIbeta)\r
5073   {\r
5074     /* Calculate pIalpha using the equation, pIalpha = Ia */\r
5075     *pIalpha = Ia;\r
5076 \r
5077     /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */\r
5078     *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);\r
5079   }\r
5080 \r
5081 \r
5082   /**\r
5083    * @brief  Clarke transform for Q31 version\r
5084    * @param[in]  Ia       input three-phase coordinate <code>a</code>\r
5085    * @param[in]  Ib       input three-phase coordinate <code>b</code>\r
5086    * @param[out] pIalpha  points to output two-phase orthogonal vector axis alpha\r
5087    * @param[out] pIbeta   points to output two-phase orthogonal vector axis beta\r
5088    *\r
5089    * <b>Scaling and Overflow Behavior:</b>\r
5090    * \par\r
5091    * The function is implemented using an internal 32-bit accumulator.\r
5092    * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.\r
5093    * There is saturation on the addition, hence there is no risk of overflow.\r
5094    */\r
5095   CMSIS_INLINE __STATIC_INLINE void arm_clarke_q31(\r
5096   q31_t Ia,\r
5097   q31_t Ib,\r
5098   q31_t * pIalpha,\r
5099   q31_t * pIbeta)\r
5100   {\r
5101     q31_t product1, product2;                    /* Temporary variables used to store intermediate results */\r
5102 \r
5103     /* Calculating pIalpha from Ia by equation pIalpha = Ia */\r
5104     *pIalpha = Ia;\r
5105 \r
5106     /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */\r
5107     product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);\r
5108 \r
5109     /* Intermediate product is calculated by (2/sqrt(3) * Ib) */\r
5110     product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);\r
5111 \r
5112     /* pIbeta is calculated by adding the intermediate products */\r
5113     *pIbeta = __QADD(product1, product2);\r
5114   }\r
5115 \r
5116   /**\r
5117    * @} end of clarke group\r
5118    */\r
5119 \r
5120   /**\r
5121    * @brief  Converts the elements of the Q7 vector to Q31 vector.\r
5122    * @param[in]  pSrc       input pointer\r
5123    * @param[out] pDst       output pointer\r
5124    * @param[in]  blockSize  number of samples to process\r
5125    */\r
5126   void arm_q7_to_q31(\r
5127   q7_t * pSrc,\r
5128   q31_t * pDst,\r
5129   uint32_t blockSize);\r
5130 \r
5131 \r
5132 \r
5133   /**\r
5134    * @ingroup groupController\r
5135    */\r
5136 \r
5137   /**\r
5138    * @defgroup inv_clarke Vector Inverse Clarke Transform\r
5139    * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.\r
5140    *\r
5141    * The function operates on a single sample of data and each call to the function returns the processed output.\r
5142    * The library provides separate functions for Q31 and floating-point data types.\r
5143    * \par Algorithm\r
5144    * \image html clarkeInvFormula.gif\r
5145    * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and\r
5146    * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.\r
5147    * \par Fixed-Point Behavior\r
5148    * Care must be taken when using the Q31 version of the Clarke transform.\r
5149    * In particular, the overflow and saturation behavior of the accumulator used must be considered.\r
5150    * Refer to the function specific documentation below for usage guidelines.\r
5151    */\r
5152 \r
5153   /**\r
5154    * @addtogroup inv_clarke\r
5155    * @{\r
5156    */\r
5157 \r
5158    /**\r
5159    * @brief  Floating-point Inverse Clarke transform\r
5160    * @param[in]  Ialpha  input two-phase orthogonal vector axis alpha\r
5161    * @param[in]  Ibeta   input two-phase orthogonal vector axis beta\r
5162    * @param[out] pIa     points to output three-phase coordinate <code>a</code>\r
5163    * @param[out] pIb     points to output three-phase coordinate <code>b</code>\r
5164    */\r
5165   CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_f32(\r
5166   float32_t Ialpha,\r
5167   float32_t Ibeta,\r
5168   float32_t * pIa,\r
5169   float32_t * pIb)\r
5170   {\r
5171     /* Calculating pIa from Ialpha by equation pIa = Ialpha */\r
5172     *pIa = Ialpha;\r
5173 \r
5174     /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */\r
5175     *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;\r
5176   }\r
5177 \r
5178 \r
5179   /**\r
5180    * @brief  Inverse Clarke transform for Q31 version\r
5181    * @param[in]  Ialpha  input two-phase orthogonal vector axis alpha\r
5182    * @param[in]  Ibeta   input two-phase orthogonal vector axis beta\r
5183    * @param[out] pIa     points to output three-phase coordinate <code>a</code>\r
5184    * @param[out] pIb     points to output three-phase coordinate <code>b</code>\r
5185    *\r
5186    * <b>Scaling and Overflow Behavior:</b>\r
5187    * \par\r
5188    * The function is implemented using an internal 32-bit accumulator.\r
5189    * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.\r
5190    * There is saturation on the subtraction, hence there is no risk of overflow.\r
5191    */\r
5192   CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_q31(\r
5193   q31_t Ialpha,\r
5194   q31_t Ibeta,\r
5195   q31_t * pIa,\r
5196   q31_t * pIb)\r
5197   {\r
5198     q31_t product1, product2;                    /* Temporary variables used to store intermediate results */\r
5199 \r
5200     /* Calculating pIa from Ialpha by equation pIa = Ialpha */\r
5201     *pIa = Ialpha;\r
5202 \r
5203     /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */\r
5204     product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);\r
5205 \r
5206     /* Intermediate product is calculated by (1/sqrt(3) * pIb) */\r
5207     product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);\r
5208 \r
5209     /* pIb is calculated by subtracting the products */\r
5210     *pIb = __QSUB(product2, product1);\r
5211   }\r
5212 \r
5213   /**\r
5214    * @} end of inv_clarke group\r
5215    */\r
5216 \r
5217   /**\r
5218    * @brief  Converts the elements of the Q7 vector to Q15 vector.\r
5219    * @param[in]  pSrc       input pointer\r
5220    * @param[out] pDst       output pointer\r
5221    * @param[in]  blockSize  number of samples to process\r
5222    */\r
5223   void arm_q7_to_q15(\r
5224   q7_t * pSrc,\r
5225   q15_t * pDst,\r
5226   uint32_t blockSize);\r
5227 \r
5228 \r
5229 \r
5230   /**\r
5231    * @ingroup groupController\r
5232    */\r
5233 \r
5234   /**\r
5235    * @defgroup park Vector Park Transform\r
5236    *\r
5237    * Forward Park transform converts the input two-coordinate vector to flux and torque components.\r
5238    * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents\r
5239    * from the stationary to the moving reference frame and control the spatial relationship between\r
5240    * the stator vector current and rotor flux vector.\r
5241    * If we consider the d axis aligned with the rotor flux, the diagram below shows the\r
5242    * current vector and the relationship from the two reference frames:\r
5243    * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"\r
5244    *\r
5245    * The function operates on a single sample of data and each call to the function returns the processed output.\r
5246    * The library provides separate functions for Q31 and floating-point data types.\r
5247    * \par Algorithm\r
5248    * \image html parkFormula.gif\r
5249    * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,\r
5250    * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the\r
5251    * cosine and sine values of theta (rotor flux position).\r
5252    * \par Fixed-Point Behavior\r
5253    * Care must be taken when using the Q31 version of the Park transform.\r
5254    * In particular, the overflow and saturation behavior of the accumulator used must be considered.\r
5255    * Refer to the function specific documentation below for usage guidelines.\r
5256    */\r
5257 \r
5258   /**\r
5259    * @addtogroup park\r
5260    * @{\r
5261    */\r
5262 \r
5263   /**\r
5264    * @brief Floating-point Park transform\r
5265    * @param[in]  Ialpha  input two-phase vector coordinate alpha\r
5266    * @param[in]  Ibeta   input two-phase vector coordinate beta\r
5267    * @param[out] pId     points to output   rotor reference frame d\r
5268    * @param[out] pIq     points to output   rotor reference frame q\r
5269    * @param[in]  sinVal  sine value of rotation angle theta\r
5270    * @param[in]  cosVal  cosine value of rotation angle theta\r
5271    *\r
5272    * The function implements the forward Park transform.\r
5273    *\r
5274    */\r
5275   CMSIS_INLINE __STATIC_INLINE void arm_park_f32(\r
5276   float32_t Ialpha,\r
5277   float32_t Ibeta,\r
5278   float32_t * pId,\r
5279   float32_t * pIq,\r
5280   float32_t sinVal,\r
5281   float32_t cosVal)\r
5282   {\r
5283     /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */\r
5284     *pId = Ialpha * cosVal + Ibeta * sinVal;\r
5285 \r
5286     /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */\r
5287     *pIq = -Ialpha * sinVal + Ibeta * cosVal;\r
5288   }\r
5289 \r
5290 \r
5291   /**\r
5292    * @brief  Park transform for Q31 version\r
5293    * @param[in]  Ialpha  input two-phase vector coordinate alpha\r
5294    * @param[in]  Ibeta   input two-phase vector coordinate beta\r
5295    * @param[out] pId     points to output rotor reference frame d\r
5296    * @param[out] pIq     points to output rotor reference frame q\r
5297    * @param[in]  sinVal  sine value of rotation angle theta\r
5298    * @param[in]  cosVal  cosine value of rotation angle theta\r
5299    *\r
5300    * <b>Scaling and Overflow Behavior:</b>\r
5301    * \par\r
5302    * The function is implemented using an internal 32-bit accumulator.\r
5303    * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.\r
5304    * There is saturation on the addition and subtraction, hence there is no risk of overflow.\r
5305    */\r
5306   CMSIS_INLINE __STATIC_INLINE void arm_park_q31(\r
5307   q31_t Ialpha,\r
5308   q31_t Ibeta,\r
5309   q31_t * pId,\r
5310   q31_t * pIq,\r
5311   q31_t sinVal,\r
5312   q31_t cosVal)\r
5313   {\r
5314     q31_t product1, product2;                    /* Temporary variables used to store intermediate results */\r
5315     q31_t product3, product4;                    /* Temporary variables used to store intermediate results */\r
5316 \r
5317     /* Intermediate product is calculated by (Ialpha * cosVal) */\r
5318     product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);\r
5319 \r
5320     /* Intermediate product is calculated by (Ibeta * sinVal) */\r
5321     product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);\r
5322 \r
5323 \r
5324     /* Intermediate product is calculated by (Ialpha * sinVal) */\r
5325     product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);\r
5326 \r
5327     /* Intermediate product is calculated by (Ibeta * cosVal) */\r
5328     product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);\r
5329 \r
5330     /* Calculate pId by adding the two intermediate products 1 and 2 */\r
5331     *pId = __QADD(product1, product2);\r
5332 \r
5333     /* Calculate pIq by subtracting the two intermediate products 3 from 4 */\r
5334     *pIq = __QSUB(product4, product3);\r
5335   }\r
5336 \r
5337   /**\r
5338    * @} end of park group\r
5339    */\r
5340 \r
5341   /**\r
5342    * @brief  Converts the elements of the Q7 vector to floating-point vector.\r
5343    * @param[in]  pSrc       is input pointer\r
5344    * @param[out] pDst       is output pointer\r
5345    * @param[in]  blockSize  is the number of samples to process\r
5346    */\r
5347   void arm_q7_to_float(\r
5348   q7_t * pSrc,\r
5349   float32_t * pDst,\r
5350   uint32_t blockSize);\r
5351 \r
5352 \r
5353   /**\r
5354    * @ingroup groupController\r
5355    */\r
5356 \r
5357   /**\r
5358    * @defgroup inv_park Vector Inverse Park transform\r
5359    * Inverse Park transform converts the input flux and torque components to two-coordinate vector.\r
5360    *\r
5361    * The function operates on a single sample of data and each call to the function returns the processed output.\r
5362    * The library provides separate functions for Q31 and floating-point data types.\r
5363    * \par Algorithm\r
5364    * \image html parkInvFormula.gif\r
5365    * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,\r
5366    * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the\r
5367    * cosine and sine values of theta (rotor flux position).\r
5368    * \par Fixed-Point Behavior\r
5369    * Care must be taken when using the Q31 version of the Park transform.\r
5370    * In particular, the overflow and saturation behavior of the accumulator used must be considered.\r
5371    * Refer to the function specific documentation below for usage guidelines.\r
5372    */\r
5373 \r
5374   /**\r
5375    * @addtogroup inv_park\r
5376    * @{\r
5377    */\r
5378 \r
5379    /**\r
5380    * @brief  Floating-point Inverse Park transform\r
5381    * @param[in]  Id       input coordinate of rotor reference frame d\r
5382    * @param[in]  Iq       input coordinate of rotor reference frame q\r
5383    * @param[out] pIalpha  points to output two-phase orthogonal vector axis alpha\r
5384    * @param[out] pIbeta   points to output two-phase orthogonal vector axis beta\r
5385    * @param[in]  sinVal   sine value of rotation angle theta\r
5386    * @param[in]  cosVal   cosine value of rotation angle theta\r
5387    */\r
5388   CMSIS_INLINE __STATIC_INLINE void arm_inv_park_f32(\r
5389   float32_t Id,\r
5390   float32_t Iq,\r
5391   float32_t * pIalpha,\r
5392   float32_t * pIbeta,\r
5393   float32_t sinVal,\r
5394   float32_t cosVal)\r
5395   {\r
5396     /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */\r
5397     *pIalpha = Id * cosVal - Iq * sinVal;\r
5398 \r
5399     /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */\r
5400     *pIbeta = Id * sinVal + Iq * cosVal;\r
5401   }\r
5402 \r
5403 \r
5404   /**\r
5405    * @brief  Inverse Park transform for   Q31 version\r
5406    * @param[in]  Id       input coordinate of rotor reference frame d\r
5407    * @param[in]  Iq       input coordinate of rotor reference frame q\r
5408    * @param[out] pIalpha  points to output two-phase orthogonal vector axis alpha\r
5409    * @param[out] pIbeta   points to output two-phase orthogonal vector axis beta\r
5410    * @param[in]  sinVal   sine value of rotation angle theta\r
5411    * @param[in]  cosVal   cosine value of rotation angle theta\r
5412    *\r
5413    * <b>Scaling and Overflow Behavior:</b>\r
5414    * \par\r
5415    * The function is implemented using an internal 32-bit accumulator.\r
5416    * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.\r
5417    * There is saturation on the addition, hence there is no risk of overflow.\r
5418    */\r
5419   CMSIS_INLINE __STATIC_INLINE void arm_inv_park_q31(\r
5420   q31_t Id,\r
5421   q31_t Iq,\r
5422   q31_t * pIalpha,\r
5423   q31_t * pIbeta,\r
5424   q31_t sinVal,\r
5425   q31_t cosVal)\r
5426   {\r
5427     q31_t product1, product2;                    /* Temporary variables used to store intermediate results */\r
5428     q31_t product3, product4;                    /* Temporary variables used to store intermediate results */\r
5429 \r
5430     /* Intermediate product is calculated by (Id * cosVal) */\r
5431     product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);\r
5432 \r
5433     /* Intermediate product is calculated by (Iq * sinVal) */\r
5434     product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);\r
5435 \r
5436 \r
5437     /* Intermediate product is calculated by (Id * sinVal) */\r
5438     product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);\r
5439 \r
5440     /* Intermediate product is calculated by (Iq * cosVal) */\r
5441     product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);\r
5442 \r
5443     /* Calculate pIalpha by using the two intermediate products 1 and 2 */\r
5444     *pIalpha = __QSUB(product1, product2);\r
5445 \r
5446     /* Calculate pIbeta by using the two intermediate products 3 and 4 */\r
5447     *pIbeta = __QADD(product4, product3);\r
5448   }\r
5449 \r
5450   /**\r
5451    * @} end of Inverse park group\r
5452    */\r
5453 \r
5454 \r
5455   /**\r
5456    * @brief  Converts the elements of the Q31 vector to floating-point vector.\r
5457    * @param[in]  pSrc       is input pointer\r
5458    * @param[out] pDst       is output pointer\r
5459    * @param[in]  blockSize  is the number of samples to process\r
5460    */\r
5461   void arm_q31_to_float(\r
5462   q31_t * pSrc,\r
5463   float32_t * pDst,\r
5464   uint32_t blockSize);\r
5465 \r
5466   /**\r
5467    * @ingroup groupInterpolation\r
5468    */\r
5469 \r
5470   /**\r
5471    * @defgroup LinearInterpolate Linear Interpolation\r
5472    *\r
5473    * Linear interpolation is a method of curve fitting using linear polynomials.\r
5474    * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line\r
5475    *\r
5476    * \par\r
5477    * \image html LinearInterp.gif "Linear interpolation"\r
5478    *\r
5479    * \par\r
5480    * A  Linear Interpolate function calculates an output value(y), for the input(x)\r
5481    * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)\r
5482    *\r
5483    * \par Algorithm:\r
5484    * <pre>\r
5485    *       y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))\r
5486    *       where x0, x1 are nearest values of input x\r
5487    *             y0, y1 are nearest values to output y\r
5488    * </pre>\r
5489    *\r
5490    * \par\r
5491    * This set of functions implements Linear interpolation process\r
5492    * for Q7, Q15, Q31, and floating-point data types.  The functions operate on a single\r
5493    * sample of data and each call to the function returns a single processed value.\r
5494    * <code>S</code> points to an instance of the Linear Interpolate function data structure.\r
5495    * <code>x</code> is the input sample value. The functions returns the output value.\r
5496    *\r
5497    * \par\r
5498    * if x is outside of the table boundary, Linear interpolation returns first value of the table\r
5499    * if x is below input range and returns last value of table if x is above range.\r
5500    */\r
5501 \r
5502   /**\r
5503    * @addtogroup LinearInterpolate\r
5504    * @{\r
5505    */\r
5506 \r
5507   /**\r
5508    * @brief  Process function for the floating-point Linear Interpolation Function.\r
5509    * @param[in,out] S  is an instance of the floating-point Linear Interpolation structure\r
5510    * @param[in]     x  input sample to process\r
5511    * @return y processed output sample.\r
5512    *\r
5513    */\r
5514   CMSIS_INLINE __STATIC_INLINE float32_t arm_linear_interp_f32(\r
5515   arm_linear_interp_instance_f32 * S,\r
5516   float32_t x)\r
5517   {\r
5518     float32_t y;\r
5519     float32_t x0, x1;                            /* Nearest input values */\r
5520     float32_t y0, y1;                            /* Nearest output values */\r
5521     float32_t xSpacing = S->xSpacing;            /* spacing between input values */\r
5522     int32_t i;                                   /* Index variable */\r
5523     float32_t *pYData = S->pYData;               /* pointer to output table */\r
5524 \r
5525     /* Calculation of index */\r
5526     i = (int32_t) ((x - S->x1) / xSpacing);\r
5527 \r
5528     if (i < 0)\r
5529     {\r
5530       /* Iniatilize output for below specified range as least output value of table */\r
5531       y = pYData[0];\r
5532     }\r
5533     else if ((uint32_t)i >= S->nValues)\r
5534     {\r
5535       /* Iniatilize output for above specified range as last output value of table */\r
5536       y = pYData[S->nValues - 1];\r
5537     }\r
5538     else\r
5539     {\r
5540       /* Calculation of nearest input values */\r
5541       x0 = S->x1 +  i      * xSpacing;\r
5542       x1 = S->x1 + (i + 1) * xSpacing;\r
5543 \r
5544       /* Read of nearest output values */\r
5545       y0 = pYData[i];\r
5546       y1 = pYData[i + 1];\r
5547 \r
5548       /* Calculation of output */\r
5549       y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));\r
5550 \r
5551     }\r
5552 \r
5553     /* returns output value */\r
5554     return (y);\r
5555   }\r
5556 \r
5557 \r
5558    /**\r
5559    *\r
5560    * @brief  Process function for the Q31 Linear Interpolation Function.\r
5561    * @param[in] pYData   pointer to Q31 Linear Interpolation table\r
5562    * @param[in] x        input sample to process\r
5563    * @param[in] nValues  number of table values\r
5564    * @return y processed output sample.\r
5565    *\r
5566    * \par\r
5567    * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.\r
5568    * This function can support maximum of table size 2^12.\r
5569    *\r
5570    */\r
5571   CMSIS_INLINE __STATIC_INLINE q31_t arm_linear_interp_q31(\r
5572   q31_t * pYData,\r
5573   q31_t x,\r
5574   uint32_t nValues)\r
5575   {\r
5576     q31_t y;                                     /* output */\r
5577     q31_t y0, y1;                                /* Nearest output values */\r
5578     q31_t fract;                                 /* fractional part */\r
5579     int32_t index;                               /* Index to read nearest output values */\r
5580 \r
5581     /* Input is in 12.20 format */\r
5582     /* 12 bits for the table index */\r
5583     /* Index value calculation */\r
5584     index = ((x & (q31_t)0xFFF00000) >> 20);\r
5585 \r
5586     if (index >= (int32_t)(nValues - 1))\r
5587     {\r
5588       return (pYData[nValues - 1]);\r
5589     }\r
5590     else if (index < 0)\r
5591     {\r
5592       return (pYData[0]);\r
5593     }\r
5594     else\r
5595     {\r
5596       /* 20 bits for the fractional part */\r
5597       /* shift left by 11 to keep fract in 1.31 format */\r
5598       fract = (x & 0x000FFFFF) << 11;\r
5599 \r
5600       /* Read two nearest output values from the index in 1.31(q31) format */\r
5601       y0 = pYData[index];\r
5602       y1 = pYData[index + 1];\r
5603 \r
5604       /* Calculation of y0 * (1-fract) and y is in 2.30 format */\r
5605       y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));\r
5606 \r
5607       /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */\r
5608       y += ((q31_t) (((q63_t) y1 * fract) >> 32));\r
5609 \r
5610       /* Convert y to 1.31 format */\r
5611       return (y << 1u);\r
5612     }\r
5613   }\r
5614 \r
5615 \r
5616   /**\r
5617    *\r
5618    * @brief  Process function for the Q15 Linear Interpolation Function.\r
5619    * @param[in] pYData   pointer to Q15 Linear Interpolation table\r
5620    * @param[in] x        input sample to process\r
5621    * @param[in] nValues  number of table values\r
5622    * @return y processed output sample.\r
5623    *\r
5624    * \par\r
5625    * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.\r
5626    * This function can support maximum of table size 2^12.\r
5627    *\r
5628    */\r
5629   CMSIS_INLINE __STATIC_INLINE q15_t arm_linear_interp_q15(\r
5630   q15_t * pYData,\r
5631   q31_t x,\r
5632   uint32_t nValues)\r
5633   {\r
5634     q63_t y;                                     /* output */\r
5635     q15_t y0, y1;                                /* Nearest output values */\r
5636     q31_t fract;                                 /* fractional part */\r
5637     int32_t index;                               /* Index to read nearest output values */\r
5638 \r
5639     /* Input is in 12.20 format */\r
5640     /* 12 bits for the table index */\r
5641     /* Index value calculation */\r
5642     index = ((x & (int32_t)0xFFF00000) >> 20);\r
5643 \r
5644     if (index >= (int32_t)(nValues - 1))\r
5645     {\r
5646       return (pYData[nValues - 1]);\r
5647     }\r
5648     else if (index < 0)\r
5649     {\r
5650       return (pYData[0]);\r
5651     }\r
5652     else\r
5653     {\r
5654       /* 20 bits for the fractional part */\r
5655       /* fract is in 12.20 format */\r
5656       fract = (x & 0x000FFFFF);\r
5657 \r
5658       /* Read two nearest output values from the index */\r
5659       y0 = pYData[index];\r
5660       y1 = pYData[index + 1];\r
5661 \r
5662       /* Calculation of y0 * (1-fract) and y is in 13.35 format */\r
5663       y = ((q63_t) y0 * (0xFFFFF - fract));\r
5664 \r
5665       /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */\r
5666       y += ((q63_t) y1 * (fract));\r
5667 \r
5668       /* convert y to 1.15 format */\r
5669       return (q15_t) (y >> 20);\r
5670     }\r
5671   }\r
5672 \r
5673 \r
5674   /**\r
5675    *\r
5676    * @brief  Process function for the Q7 Linear Interpolation Function.\r
5677    * @param[in] pYData   pointer to Q7 Linear Interpolation table\r
5678    * @param[in] x        input sample to process\r
5679    * @param[in] nValues  number of table values\r
5680    * @return y processed output sample.\r
5681    *\r
5682    * \par\r
5683    * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.\r
5684    * This function can support maximum of table size 2^12.\r
5685    */\r
5686   CMSIS_INLINE __STATIC_INLINE q7_t arm_linear_interp_q7(\r
5687   q7_t * pYData,\r
5688   q31_t x,\r
5689   uint32_t nValues)\r
5690   {\r
5691     q31_t y;                                     /* output */\r
5692     q7_t y0, y1;                                 /* Nearest output values */\r
5693     q31_t fract;                                 /* fractional part */\r
5694     uint32_t index;                              /* Index to read nearest output values */\r
5695 \r
5696     /* Input is in 12.20 format */\r
5697     /* 12 bits for the table index */\r
5698     /* Index value calculation */\r
5699     if (x < 0)\r
5700     {\r
5701       return (pYData[0]);\r
5702     }\r
5703     index = (x >> 20) & 0xfff;\r
5704 \r
5705     if (index >= (nValues - 1))\r
5706     {\r
5707       return (pYData[nValues - 1]);\r
5708     }\r
5709     else\r
5710     {\r
5711       /* 20 bits for the fractional part */\r
5712       /* fract is in 12.20 format */\r
5713       fract = (x & 0x000FFFFF);\r
5714 \r
5715       /* Read two nearest output values from the index and are in 1.7(q7) format */\r
5716       y0 = pYData[index];\r
5717       y1 = pYData[index + 1];\r
5718 \r
5719       /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */\r
5720       y = ((y0 * (0xFFFFF - fract)));\r
5721 \r
5722       /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */\r
5723       y += (y1 * fract);\r
5724 \r
5725       /* convert y to 1.7(q7) format */\r
5726       return (q7_t) (y >> 20);\r
5727      }\r
5728   }\r
5729 \r
5730   /**\r
5731    * @} end of LinearInterpolate group\r
5732    */\r
5733 \r
5734   /**\r
5735    * @brief  Fast approximation to the trigonometric sine function for floating-point data.\r
5736    * @param[in] x  input value in radians.\r
5737    * @return  sin(x).\r
5738    */\r
5739   float32_t arm_sin_f32(\r
5740   float32_t x);\r
5741 \r
5742 \r
5743   /**\r
5744    * @brief  Fast approximation to the trigonometric sine function for Q31 data.\r
5745    * @param[in] x  Scaled input value in radians.\r
5746    * @return  sin(x).\r
5747    */\r
5748   q31_t arm_sin_q31(\r
5749   q31_t x);\r
5750 \r
5751 \r
5752   /**\r
5753    * @brief  Fast approximation to the trigonometric sine function for Q15 data.\r
5754    * @param[in] x  Scaled input value in radians.\r
5755    * @return  sin(x).\r
5756    */\r
5757   q15_t arm_sin_q15(\r
5758   q15_t x);\r
5759 \r
5760 \r
5761   /**\r
5762    * @brief  Fast approximation to the trigonometric cosine function for floating-point data.\r
5763    * @param[in] x  input value in radians.\r
5764    * @return  cos(x).\r
5765    */\r
5766   float32_t arm_cos_f32(\r
5767   float32_t x);\r
5768 \r
5769 \r
5770   /**\r
5771    * @brief Fast approximation to the trigonometric cosine function for Q31 data.\r
5772    * @param[in] x  Scaled input value in radians.\r
5773    * @return  cos(x).\r
5774    */\r
5775   q31_t arm_cos_q31(\r
5776   q31_t x);\r
5777 \r
5778 \r
5779   /**\r
5780    * @brief  Fast approximation to the trigonometric cosine function for Q15 data.\r
5781    * @param[in] x  Scaled input value in radians.\r
5782    * @return  cos(x).\r
5783    */\r
5784   q15_t arm_cos_q15(\r
5785   q15_t x);\r
5786 \r
5787 \r
5788   /**\r
5789    * @ingroup groupFastMath\r
5790    */\r
5791 \r
5792 \r
5793   /**\r
5794    * @defgroup SQRT Square Root\r
5795    *\r
5796    * Computes the square root of a number.\r
5797    * There are separate functions for Q15, Q31, and floating-point data types.\r
5798    * The square root function is computed using the Newton-Raphson algorithm.\r
5799    * This is an iterative algorithm of the form:\r
5800    * <pre>\r
5801    *      x1 = x0 - f(x0)/f'(x0)\r
5802    * </pre>\r
5803    * where <code>x1</code> is the current estimate,\r
5804    * <code>x0</code> is the previous estimate, and\r
5805    * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.\r
5806    * For the square root function, the algorithm reduces to:\r
5807    * <pre>\r
5808    *     x0 = in/2                         [initial guess]\r
5809    *     x1 = 1/2 * ( x0 + in / x0)        [each iteration]\r
5810    * </pre>\r
5811    */\r
5812 \r
5813 \r
5814   /**\r
5815    * @addtogroup SQRT\r
5816    * @{\r
5817    */\r
5818 \r
5819   /**\r
5820    * @brief  Floating-point square root function.\r
5821    * @param[in]  in    input value.\r
5822    * @param[out] pOut  square root of input value.\r
5823    * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if\r
5824    * <code>in</code> is negative value and returns zero output for negative values.\r
5825    */\r
5826   CMSIS_INLINE __STATIC_INLINE arm_status arm_sqrt_f32(\r
5827   float32_t in,\r
5828   float32_t * pOut)\r
5829   {\r
5830     if (in >= 0.0f)\r
5831     {\r
5832 \r
5833 #if   (__FPU_USED == 1) && defined ( __CC_ARM   )\r
5834       *pOut = __sqrtf(in);\r
5835 #elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))\r
5836       *pOut = __builtin_sqrtf(in);\r
5837 #elif (__FPU_USED == 1) && defined(__GNUC__)\r
5838       *pOut = __builtin_sqrtf(in);\r
5839 #elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000)\r
5840       __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));\r
5841 #else\r
5842       *pOut = sqrtf(in);\r
5843 #endif\r
5844 \r
5845       return (ARM_MATH_SUCCESS);\r
5846     }\r
5847     else\r
5848     {\r
5849       *pOut = 0.0f;\r
5850       return (ARM_MATH_ARGUMENT_ERROR);\r
5851     }\r
5852   }\r
5853 \r
5854 \r
5855   /**\r
5856    * @brief Q31 square root function.\r
5857    * @param[in]  in    input value.  The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.\r
5858    * @param[out] pOut  square root of input value.\r
5859    * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if\r
5860    * <code>in</code> is negative value and returns zero output for negative values.\r
5861    */\r
5862   arm_status arm_sqrt_q31(\r
5863   q31_t in,\r
5864   q31_t * pOut);\r
5865 \r
5866 \r
5867   /**\r
5868    * @brief  Q15 square root function.\r
5869    * @param[in]  in    input value.  The range of the input value is [0 +1) or 0x0000 to 0x7FFF.\r
5870    * @param[out] pOut  square root of input value.\r
5871    * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if\r
5872    * <code>in</code> is negative value and returns zero output for negative values.\r
5873    */\r
5874   arm_status arm_sqrt_q15(\r
5875   q15_t in,\r
5876   q15_t * pOut);\r
5877 \r
5878   /**\r
5879    * @} end of SQRT group\r
5880    */\r
5881 \r
5882 \r
5883   /**\r
5884    * @brief floating-point Circular write function.\r
5885    */\r
5886   CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_f32(\r
5887   int32_t * circBuffer,\r
5888   int32_t L,\r
5889   uint16_t * writeOffset,\r
5890   int32_t bufferInc,\r
5891   const int32_t * src,\r
5892   int32_t srcInc,\r
5893   uint32_t blockSize)\r
5894   {\r
5895     uint32_t i = 0u;\r
5896     int32_t wOffset;\r
5897 \r
5898     /* Copy the value of Index pointer that points\r
5899      * to the current location where the input samples to be copied */\r
5900     wOffset = *writeOffset;\r
5901 \r
5902     /* Loop over the blockSize */\r
5903     i = blockSize;\r
5904 \r
5905     while (i > 0u)\r
5906     {\r
5907       /* copy the input sample to the circular buffer */\r
5908       circBuffer[wOffset] = *src;\r
5909 \r
5910       /* Update the input pointer */\r
5911       src += srcInc;\r
5912 \r
5913       /* Circularly update wOffset.  Watch out for positive and negative value */\r
5914       wOffset += bufferInc;\r
5915       if (wOffset >= L)\r
5916         wOffset -= L;\r
5917 \r
5918       /* Decrement the loop counter */\r
5919       i--;\r
5920     }\r
5921 \r
5922     /* Update the index pointer */\r
5923     *writeOffset = (uint16_t)wOffset;\r
5924   }\r
5925 \r
5926 \r
5927 \r
5928   /**\r
5929    * @brief floating-point Circular Read function.\r
5930    */\r
5931   CMSIS_INLINE __STATIC_INLINE void arm_circularRead_f32(\r
5932   int32_t * circBuffer,\r
5933   int32_t L,\r
5934   int32_t * readOffset,\r
5935   int32_t bufferInc,\r
5936   int32_t * dst,\r
5937   int32_t * dst_base,\r
5938   int32_t dst_length,\r
5939   int32_t dstInc,\r
5940   uint32_t blockSize)\r
5941   {\r
5942     uint32_t i = 0u;\r
5943     int32_t rOffset, dst_end;\r
5944 \r
5945     /* Copy the value of Index pointer that points\r
5946      * to the current location from where the input samples to be read */\r
5947     rOffset = *readOffset;\r
5948     dst_end = (int32_t) (dst_base + dst_length);\r
5949 \r
5950     /* Loop over the blockSize */\r
5951     i = blockSize;\r
5952 \r
5953     while (i > 0u)\r
5954     {\r
5955       /* copy the sample from the circular buffer to the destination buffer */\r
5956       *dst = circBuffer[rOffset];\r
5957 \r
5958       /* Update the input pointer */\r
5959       dst += dstInc;\r
5960 \r
5961       if (dst == (int32_t *) dst_end)\r
5962       {\r
5963         dst = dst_base;\r
5964       }\r
5965 \r
5966       /* Circularly update rOffset.  Watch out for positive and negative value  */\r
5967       rOffset += bufferInc;\r
5968 \r
5969       if (rOffset >= L)\r
5970       {\r
5971         rOffset -= L;\r
5972       }\r
5973 \r
5974       /* Decrement the loop counter */\r
5975       i--;\r
5976     }\r
5977 \r
5978     /* Update the index pointer */\r
5979     *readOffset = rOffset;\r
5980   }\r
5981 \r
5982 \r
5983   /**\r
5984    * @brief Q15 Circular write function.\r
5985    */\r
5986   CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q15(\r
5987   q15_t * circBuffer,\r
5988   int32_t L,\r
5989   uint16_t * writeOffset,\r
5990   int32_t bufferInc,\r
5991   const q15_t * src,\r
5992   int32_t srcInc,\r
5993   uint32_t blockSize)\r
5994   {\r
5995     uint32_t i = 0u;\r
5996     int32_t wOffset;\r
5997 \r
5998     /* Copy the value of Index pointer that points\r
5999      * to the current location where the input samples to be copied */\r
6000     wOffset = *writeOffset;\r
6001 \r
6002     /* Loop over the blockSize */\r
6003     i = blockSize;\r
6004 \r
6005     while (i > 0u)\r
6006     {\r
6007       /* copy the input sample to the circular buffer */\r
6008       circBuffer[wOffset] = *src;\r
6009 \r
6010       /* Update the input pointer */\r
6011       src += srcInc;\r
6012 \r
6013       /* Circularly update wOffset.  Watch out for positive and negative value */\r
6014       wOffset += bufferInc;\r
6015       if (wOffset >= L)\r
6016         wOffset -= L;\r
6017 \r
6018       /* Decrement the loop counter */\r
6019       i--;\r
6020     }\r
6021 \r
6022     /* Update the index pointer */\r
6023     *writeOffset = (uint16_t)wOffset;\r
6024   }\r
6025 \r
6026 \r
6027   /**\r
6028    * @brief Q15 Circular Read function.\r
6029    */\r
6030   CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q15(\r
6031   q15_t * circBuffer,\r
6032   int32_t L,\r
6033   int32_t * readOffset,\r
6034   int32_t bufferInc,\r
6035   q15_t * dst,\r
6036   q15_t * dst_base,\r
6037   int32_t dst_length,\r
6038   int32_t dstInc,\r
6039   uint32_t blockSize)\r
6040   {\r
6041     uint32_t i = 0;\r
6042     int32_t rOffset, dst_end;\r
6043 \r
6044     /* Copy the value of Index pointer that points\r
6045      * to the current location from where the input samples to be read */\r
6046     rOffset = *readOffset;\r
6047 \r
6048     dst_end = (int32_t) (dst_base + dst_length);\r
6049 \r
6050     /* Loop over the blockSize */\r
6051     i = blockSize;\r
6052 \r
6053     while (i > 0u)\r
6054     {\r
6055       /* copy the sample from the circular buffer to the destination buffer */\r
6056       *dst = circBuffer[rOffset];\r
6057 \r
6058       /* Update the input pointer */\r
6059       dst += dstInc;\r
6060 \r
6061       if (dst == (q15_t *) dst_end)\r
6062       {\r
6063         dst = dst_base;\r
6064       }\r
6065 \r
6066       /* Circularly update wOffset.  Watch out for positive and negative value */\r
6067       rOffset += bufferInc;\r
6068 \r
6069       if (rOffset >= L)\r
6070       {\r
6071         rOffset -= L;\r
6072       }\r
6073 \r
6074       /* Decrement the loop counter */\r
6075       i--;\r
6076     }\r
6077 \r
6078     /* Update the index pointer */\r
6079     *readOffset = rOffset;\r
6080   }\r
6081 \r
6082 \r
6083   /**\r
6084    * @brief Q7 Circular write function.\r
6085    */\r
6086   CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q7(\r
6087   q7_t * circBuffer,\r
6088   int32_t L,\r
6089   uint16_t * writeOffset,\r
6090   int32_t bufferInc,\r
6091   const q7_t * src,\r
6092   int32_t srcInc,\r
6093   uint32_t blockSize)\r
6094   {\r
6095     uint32_t i = 0u;\r
6096     int32_t wOffset;\r
6097 \r
6098     /* Copy the value of Index pointer that points\r
6099      * to the current location where the input samples to be copied */\r
6100     wOffset = *writeOffset;\r
6101 \r
6102     /* Loop over the blockSize */\r
6103     i = blockSize;\r
6104 \r
6105     while (i > 0u)\r
6106     {\r
6107       /* copy the input sample to the circular buffer */\r
6108       circBuffer[wOffset] = *src;\r
6109 \r
6110       /* Update the input pointer */\r
6111       src += srcInc;\r
6112 \r
6113       /* Circularly update wOffset.  Watch out for positive and negative value */\r
6114       wOffset += bufferInc;\r
6115       if (wOffset >= L)\r
6116         wOffset -= L;\r
6117 \r
6118       /* Decrement the loop counter */\r
6119       i--;\r
6120     }\r
6121 \r
6122     /* Update the index pointer */\r
6123     *writeOffset = (uint16_t)wOffset;\r
6124   }\r
6125 \r
6126 \r
6127   /**\r
6128    * @brief Q7 Circular Read function.\r
6129    */\r
6130   CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q7(\r
6131   q7_t * circBuffer,\r
6132   int32_t L,\r
6133   int32_t * readOffset,\r
6134   int32_t bufferInc,\r
6135   q7_t * dst,\r
6136   q7_t * dst_base,\r
6137   int32_t dst_length,\r
6138   int32_t dstInc,\r
6139   uint32_t blockSize)\r
6140   {\r
6141     uint32_t i = 0;\r
6142     int32_t rOffset, dst_end;\r
6143 \r
6144     /* Copy the value of Index pointer that points\r
6145      * to the current location from where the input samples to be read */\r
6146     rOffset = *readOffset;\r
6147 \r
6148     dst_end = (int32_t) (dst_base + dst_length);\r
6149 \r
6150     /* Loop over the blockSize */\r
6151     i = blockSize;\r
6152 \r
6153     while (i > 0u)\r
6154     {\r
6155       /* copy the sample from the circular buffer to the destination buffer */\r
6156       *dst = circBuffer[rOffset];\r
6157 \r
6158       /* Update the input pointer */\r
6159       dst += dstInc;\r
6160 \r
6161       if (dst == (q7_t *) dst_end)\r
6162       {\r
6163         dst = dst_base;\r
6164       }\r
6165 \r
6166       /* Circularly update rOffset.  Watch out for positive and negative value */\r
6167       rOffset += bufferInc;\r
6168 \r
6169       if (rOffset >= L)\r
6170       {\r
6171         rOffset -= L;\r
6172       }\r
6173 \r
6174       /* Decrement the loop counter */\r
6175       i--;\r
6176     }\r
6177 \r
6178     /* Update the index pointer */\r
6179     *readOffset = rOffset;\r
6180   }\r
6181 \r
6182 \r
6183   /**\r
6184    * @brief  Sum of the squares of the elements of a Q31 vector.\r
6185    * @param[in]  pSrc       is input pointer\r
6186    * @param[in]  blockSize  is the number of samples to process\r
6187    * @param[out] pResult    is output value.\r
6188    */\r
6189   void arm_power_q31(\r
6190   q31_t * pSrc,\r
6191   uint32_t blockSize,\r
6192   q63_t * pResult);\r
6193 \r
6194 \r
6195   /**\r
6196    * @brief  Sum of the squares of the elements of a floating-point vector.\r
6197    * @param[in]  pSrc       is input pointer\r
6198    * @param[in]  blockSize  is the number of samples to process\r
6199    * @param[out] pResult    is output value.\r
6200    */\r
6201   void arm_power_f32(\r
6202   float32_t * pSrc,\r
6203   uint32_t blockSize,\r
6204   float32_t * pResult);\r
6205 \r
6206 \r
6207   /**\r
6208    * @brief  Sum of the squares of the elements of a Q15 vector.\r
6209    * @param[in]  pSrc       is input pointer\r
6210    * @param[in]  blockSize  is the number of samples to process\r
6211    * @param[out] pResult    is output value.\r
6212    */\r
6213   void arm_power_q15(\r
6214   q15_t * pSrc,\r
6215   uint32_t blockSize,\r
6216   q63_t * pResult);\r
6217 \r
6218 \r
6219   /**\r
6220    * @brief  Sum of the squares of the elements of a Q7 vector.\r
6221    * @param[in]  pSrc       is input pointer\r
6222    * @param[in]  blockSize  is the number of samples to process\r
6223    * @param[out] pResult    is output value.\r
6224    */\r
6225   void arm_power_q7(\r
6226   q7_t * pSrc,\r
6227   uint32_t blockSize,\r
6228   q31_t * pResult);\r
6229 \r
6230 \r
6231   /**\r
6232    * @brief  Mean value of a Q7 vector.\r
6233    * @param[in]  pSrc       is input pointer\r
6234    * @param[in]  blockSize  is the number of samples to process\r
6235    * @param[out] pResult    is output value.\r
6236    */\r
6237   void arm_mean_q7(\r
6238   q7_t * pSrc,\r
6239   uint32_t blockSize,\r
6240   q7_t * pResult);\r
6241 \r
6242 \r
6243   /**\r
6244    * @brief  Mean value of a Q15 vector.\r
6245    * @param[in]  pSrc       is input pointer\r
6246    * @param[in]  blockSize  is the number of samples to process\r
6247    * @param[out] pResult    is output value.\r
6248    */\r
6249   void arm_mean_q15(\r
6250   q15_t * pSrc,\r
6251   uint32_t blockSize,\r
6252   q15_t * pResult);\r
6253 \r
6254 \r
6255   /**\r
6256    * @brief  Mean value of a Q31 vector.\r
6257    * @param[in]  pSrc       is input pointer\r
6258    * @param[in]  blockSize  is the number of samples to process\r
6259    * @param[out] pResult    is output value.\r
6260    */\r
6261   void arm_mean_q31(\r
6262   q31_t * pSrc,\r
6263   uint32_t blockSize,\r
6264   q31_t * pResult);\r
6265 \r
6266 \r
6267   /**\r
6268    * @brief  Mean value of a floating-point vector.\r
6269    * @param[in]  pSrc       is input pointer\r
6270    * @param[in]  blockSize  is the number of samples to process\r
6271    * @param[out] pResult    is output value.\r
6272    */\r
6273   void arm_mean_f32(\r
6274   float32_t * pSrc,\r
6275   uint32_t blockSize,\r
6276   float32_t * pResult);\r
6277 \r
6278 \r
6279   /**\r
6280    * @brief  Variance of the elements of a floating-point vector.\r
6281    * @param[in]  pSrc       is input pointer\r
6282    * @param[in]  blockSize  is the number of samples to process\r
6283    * @param[out] pResult    is output value.\r
6284    */\r
6285   void arm_var_f32(\r
6286   float32_t * pSrc,\r
6287   uint32_t blockSize,\r
6288   float32_t * pResult);\r
6289 \r
6290 \r
6291   /**\r
6292    * @brief  Variance of the elements of a Q31 vector.\r
6293    * @param[in]  pSrc       is input pointer\r
6294    * @param[in]  blockSize  is the number of samples to process\r
6295    * @param[out] pResult    is output value.\r
6296    */\r
6297   void arm_var_q31(\r
6298   q31_t * pSrc,\r
6299   uint32_t blockSize,\r
6300   q31_t * pResult);\r
6301 \r
6302 \r
6303   /**\r
6304    * @brief  Variance of the elements of a Q15 vector.\r
6305    * @param[in]  pSrc       is input pointer\r
6306    * @param[in]  blockSize  is the number of samples to process\r
6307    * @param[out] pResult    is output value.\r
6308    */\r
6309   void arm_var_q15(\r
6310   q15_t * pSrc,\r
6311   uint32_t blockSize,\r
6312   q15_t * pResult);\r
6313 \r
6314 \r
6315   /**\r
6316    * @brief  Root Mean Square of the elements of a floating-point vector.\r
6317    * @param[in]  pSrc       is input pointer\r
6318    * @param[in]  blockSize  is the number of samples to process\r
6319    * @param[out] pResult    is output value.\r
6320    */\r
6321   void arm_rms_f32(\r
6322   float32_t * pSrc,\r
6323   uint32_t blockSize,\r
6324   float32_t * pResult);\r
6325 \r
6326 \r
6327   /**\r
6328    * @brief  Root Mean Square of the elements of a Q31 vector.\r
6329    * @param[in]  pSrc       is input pointer\r
6330    * @param[in]  blockSize  is the number of samples to process\r
6331    * @param[out] pResult    is output value.\r
6332    */\r
6333   void arm_rms_q31(\r
6334   q31_t * pSrc,\r
6335   uint32_t blockSize,\r
6336   q31_t * pResult);\r
6337 \r
6338 \r
6339   /**\r
6340    * @brief  Root Mean Square of the elements of a Q15 vector.\r
6341    * @param[in]  pSrc       is input pointer\r
6342    * @param[in]  blockSize  is the number of samples to process\r
6343    * @param[out] pResult    is output value.\r
6344    */\r
6345   void arm_rms_q15(\r
6346   q15_t * pSrc,\r
6347   uint32_t blockSize,\r
6348   q15_t * pResult);\r
6349 \r
6350 \r
6351   /**\r
6352    * @brief  Standard deviation of the elements of a floating-point vector.\r
6353    * @param[in]  pSrc       is input pointer\r
6354    * @param[in]  blockSize  is the number of samples to process\r
6355    * @param[out] pResult    is output value.\r
6356    */\r
6357   void arm_std_f32(\r
6358   float32_t * pSrc,\r
6359   uint32_t blockSize,\r
6360   float32_t * pResult);\r
6361 \r
6362 \r
6363   /**\r
6364    * @brief  Standard deviation of the elements of a Q31 vector.\r
6365    * @param[in]  pSrc       is input pointer\r
6366    * @param[in]  blockSize  is the number of samples to process\r
6367    * @param[out] pResult    is output value.\r
6368    */\r
6369   void arm_std_q31(\r
6370   q31_t * pSrc,\r
6371   uint32_t blockSize,\r
6372   q31_t * pResult);\r
6373 \r
6374 \r
6375   /**\r
6376    * @brief  Standard deviation of the elements of a Q15 vector.\r
6377    * @param[in]  pSrc       is input pointer\r
6378    * @param[in]  blockSize  is the number of samples to process\r
6379    * @param[out] pResult    is output value.\r
6380    */\r
6381   void arm_std_q15(\r
6382   q15_t * pSrc,\r
6383   uint32_t blockSize,\r
6384   q15_t * pResult);\r
6385 \r
6386 \r
6387   /**\r
6388    * @brief  Floating-point complex magnitude\r
6389    * @param[in]  pSrc        points to the complex input vector\r
6390    * @param[out] pDst        points to the real output vector\r
6391    * @param[in]  numSamples  number of complex samples in the input vector\r
6392    */\r
6393   void arm_cmplx_mag_f32(\r
6394   float32_t * pSrc,\r
6395   float32_t * pDst,\r
6396   uint32_t numSamples);\r
6397 \r
6398 \r
6399   /**\r
6400    * @brief  Q31 complex magnitude\r
6401    * @param[in]  pSrc        points to the complex input vector\r
6402    * @param[out] pDst        points to the real output vector\r
6403    * @param[in]  numSamples  number of complex samples in the input vector\r
6404    */\r
6405   void arm_cmplx_mag_q31(\r
6406   q31_t * pSrc,\r
6407   q31_t * pDst,\r
6408   uint32_t numSamples);\r
6409 \r
6410 \r
6411   /**\r
6412    * @brief  Q15 complex magnitude\r
6413    * @param[in]  pSrc        points to the complex input vector\r
6414    * @param[out] pDst        points to the real output vector\r
6415    * @param[in]  numSamples  number of complex samples in the input vector\r
6416    */\r
6417   void arm_cmplx_mag_q15(\r
6418   q15_t * pSrc,\r
6419   q15_t * pDst,\r
6420   uint32_t numSamples);\r
6421 \r
6422 \r
6423   /**\r
6424    * @brief  Q15 complex dot product\r
6425    * @param[in]  pSrcA       points to the first input vector\r
6426    * @param[in]  pSrcB       points to the second input vector\r
6427    * @param[in]  numSamples  number of complex samples in each vector\r
6428    * @param[out] realResult  real part of the result returned here\r
6429    * @param[out] imagResult  imaginary part of the result returned here\r
6430    */\r
6431   void arm_cmplx_dot_prod_q15(\r
6432   q15_t * pSrcA,\r
6433   q15_t * pSrcB,\r
6434   uint32_t numSamples,\r
6435   q31_t * realResult,\r
6436   q31_t * imagResult);\r
6437 \r
6438 \r
6439   /**\r
6440    * @brief  Q31 complex dot product\r
6441    * @param[in]  pSrcA       points to the first input vector\r
6442    * @param[in]  pSrcB       points to the second input vector\r
6443    * @param[in]  numSamples  number of complex samples in each vector\r
6444    * @param[out] realResult  real part of the result returned here\r
6445    * @param[out] imagResult  imaginary part of the result returned here\r
6446    */\r
6447   void arm_cmplx_dot_prod_q31(\r
6448   q31_t * pSrcA,\r
6449   q31_t * pSrcB,\r
6450   uint32_t numSamples,\r
6451   q63_t * realResult,\r
6452   q63_t * imagResult);\r
6453 \r
6454 \r
6455   /**\r
6456    * @brief  Floating-point complex dot product\r
6457    * @param[in]  pSrcA       points to the first input vector\r
6458    * @param[in]  pSrcB       points to the second input vector\r
6459    * @param[in]  numSamples  number of complex samples in each vector\r
6460    * @param[out] realResult  real part of the result returned here\r
6461    * @param[out] imagResult  imaginary part of the result returned here\r
6462    */\r
6463   void arm_cmplx_dot_prod_f32(\r
6464   float32_t * pSrcA,\r
6465   float32_t * pSrcB,\r
6466   uint32_t numSamples,\r
6467   float32_t * realResult,\r
6468   float32_t * imagResult);\r
6469 \r
6470 \r
6471   /**\r
6472    * @brief  Q15 complex-by-real multiplication\r
6473    * @param[in]  pSrcCmplx   points to the complex input vector\r
6474    * @param[in]  pSrcReal    points to the real input vector\r
6475    * @param[out] pCmplxDst   points to the complex output vector\r
6476    * @param[in]  numSamples  number of samples in each vector\r
6477    */\r
6478   void arm_cmplx_mult_real_q15(\r
6479   q15_t * pSrcCmplx,\r
6480   q15_t * pSrcReal,\r
6481   q15_t * pCmplxDst,\r
6482   uint32_t numSamples);\r
6483 \r
6484 \r
6485   /**\r
6486    * @brief  Q31 complex-by-real multiplication\r
6487    * @param[in]  pSrcCmplx   points to the complex input vector\r
6488    * @param[in]  pSrcReal    points to the real input vector\r
6489    * @param[out] pCmplxDst   points to the complex output vector\r
6490    * @param[in]  numSamples  number of samples in each vector\r
6491    */\r
6492   void arm_cmplx_mult_real_q31(\r
6493   q31_t * pSrcCmplx,\r
6494   q31_t * pSrcReal,\r
6495   q31_t * pCmplxDst,\r
6496   uint32_t numSamples);\r
6497 \r
6498 \r
6499   /**\r
6500    * @brief  Floating-point complex-by-real multiplication\r
6501    * @param[in]  pSrcCmplx   points to the complex input vector\r
6502    * @param[in]  pSrcReal    points to the real input vector\r
6503    * @param[out] pCmplxDst   points to the complex output vector\r
6504    * @param[in]  numSamples  number of samples in each vector\r
6505    */\r
6506   void arm_cmplx_mult_real_f32(\r
6507   float32_t * pSrcCmplx,\r
6508   float32_t * pSrcReal,\r
6509   float32_t * pCmplxDst,\r
6510   uint32_t numSamples);\r
6511 \r
6512 \r
6513   /**\r
6514    * @brief  Minimum value of a Q7 vector.\r
6515    * @param[in]  pSrc       is input pointer\r
6516    * @param[in]  blockSize  is the number of samples to process\r
6517    * @param[out] result     is output pointer\r
6518    * @param[in]  index      is the array index of the minimum value in the input buffer.\r
6519    */\r
6520   void arm_min_q7(\r
6521   q7_t * pSrc,\r
6522   uint32_t blockSize,\r
6523   q7_t * result,\r
6524   uint32_t * index);\r
6525 \r
6526 \r
6527   /**\r
6528    * @brief  Minimum value of a Q15 vector.\r
6529    * @param[in]  pSrc       is input pointer\r
6530    * @param[in]  blockSize  is the number of samples to process\r
6531    * @param[out] pResult    is output pointer\r
6532    * @param[in]  pIndex     is the array index of the minimum value in the input buffer.\r
6533    */\r
6534   void arm_min_q15(\r
6535   q15_t * pSrc,\r
6536   uint32_t blockSize,\r
6537   q15_t * pResult,\r
6538   uint32_t * pIndex);\r
6539 \r
6540 \r
6541   /**\r
6542    * @brief  Minimum value of a Q31 vector.\r
6543    * @param[in]  pSrc       is input pointer\r
6544    * @param[in]  blockSize  is the number of samples to process\r
6545    * @param[out] pResult    is output pointer\r
6546    * @param[out] pIndex     is the array index of the minimum value in the input buffer.\r
6547    */\r
6548   void arm_min_q31(\r
6549   q31_t * pSrc,\r
6550   uint32_t blockSize,\r
6551   q31_t * pResult,\r
6552   uint32_t * pIndex);\r
6553 \r
6554 \r
6555   /**\r
6556    * @brief  Minimum value of a floating-point vector.\r
6557    * @param[in]  pSrc       is input pointer\r
6558    * @param[in]  blockSize  is the number of samples to process\r
6559    * @param[out] pResult    is output pointer\r
6560    * @param[out] pIndex     is the array index of the minimum value in the input buffer.\r
6561    */\r
6562   void arm_min_f32(\r
6563   float32_t * pSrc,\r
6564   uint32_t blockSize,\r
6565   float32_t * pResult,\r
6566   uint32_t * pIndex);\r
6567 \r
6568 \r
6569 /**\r
6570  * @brief Maximum value of a Q7 vector.\r
6571  * @param[in]  pSrc       points to the input buffer\r
6572  * @param[in]  blockSize  length of the input vector\r
6573  * @param[out] pResult    maximum value returned here\r
6574  * @param[out] pIndex     index of maximum value returned here\r
6575  */\r
6576   void arm_max_q7(\r
6577   q7_t * pSrc,\r
6578   uint32_t blockSize,\r
6579   q7_t * pResult,\r
6580   uint32_t * pIndex);\r
6581 \r
6582 \r
6583 /**\r
6584  * @brief Maximum value of a Q15 vector.\r
6585  * @param[in]  pSrc       points to the input buffer\r
6586  * @param[in]  blockSize  length of the input vector\r
6587  * @param[out] pResult    maximum value returned here\r
6588  * @param[out] pIndex     index of maximum value returned here\r
6589  */\r
6590   void arm_max_q15(\r
6591   q15_t * pSrc,\r
6592   uint32_t blockSize,\r
6593   q15_t * pResult,\r
6594   uint32_t * pIndex);\r
6595 \r
6596 \r
6597 /**\r
6598  * @brief Maximum value of a Q31 vector.\r
6599  * @param[in]  pSrc       points to the input buffer\r
6600  * @param[in]  blockSize  length of the input vector\r
6601  * @param[out] pResult    maximum value returned here\r
6602  * @param[out] pIndex     index of maximum value returned here\r
6603  */\r
6604   void arm_max_q31(\r
6605   q31_t * pSrc,\r
6606   uint32_t blockSize,\r
6607   q31_t * pResult,\r
6608   uint32_t * pIndex);\r
6609 \r
6610 \r
6611 /**\r
6612  * @brief Maximum value of a floating-point vector.\r
6613  * @param[in]  pSrc       points to the input buffer\r
6614  * @param[in]  blockSize  length of the input vector\r
6615  * @param[out] pResult    maximum value returned here\r
6616  * @param[out] pIndex     index of maximum value returned here\r
6617  */\r
6618   void arm_max_f32(\r
6619   float32_t * pSrc,\r
6620   uint32_t blockSize,\r
6621   float32_t * pResult,\r
6622   uint32_t * pIndex);\r
6623 \r
6624 \r
6625   /**\r
6626    * @brief  Q15 complex-by-complex multiplication\r
6627    * @param[in]  pSrcA       points to the first input vector\r
6628    * @param[in]  pSrcB       points to the second input vector\r
6629    * @param[out] pDst        points to the output vector\r
6630    * @param[in]  numSamples  number of complex samples in each vector\r
6631    */\r
6632   void arm_cmplx_mult_cmplx_q15(\r
6633   q15_t * pSrcA,\r
6634   q15_t * pSrcB,\r
6635   q15_t * pDst,\r
6636   uint32_t numSamples);\r
6637 \r
6638 \r
6639   /**\r
6640    * @brief  Q31 complex-by-complex multiplication\r
6641    * @param[in]  pSrcA       points to the first input vector\r
6642    * @param[in]  pSrcB       points to the second input vector\r
6643    * @param[out] pDst        points to the output vector\r
6644    * @param[in]  numSamples  number of complex samples in each vector\r
6645    */\r
6646   void arm_cmplx_mult_cmplx_q31(\r
6647   q31_t * pSrcA,\r
6648   q31_t * pSrcB,\r
6649   q31_t * pDst,\r
6650   uint32_t numSamples);\r
6651 \r
6652 \r
6653   /**\r
6654    * @brief  Floating-point complex-by-complex multiplication\r
6655    * @param[in]  pSrcA       points to the first input vector\r
6656    * @param[in]  pSrcB       points to the second input vector\r
6657    * @param[out] pDst        points to the output vector\r
6658    * @param[in]  numSamples  number of complex samples in each vector\r
6659    */\r
6660   void arm_cmplx_mult_cmplx_f32(\r
6661   float32_t * pSrcA,\r
6662   float32_t * pSrcB,\r
6663   float32_t * pDst,\r
6664   uint32_t numSamples);\r
6665 \r
6666 \r
6667   /**\r
6668    * @brief Converts the elements of the floating-point vector to Q31 vector.\r
6669    * @param[in]  pSrc       points to the floating-point input vector\r
6670    * @param[out] pDst       points to the Q31 output vector\r
6671    * @param[in]  blockSize  length of the input vector\r
6672    */\r
6673   void arm_float_to_q31(\r
6674   float32_t * pSrc,\r
6675   q31_t * pDst,\r
6676   uint32_t blockSize);\r
6677 \r
6678 \r
6679   /**\r
6680    * @brief Converts the elements of the floating-point vector to Q15 vector.\r
6681    * @param[in]  pSrc       points to the floating-point input vector\r
6682    * @param[out] pDst       points to the Q15 output vector\r
6683    * @param[in]  blockSize  length of the input vector\r
6684    */\r
6685   void arm_float_to_q15(\r
6686   float32_t * pSrc,\r
6687   q15_t * pDst,\r
6688   uint32_t blockSize);\r
6689 \r
6690 \r
6691   /**\r
6692    * @brief Converts the elements of the floating-point vector to Q7 vector.\r
6693    * @param[in]  pSrc       points to the floating-point input vector\r
6694    * @param[out] pDst       points to the Q7 output vector\r
6695    * @param[in]  blockSize  length of the input vector\r
6696    */\r
6697   void arm_float_to_q7(\r
6698   float32_t * pSrc,\r
6699   q7_t * pDst,\r
6700   uint32_t blockSize);\r
6701 \r
6702 \r
6703   /**\r
6704    * @brief  Converts the elements of the Q31 vector to Q15 vector.\r
6705    * @param[in]  pSrc       is input pointer\r
6706    * @param[out] pDst       is output pointer\r
6707    * @param[in]  blockSize  is the number of samples to process\r
6708    */\r
6709   void arm_q31_to_q15(\r
6710   q31_t * pSrc,\r
6711   q15_t * pDst,\r
6712   uint32_t blockSize);\r
6713 \r
6714 \r
6715   /**\r
6716    * @brief  Converts the elements of the Q31 vector to Q7 vector.\r
6717    * @param[in]  pSrc       is input pointer\r
6718    * @param[out] pDst       is output pointer\r
6719    * @param[in]  blockSize  is the number of samples to process\r
6720    */\r
6721   void arm_q31_to_q7(\r
6722   q31_t * pSrc,\r
6723   q7_t * pDst,\r
6724   uint32_t blockSize);\r
6725 \r
6726 \r
6727   /**\r
6728    * @brief  Converts the elements of the Q15 vector to floating-point vector.\r
6729    * @param[in]  pSrc       is input pointer\r
6730    * @param[out] pDst       is output pointer\r
6731    * @param[in]  blockSize  is the number of samples to process\r
6732    */\r
6733   void arm_q15_to_float(\r
6734   q15_t * pSrc,\r
6735   float32_t * pDst,\r
6736   uint32_t blockSize);\r
6737 \r
6738 \r
6739   /**\r
6740    * @brief  Converts the elements of the Q15 vector to Q31 vector.\r
6741    * @param[in]  pSrc       is input pointer\r
6742    * @param[out] pDst       is output pointer\r
6743    * @param[in]  blockSize  is the number of samples to process\r
6744    */\r
6745   void arm_q15_to_q31(\r
6746   q15_t * pSrc,\r
6747   q31_t * pDst,\r
6748   uint32_t blockSize);\r
6749 \r
6750 \r
6751   /**\r
6752    * @brief  Converts the elements of the Q15 vector to Q7 vector.\r
6753    * @param[in]  pSrc       is input pointer\r
6754    * @param[out] pDst       is output pointer\r
6755    * @param[in]  blockSize  is the number of samples to process\r
6756    */\r
6757   void arm_q15_to_q7(\r
6758   q15_t * pSrc,\r
6759   q7_t * pDst,\r
6760   uint32_t blockSize);\r
6761 \r
6762 \r
6763   /**\r
6764    * @ingroup groupInterpolation\r
6765    */\r
6766 \r
6767   /**\r
6768    * @defgroup BilinearInterpolate Bilinear Interpolation\r
6769    *\r
6770    * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.\r
6771    * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process\r
6772    * determines values between the grid points.\r
6773    * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.\r
6774    * Bilinear interpolation is often used in image processing to rescale images.\r
6775    * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.\r
6776    *\r
6777    * <b>Algorithm</b>\r
6778    * \par\r
6779    * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.\r
6780    * For floating-point, the instance structure is defined as:\r
6781    * <pre>\r
6782    *   typedef struct\r
6783    *   {\r
6784    *     uint16_t numRows;\r
6785    *     uint16_t numCols;\r
6786    *     float32_t *pData;\r
6787    * } arm_bilinear_interp_instance_f32;\r
6788    * </pre>\r
6789    *\r
6790    * \par\r
6791    * where <code>numRows</code> specifies the number of rows in the table;\r
6792    * <code>numCols</code> specifies the number of columns in the table;\r
6793    * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.\r
6794    * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.\r
6795    * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.\r
6796    *\r
6797    * \par\r
6798    * Let <code>(x, y)</code> specify the desired interpolation point.  Then define:\r
6799    * <pre>\r
6800    *     XF = floor(x)\r
6801    *     YF = floor(y)\r
6802    * </pre>\r
6803    * \par\r
6804    * The interpolated output point is computed as:\r
6805    * <pre>\r
6806    *  f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))\r
6807    *           + f(XF+1, YF) * (x-XF)*(1-(y-YF))\r
6808    *           + f(XF, YF+1) * (1-(x-XF))*(y-YF)\r
6809    *           + f(XF+1, YF+1) * (x-XF)*(y-YF)\r
6810    * </pre>\r
6811    * Note that the coordinates (x, y) contain integer and fractional components.\r
6812    * The integer components specify which portion of the table to use while the\r
6813    * fractional components control the interpolation processor.\r
6814    *\r
6815    * \par\r
6816    * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.\r
6817    */\r
6818 \r
6819   /**\r
6820    * @addtogroup BilinearInterpolate\r
6821    * @{\r
6822    */\r
6823 \r
6824 \r
6825   /**\r
6826   *\r
6827   * @brief  Floating-point bilinear interpolation.\r
6828   * @param[in,out] S  points to an instance of the interpolation structure.\r
6829   * @param[in]     X  interpolation coordinate.\r
6830   * @param[in]     Y  interpolation coordinate.\r
6831   * @return out interpolated value.\r
6832   */\r
6833   CMSIS_INLINE __STATIC_INLINE float32_t arm_bilinear_interp_f32(\r
6834   const arm_bilinear_interp_instance_f32 * S,\r
6835   float32_t X,\r
6836   float32_t Y)\r
6837   {\r
6838     float32_t out;\r
6839     float32_t f00, f01, f10, f11;\r
6840     float32_t *pData = S->pData;\r
6841     int32_t xIndex, yIndex, index;\r
6842     float32_t xdiff, ydiff;\r
6843     float32_t b1, b2, b3, b4;\r
6844 \r
6845     xIndex = (int32_t) X;\r
6846     yIndex = (int32_t) Y;\r
6847 \r
6848     /* Care taken for table outside boundary */\r
6849     /* Returns zero output when values are outside table boundary */\r
6850     if (xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1))\r
6851     {\r
6852       return (0);\r
6853     }\r
6854 \r
6855     /* Calculation of index for two nearest points in X-direction */\r
6856     index = (xIndex - 1) + (yIndex - 1) * S->numCols;\r
6857 \r
6858 \r
6859     /* Read two nearest points in X-direction */\r
6860     f00 = pData[index];\r
6861     f01 = pData[index + 1];\r
6862 \r
6863     /* Calculation of index for two nearest points in Y-direction */\r
6864     index = (xIndex - 1) + (yIndex) * S->numCols;\r
6865 \r
6866 \r
6867     /* Read two nearest points in Y-direction */\r
6868     f10 = pData[index];\r
6869     f11 = pData[index + 1];\r
6870 \r
6871     /* Calculation of intermediate values */\r
6872     b1 = f00;\r
6873     b2 = f01 - f00;\r
6874     b3 = f10 - f00;\r
6875     b4 = f00 - f01 - f10 + f11;\r
6876 \r
6877     /* Calculation of fractional part in X */\r
6878     xdiff = X - xIndex;\r
6879 \r
6880     /* Calculation of fractional part in Y */\r
6881     ydiff = Y - yIndex;\r
6882 \r
6883     /* Calculation of bi-linear interpolated output */\r
6884     out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;\r
6885 \r
6886     /* return to application */\r
6887     return (out);\r
6888   }\r
6889 \r
6890 \r
6891   /**\r
6892   *\r
6893   * @brief  Q31 bilinear interpolation.\r
6894   * @param[in,out] S  points to an instance of the interpolation structure.\r
6895   * @param[in]     X  interpolation coordinate in 12.20 format.\r
6896   * @param[in]     Y  interpolation coordinate in 12.20 format.\r
6897   * @return out interpolated value.\r
6898   */\r
6899   CMSIS_INLINE __STATIC_INLINE q31_t arm_bilinear_interp_q31(\r
6900   arm_bilinear_interp_instance_q31 * S,\r
6901   q31_t X,\r
6902   q31_t Y)\r
6903   {\r
6904     q31_t out;                                   /* Temporary output */\r
6905     q31_t acc = 0;                               /* output */\r
6906     q31_t xfract, yfract;                        /* X, Y fractional parts */\r
6907     q31_t x1, x2, y1, y2;                        /* Nearest output values */\r
6908     int32_t rI, cI;                              /* Row and column indices */\r
6909     q31_t *pYData = S->pData;                    /* pointer to output table values */\r
6910     uint32_t nCols = S->numCols;                 /* num of rows */\r
6911 \r
6912     /* Input is in 12.20 format */\r
6913     /* 12 bits for the table index */\r
6914     /* Index value calculation */\r
6915     rI = ((X & (q31_t)0xFFF00000) >> 20);\r
6916 \r
6917     /* Input is in 12.20 format */\r
6918     /* 12 bits for the table index */\r
6919     /* Index value calculation */\r
6920     cI = ((Y & (q31_t)0xFFF00000) >> 20);\r
6921 \r
6922     /* Care taken for table outside boundary */\r
6923     /* Returns zero output when values are outside table boundary */\r
6924     if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))\r
6925     {\r
6926       return (0);\r
6927     }\r
6928 \r
6929     /* 20 bits for the fractional part */\r
6930     /* shift left xfract by 11 to keep 1.31 format */\r
6931     xfract = (X & 0x000FFFFF) << 11u;\r
6932 \r
6933     /* Read two nearest output values from the index */\r
6934     x1 = pYData[(rI) + (int32_t)nCols * (cI)    ];\r
6935     x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];\r
6936 \r
6937     /* 20 bits for the fractional part */\r
6938     /* shift left yfract by 11 to keep 1.31 format */\r
6939     yfract = (Y & 0x000FFFFF) << 11u;\r
6940 \r
6941     /* Read two nearest output values from the index */\r
6942     y1 = pYData[(rI) + (int32_t)nCols * (cI + 1)    ];\r
6943     y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];\r
6944 \r
6945     /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */\r
6946     out = ((q31_t) (((q63_t) x1  * (0x7FFFFFFF - xfract)) >> 32));\r
6947     acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));\r
6948 \r
6949     /* x2 * (xfract) * (1-yfract)  in 3.29(q29) and adding to acc */\r
6950     out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));\r
6951     acc += ((q31_t) ((q63_t) out * (xfract) >> 32));\r
6952 \r
6953     /* y1 * (1 - xfract) * (yfract)  in 3.29(q29) and adding to acc */\r
6954     out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));\r
6955     acc += ((q31_t) ((q63_t) out * (yfract) >> 32));\r
6956 \r
6957     /* y2 * (xfract) * (yfract)  in 3.29(q29) and adding to acc */\r
6958     out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));\r
6959     acc += ((q31_t) ((q63_t) out * (yfract) >> 32));\r
6960 \r
6961     /* Convert acc to 1.31(q31) format */\r
6962     return ((q31_t)(acc << 2));\r
6963   }\r
6964 \r
6965 \r
6966   /**\r
6967   * @brief  Q15 bilinear interpolation.\r
6968   * @param[in,out] S  points to an instance of the interpolation structure.\r
6969   * @param[in]     X  interpolation coordinate in 12.20 format.\r
6970   * @param[in]     Y  interpolation coordinate in 12.20 format.\r
6971   * @return out interpolated value.\r
6972   */\r
6973   CMSIS_INLINE __STATIC_INLINE q15_t arm_bilinear_interp_q15(\r
6974   arm_bilinear_interp_instance_q15 * S,\r
6975   q31_t X,\r
6976   q31_t Y)\r
6977   {\r
6978     q63_t acc = 0;                               /* output */\r
6979     q31_t out;                                   /* Temporary output */\r
6980     q15_t x1, x2, y1, y2;                        /* Nearest output values */\r
6981     q31_t xfract, yfract;                        /* X, Y fractional parts */\r
6982     int32_t rI, cI;                              /* Row and column indices */\r
6983     q15_t *pYData = S->pData;                    /* pointer to output table values */\r
6984     uint32_t nCols = S->numCols;                 /* num of rows */\r
6985 \r
6986     /* Input is in 12.20 format */\r
6987     /* 12 bits for the table index */\r
6988     /* Index value calculation */\r
6989     rI = ((X & (q31_t)0xFFF00000) >> 20);\r
6990 \r
6991     /* Input is in 12.20 format */\r
6992     /* 12 bits for the table index */\r
6993     /* Index value calculation */\r
6994     cI = ((Y & (q31_t)0xFFF00000) >> 20);\r
6995 \r
6996     /* Care taken for table outside boundary */\r
6997     /* Returns zero output when values are outside table boundary */\r
6998     if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))\r
6999     {\r
7000       return (0);\r
7001     }\r
7002 \r
7003     /* 20 bits for the fractional part */\r
7004     /* xfract should be in 12.20 format */\r
7005     xfract = (X & 0x000FFFFF);\r
7006 \r
7007     /* Read two nearest output values from the index */\r
7008     x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI)    ];\r
7009     x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];\r
7010 \r
7011     /* 20 bits for the fractional part */\r
7012     /* yfract should be in 12.20 format */\r
7013     yfract = (Y & 0x000FFFFF);\r
7014 \r
7015     /* Read two nearest output values from the index */\r
7016     y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1)    ];\r
7017     y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];\r
7018 \r
7019     /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */\r
7020 \r
7021     /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */\r
7022     /* convert 13.35 to 13.31 by right shifting  and out is in 1.31 */\r
7023     out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);\r
7024     acc = ((q63_t) out * (0xFFFFF - yfract));\r
7025 \r
7026     /* x2 * (xfract) * (1-yfract)  in 1.51 and adding to acc */\r
7027     out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);\r
7028     acc += ((q63_t) out * (xfract));\r
7029 \r
7030     /* y1 * (1 - xfract) * (yfract)  in 1.51 and adding to acc */\r
7031     out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);\r
7032     acc += ((q63_t) out * (yfract));\r
7033 \r
7034     /* y2 * (xfract) * (yfract)  in 1.51 and adding to acc */\r
7035     out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);\r
7036     acc += ((q63_t) out * (yfract));\r
7037 \r
7038     /* acc is in 13.51 format and down shift acc by 36 times */\r
7039     /* Convert out to 1.15 format */\r
7040     return ((q15_t)(acc >> 36));\r
7041   }\r
7042 \r
7043 \r
7044   /**\r
7045   * @brief  Q7 bilinear interpolation.\r
7046   * @param[in,out] S  points to an instance of the interpolation structure.\r
7047   * @param[in]     X  interpolation coordinate in 12.20 format.\r
7048   * @param[in]     Y  interpolation coordinate in 12.20 format.\r
7049   * @return out interpolated value.\r
7050   */\r
7051   CMSIS_INLINE __STATIC_INLINE q7_t arm_bilinear_interp_q7(\r
7052   arm_bilinear_interp_instance_q7 * S,\r
7053   q31_t X,\r
7054   q31_t Y)\r
7055   {\r
7056     q63_t acc = 0;                               /* output */\r
7057     q31_t out;                                   /* Temporary output */\r
7058     q31_t xfract, yfract;                        /* X, Y fractional parts */\r
7059     q7_t x1, x2, y1, y2;                         /* Nearest output values */\r
7060     int32_t rI, cI;                              /* Row and column indices */\r
7061     q7_t *pYData = S->pData;                     /* pointer to output table values */\r
7062     uint32_t nCols = S->numCols;                 /* num of rows */\r
7063 \r
7064     /* Input is in 12.20 format */\r
7065     /* 12 bits for the table index */\r
7066     /* Index value calculation */\r
7067     rI = ((X & (q31_t)0xFFF00000) >> 20);\r
7068 \r
7069     /* Input is in 12.20 format */\r
7070     /* 12 bits for the table index */\r
7071     /* Index value calculation */\r
7072     cI = ((Y & (q31_t)0xFFF00000) >> 20);\r
7073 \r
7074     /* Care taken for table outside boundary */\r
7075     /* Returns zero output when values are outside table boundary */\r
7076     if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))\r
7077     {\r
7078       return (0);\r
7079     }\r
7080 \r
7081     /* 20 bits for the fractional part */\r
7082     /* xfract should be in 12.20 format */\r
7083     xfract = (X & (q31_t)0x000FFFFF);\r
7084 \r
7085     /* Read two nearest output values from the index */\r
7086     x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI)    ];\r
7087     x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];\r
7088 \r
7089     /* 20 bits for the fractional part */\r
7090     /* yfract should be in 12.20 format */\r
7091     yfract = (Y & (q31_t)0x000FFFFF);\r
7092 \r
7093     /* Read two nearest output values from the index */\r
7094     y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1)    ];\r
7095     y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];\r
7096 \r
7097     /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */\r
7098     out = ((x1 * (0xFFFFF - xfract)));\r
7099     acc = (((q63_t) out * (0xFFFFF - yfract)));\r
7100 \r
7101     /* x2 * (xfract) * (1-yfract)  in 2.22 and adding to acc */\r
7102     out = ((x2 * (0xFFFFF - yfract)));\r
7103     acc += (((q63_t) out * (xfract)));\r
7104 \r
7105     /* y1 * (1 - xfract) * (yfract)  in 2.22 and adding to acc */\r
7106     out = ((y1 * (0xFFFFF - xfract)));\r
7107     acc += (((q63_t) out * (yfract)));\r
7108 \r
7109     /* y2 * (xfract) * (yfract)  in 2.22 and adding to acc */\r
7110     out = ((y2 * (yfract)));\r
7111     acc += (((q63_t) out * (xfract)));\r
7112 \r
7113     /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */\r
7114     return ((q7_t)(acc >> 40));\r
7115   }\r
7116 \r
7117   /**\r
7118    * @} end of BilinearInterpolate group\r
7119    */\r
7120 \r
7121 \r
7122 /* SMMLAR */\r
7123 #define multAcc_32x32_keep32_R(a, x, y) \\r
7124     a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)\r
7125 \r
7126 /* SMMLSR */\r
7127 #define multSub_32x32_keep32_R(a, x, y) \\r
7128     a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)\r
7129 \r
7130 /* SMMULR */\r
7131 #define mult_32x32_keep32_R(a, x, y) \\r
7132     a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)\r
7133 \r
7134 /* SMMLA */\r
7135 #define multAcc_32x32_keep32(a, x, y) \\r
7136     a += (q31_t) (((q63_t) x * y) >> 32)\r
7137 \r
7138 /* SMMLS */\r
7139 #define multSub_32x32_keep32(a, x, y) \\r
7140     a -= (q31_t) (((q63_t) x * y) >> 32)\r
7141 \r
7142 /* SMMUL */\r
7143 #define mult_32x32_keep32(a, x, y) \\r
7144     a = (q31_t) (((q63_t) x * y ) >> 32)\r
7145 \r
7146 \r
7147 #if   defined ( __CC_ARM )\r
7148   /* Enter low optimization region - place directly above function definition */\r
7149   #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)\r
7150     #define LOW_OPTIMIZATION_ENTER \\r
7151        _Pragma ("push")         \\r
7152        _Pragma ("O1")\r
7153   #else\r
7154     #define LOW_OPTIMIZATION_ENTER\r
7155   #endif\r
7156 \r
7157   /* Exit low optimization region - place directly after end of function definition */\r
7158   #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )\r
7159     #define LOW_OPTIMIZATION_EXIT \\r
7160        _Pragma ("pop")\r
7161   #else\r
7162     #define LOW_OPTIMIZATION_EXIT\r
7163   #endif\r
7164 \r
7165   /* Enter low optimization region - place directly above function definition */\r
7166   #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7167 \r
7168   /* Exit low optimization region - place directly after end of function definition */\r
7169   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7170 \r
7171 #elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )\r
7172   #define LOW_OPTIMIZATION_ENTER\r
7173   #define LOW_OPTIMIZATION_EXIT\r
7174   #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7175   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7176 \r
7177 #elif defined ( __GNUC__ )\r
7178   #define LOW_OPTIMIZATION_ENTER \\r
7179        __attribute__(( optimize("-O1") ))\r
7180   #define LOW_OPTIMIZATION_EXIT\r
7181   #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7182   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7183 \r
7184 #elif defined ( __ICCARM__ )\r
7185   /* Enter low optimization region - place directly above function definition */\r
7186   #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )\r
7187     #define LOW_OPTIMIZATION_ENTER \\r
7188        _Pragma ("optimize=low")\r
7189   #else\r
7190     #define LOW_OPTIMIZATION_ENTER\r
7191   #endif\r
7192 \r
7193   /* Exit low optimization region - place directly after end of function definition */\r
7194   #define LOW_OPTIMIZATION_EXIT\r
7195 \r
7196   /* Enter low optimization region - place directly above function definition */\r
7197   #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )\r
7198     #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \\r
7199        _Pragma ("optimize=low")\r
7200   #else\r
7201     #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7202   #endif\r
7203 \r
7204   /* Exit low optimization region - place directly after end of function definition */\r
7205   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7206 \r
7207 #elif defined ( __TI_ARM__ )\r
7208   #define LOW_OPTIMIZATION_ENTER\r
7209   #define LOW_OPTIMIZATION_EXIT\r
7210   #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7211   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7212 \r
7213 #elif defined ( __CSMC__ )\r
7214   #define LOW_OPTIMIZATION_ENTER\r
7215   #define LOW_OPTIMIZATION_EXIT\r
7216   #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7217   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7218 \r
7219 #elif defined ( __TASKING__ )\r
7220   #define LOW_OPTIMIZATION_ENTER\r
7221   #define LOW_OPTIMIZATION_EXIT\r
7222   #define IAR_ONLY_LOW_OPTIMIZATION_ENTER\r
7223   #define IAR_ONLY_LOW_OPTIMIZATION_EXIT\r
7224 \r
7225 #endif\r
7226 \r
7227 \r
7228 #ifdef   __cplusplus\r
7229 }\r
7230 #endif\r
7231 \r
7232 /* Compiler specific diagnostic adjustment */\r
7233 #if   defined ( __CC_ARM )\r
7234 \r
7235 #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )\r
7236 \r
7237 #elif defined ( __GNUC__ )\r
7238 #pragma GCC diagnostic pop\r
7239 \r
7240 #elif defined ( __ICCARM__ )\r
7241 \r
7242 #elif defined ( __TI_ARM__ )\r
7243 \r
7244 #elif defined ( __CSMC__ )\r
7245 \r
7246 #elif defined ( __TASKING__ )\r
7247 \r
7248 #else\r
7249   #error Unknown compiler\r
7250 #endif\r
7251 \r
7252 #endif /* _ARM_MATH_H */\r
7253 \r
7254 /**\r
7255  *\r
7256  * End of file.\r
7257  */\r