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