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