Set blackbox file handler to NULL after closing file
[inav.git] / lib / main / CMSIS / DSP / Include / arm_math.h
blobea9dd26aa8110a0a90babc7b297c5bc6d5eb4216
1 /******************************************************************************
2 * @file arm_math.h
3 * @brief Public header file for CMSIS DSP LibraryU
4 * @version V1.5.3
5 * @date 10. January 2018
6 ******************************************************************************/
7 /*
8 * Copyright (c) 2010-2018 Arm Limited or its affiliates. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
25 /**
26 \mainpage CMSIS DSP Software Library
28 * Introduction
29 * ------------
31 * This user manual describes the CMSIS DSP software library,
32 * a suite of common signal processing functions for use on Cortex-M processor based devices.
34 * The library is divided into a number of functions each covering a specific category:
35 * - Basic math functions
36 * - Fast math functions
37 * - Complex math functions
38 * - Filters
39 * - Matrix functions
40 * - Transforms
41 * - Motor control functions
42 * - Statistical functions
43 * - Support functions
44 * - Interpolation functions
46 * The library has separate functions for operating on 8-bit integers, 16-bit integers,
47 * 32-bit integer and 32-bit floating-point values.
49 * Using the Library
50 * ------------
52 * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
53 * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit)
54 * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit)
55 * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit)
56 * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on)
57 * - arm_cortexM7l_math.lib (Cortex-M7, Little endian)
58 * - arm_cortexM7b_math.lib (Cortex-M7, Big endian)
59 * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit)
60 * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit)
61 * - arm_cortexM4l_math.lib (Cortex-M4, Little endian)
62 * - arm_cortexM4b_math.lib (Cortex-M4, Big endian)
63 * - arm_cortexM3l_math.lib (Cortex-M3, Little endian)
64 * - arm_cortexM3b_math.lib (Cortex-M3, Big endian)
65 * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian)
66 * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian)
67 * - arm_ARMv8MBLl_math.lib (Armv8-M Baseline, Little endian)
68 * - arm_ARMv8MMLl_math.lib (Armv8-M Mainline, Little endian)
69 * - arm_ARMv8MMLlfsp_math.lib (Armv8-M Mainline, Little endian, Single Precision Floating Point Unit)
70 * - arm_ARMv8MMLld_math.lib (Armv8-M Mainline, Little endian, DSP instructions)
71 * - arm_ARMv8MMLldfsp_math.lib (Armv8-M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit)
73 * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
74 * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
75 * public header file <code> arm_math.h</code> for Cortex-M cores with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
76 * Define the appropriate preprocessor macro ARM_MATH_CM7 or ARM_MATH_CM4 or ARM_MATH_CM3 or
77 * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
78 * For Armv8-M cores define preprocessor macro ARM_MATH_ARMV8MBL or ARM_MATH_ARMV8MML.
79 * Set preprocessor macro __DSP_PRESENT if Armv8-M Mainline core supports DSP instructions.
82 * Examples
83 * --------
85 * The library ships with a number of examples which demonstrate how to use the library functions.
87 * Toolchain Support
88 * ------------
90 * The library has been developed and tested with MDK version 5.14.0.0
91 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
93 * Building the Library
94 * ------------
96 * The library installer contains a project file to rebuild libraries on MDK toolchain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
97 * - arm_cortexM_math.uvprojx
100 * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional preprocessor macros detailed above.
102 * Preprocessor Macros
103 * ------------
105 * Each library project have different preprocessor macros.
107 * - UNALIGNED_SUPPORT_DISABLE:
109 * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
111 * - ARM_MATH_BIG_ENDIAN:
113 * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
115 * - ARM_MATH_MATRIX_CHECK:
117 * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
119 * - ARM_MATH_ROUNDING:
121 * Define macro ARM_MATH_ROUNDING for rounding on support functions
123 * - ARM_MATH_CMx:
125 * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
126 * and ARM_MATH_CM0 for building library on Cortex-M0 target, ARM_MATH_CM0PLUS for building library on Cortex-M0+ target, and
127 * ARM_MATH_CM7 for building the library on cortex-M7.
129 * - ARM_MATH_ARMV8MxL:
131 * Define macro ARM_MATH_ARMV8MBL for building the library on Armv8-M Baseline target, ARM_MATH_ARMV8MML for building library
132 * on Armv8-M Mainline target.
134 * - __FPU_PRESENT:
136 * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for floating point libraries.
138 * - __DSP_PRESENT:
140 * Initialize macro __DSP_PRESENT = 1 when Armv8-M Mainline core supports DSP instructions.
142 * <hr>
143 * CMSIS-DSP in ARM::CMSIS Pack
144 * -----------------------------
146 * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:
147 * |File/Folder |Content |
148 * |------------------------------|------------------------------------------------------------------------|
149 * |\b CMSIS\\Documentation\\DSP | This documentation |
150 * |\b CMSIS\\DSP_Lib | Software license agreement (license.txt) |
151 * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions |
152 * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library |
154 * <hr>
155 * Revision History of CMSIS-DSP
156 * ------------
157 * Please refer to \ref ChangeLog_pg.
159 * Copyright Notice
160 * ------------
162 * Copyright (C) 2010-2015 Arm Limited. All rights reserved.
167 * @defgroup groupMath Basic Math Functions
171 * @defgroup groupFastMath Fast Math Functions
172 * This set of functions provides a fast approximation to sine, cosine, and square root.
173 * As compared to most of the other functions in the CMSIS math library, the fast math functions
174 * operate on individual values and not arrays.
175 * There are separate functions for Q15, Q31, and floating-point data.
180 * @defgroup groupCmplxMath Complex Math Functions
181 * This set of functions operates on complex data vectors.
182 * The data in the complex arrays is stored in an interleaved fashion
183 * (real, imag, real, imag, ...).
184 * In the API functions, the number of samples in a complex array refers
185 * to the number of complex values; the array contains twice this number of
186 * real values.
190 * @defgroup groupFilters Filtering Functions
194 * @defgroup groupMatrix Matrix Functions
196 * This set of functions provides basic matrix math operations.
197 * The functions operate on matrix data structures. For example,
198 * the type
199 * definition for the floating-point matrix structure is shown
200 * below:
201 * <pre>
202 * typedef struct
204 * uint16_t numRows; // number of rows of the matrix.
205 * uint16_t numCols; // number of columns of the matrix.
206 * float32_t *pData; // points to the data of the matrix.
207 * } arm_matrix_instance_f32;
208 * </pre>
209 * There are similar definitions for Q15 and Q31 data types.
211 * The structure specifies the size of the matrix and then points to
212 * an array of data. The array is of size <code>numRows X numCols</code>
213 * and the values are arranged in row order. That is, the
214 * matrix element (i, j) is stored at:
215 * <pre>
216 * pData[i*numCols + j]
217 * </pre>
219 * \par Init Functions
220 * There is an associated initialization function for each type of matrix
221 * data structure.
222 * The initialization function sets the values of the internal structure fields.
223 * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
224 * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
226 * \par
227 * Use of the initialization function is optional. However, if initialization function is used
228 * then the instance structure cannot be placed into a const data section.
229 * To place the instance structure in a const data
230 * section, manually initialize the data structure. For example:
231 * <pre>
232 * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
233 * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
234 * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
235 * </pre>
236 * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
237 * specifies the number of columns, and <code>pData</code> points to the
238 * data array.
240 * \par Size Checking
241 * By default all of the matrix functions perform size checking on the input and
242 * output matrices. For example, the matrix addition function verifies that the
243 * two input matrices and the output matrix all have the same number of rows and
244 * columns. If the size check fails the functions return:
245 * <pre>
246 * ARM_MATH_SIZE_MISMATCH
247 * </pre>
248 * Otherwise the functions return
249 * <pre>
250 * ARM_MATH_SUCCESS
251 * </pre>
252 * There is some overhead associated with this matrix size checking.
253 * The matrix size checking is enabled via the \#define
254 * <pre>
255 * ARM_MATH_MATRIX_CHECK
256 * </pre>
257 * within the library project settings. By default this macro is defined
258 * and size checking is enabled. By changing the project settings and
259 * undefining this macro size checking is eliminated and the functions
260 * run a bit faster. With size checking disabled the functions always
261 * return <code>ARM_MATH_SUCCESS</code>.
265 * @defgroup groupTransforms Transform Functions
269 * @defgroup groupController Controller Functions
273 * @defgroup groupStats Statistics Functions
276 * @defgroup groupSupport Support Functions
280 * @defgroup groupInterpolation Interpolation Functions
281 * These functions perform 1- and 2-dimensional interpolation of data.
282 * Linear interpolation is used for 1-dimensional data and
283 * bilinear interpolation is used for 2-dimensional data.
287 * @defgroup groupExamples Examples
289 #ifndef _ARM_MATH_H
290 #define _ARM_MATH_H
292 /* Compiler specific diagnostic adjustment */
293 #if defined ( __CC_ARM )
295 #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
297 #elif defined ( __GNUC__ )
298 #pragma GCC diagnostic push
299 #pragma GCC diagnostic ignored "-Wsign-conversion"
300 #pragma GCC diagnostic ignored "-Wconversion"
301 #pragma GCC diagnostic ignored "-Wunused-parameter"
303 #elif defined ( __ICCARM__ )
305 #elif defined ( __TI_ARM__ )
307 #elif defined ( __CSMC__ )
309 #elif defined ( __TASKING__ )
311 #else
312 #error Unknown compiler
313 #endif
316 #define __CMSIS_GENERIC /* disable NVIC and Systick functions */
318 #if defined(ARM_MATH_CM7)
319 #include "core_cm7.h"
320 #define ARM_MATH_DSP
321 #elif defined (ARM_MATH_CM4)
322 #include "core_cm4.h"
323 #define ARM_MATH_DSP
324 #elif defined (ARM_MATH_CM3)
325 #include "core_cm3.h"
326 #elif defined (ARM_MATH_CM0)
327 #include "core_cm0.h"
328 #define ARM_MATH_CM0_FAMILY
329 #elif defined (ARM_MATH_CM0PLUS)
330 #include "core_cm0plus.h"
331 #define ARM_MATH_CM0_FAMILY
332 #elif defined (ARM_MATH_ARMV8MBL)
333 #include "core_armv8mbl.h"
334 #define ARM_MATH_CM0_FAMILY
335 #elif defined (ARM_MATH_ARMV8MML)
336 #include "core_armv8mml.h"
337 #if (defined (__DSP_PRESENT) && (__DSP_PRESENT == 1))
338 #define ARM_MATH_DSP
339 #endif
340 #else
341 #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS, ARM_MATH_CM0, ARM_MATH_ARMV8MBL, ARM_MATH_ARMV8MML"
342 #endif
344 #undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
345 #include "string.h"
346 #include "math.h"
347 #ifdef __cplusplus
348 extern "C"
350 #endif
354 * @brief Macros required for reciprocal calculation in Normalized LMS
357 #define DELTA_Q31 (0x100)
358 #define DELTA_Q15 0x5
359 #define INDEX_MASK 0x0000003F
360 #ifndef PI
361 #define PI 3.14159265358979f
362 #endif
365 * @brief Macros required for SINE and COSINE Fast math approximations
368 #define FAST_MATH_TABLE_SIZE 512
369 #define FAST_MATH_Q31_SHIFT (32 - 10)
370 #define FAST_MATH_Q15_SHIFT (16 - 10)
371 #define CONTROLLER_Q31_SHIFT (32 - 9)
372 #define TABLE_SPACING_Q31 0x400000
373 #define TABLE_SPACING_Q15 0x80
376 * @brief Macros required for SINE and COSINE Controller functions
378 /* 1.31(q31) Fixed value of 2/360 */
379 /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
380 #define INPUT_SPACING 0xB60B61
383 * @brief Macro for Unaligned Support
385 #ifndef UNALIGNED_SUPPORT_DISABLE
386 #define ALIGN4
387 #else
388 #if defined (__GNUC__)
389 #define ALIGN4 __attribute__((aligned(4)))
390 #else
391 #define ALIGN4 __align(4)
392 #endif
393 #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
396 * @brief Error status returned by some functions in the library.
399 typedef enum
401 ARM_MATH_SUCCESS = 0, /**< No error */
402 ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
403 ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
404 ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
405 ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
406 ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
407 ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
408 } arm_status;
411 * @brief 8-bit fractional data type in 1.7 format.
413 typedef int8_t q7_t;
416 * @brief 16-bit fractional data type in 1.15 format.
418 typedef int16_t q15_t;
421 * @brief 32-bit fractional data type in 1.31 format.
423 typedef int32_t q31_t;
426 * @brief 64-bit fractional data type in 1.63 format.
428 typedef int64_t q63_t;
431 * @brief 32-bit floating-point type definition.
433 typedef float float32_t;
436 * @brief 64-bit floating-point type definition.
438 typedef double float64_t;
441 * @brief definition to read/write two 16 bit values.
443 #if defined ( __CC_ARM )
444 #define __SIMD32_TYPE int32_t __packed
445 #define CMSIS_UNUSED __attribute__((unused))
446 #define CMSIS_INLINE __attribute__((always_inline))
448 #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
449 #define __SIMD32_TYPE int32_t
450 #define CMSIS_UNUSED __attribute__((unused))
451 #define CMSIS_INLINE __attribute__((always_inline))
453 #elif defined ( __GNUC__ )
454 #define __SIMD32_TYPE int32_t
455 #define CMSIS_UNUSED __attribute__((unused))
456 #define CMSIS_INLINE __attribute__((always_inline))
458 #elif defined ( __ICCARM__ )
459 #define __SIMD32_TYPE int32_t __packed
460 #define CMSIS_UNUSED
461 #define CMSIS_INLINE
463 #elif defined ( __TI_ARM__ )
464 #define __SIMD32_TYPE int32_t
465 #define CMSIS_UNUSED __attribute__((unused))
466 #define CMSIS_INLINE
468 #elif defined ( __CSMC__ )
469 #define __SIMD32_TYPE int32_t
470 #define CMSIS_UNUSED
471 #define CMSIS_INLINE
473 #elif defined ( __TASKING__ )
474 #define __SIMD32_TYPE __unaligned int32_t
475 #define CMSIS_UNUSED
476 #define CMSIS_INLINE
478 #else
479 #error Unknown compiler
480 #endif
482 #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
483 #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
484 #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
485 #define __SIMD64(addr) (*(int64_t **) & (addr))
487 #if !defined (ARM_MATH_DSP)
489 * @brief definition to pack two 16 bit values.
491 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
492 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
493 #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
494 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
496 #endif /* !defined (ARM_MATH_DSP) */
499 * @brief definition to pack four 8 bit values.
501 #ifndef ARM_MATH_BIG_ENDIAN
503 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
504 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
505 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
506 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
507 #else
509 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
510 (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
511 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
512 (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
514 #endif
518 * @brief Clips Q63 to Q31 values.
520 CMSIS_INLINE __STATIC_INLINE q31_t clip_q63_to_q31(
521 q63_t x)
523 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
524 ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
528 * @brief Clips Q63 to Q15 values.
530 CMSIS_INLINE __STATIC_INLINE q15_t clip_q63_to_q15(
531 q63_t x)
533 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
534 ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
538 * @brief Clips Q31 to Q7 values.
540 CMSIS_INLINE __STATIC_INLINE q7_t clip_q31_to_q7(
541 q31_t x)
543 return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
544 ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
548 * @brief Clips Q31 to Q15 values.
550 CMSIS_INLINE __STATIC_INLINE q15_t clip_q31_to_q15(
551 q31_t x)
553 return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
554 ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
558 * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
561 CMSIS_INLINE __STATIC_INLINE q63_t mult32x64(
562 q63_t x,
563 q31_t y)
565 return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
566 (((q63_t) (x >> 32) * y)));
570 * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
573 CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q31(
574 q31_t in,
575 q31_t * dst,
576 q31_t * pRecipTable)
578 q31_t out;
579 uint32_t tempVal;
580 uint32_t index, i;
581 uint32_t signBits;
583 if (in > 0)
585 signBits = ((uint32_t) (__CLZ( in) - 1));
587 else
589 signBits = ((uint32_t) (__CLZ(-in) - 1));
592 /* Convert input sample to 1.31 format */
593 in = (in << signBits);
595 /* calculation of index for initial approximated Val */
596 index = (uint32_t)(in >> 24);
597 index = (index & INDEX_MASK);
599 /* 1.31 with exp 1 */
600 out = pRecipTable[index];
602 /* calculation of reciprocal value */
603 /* running approximation for two iterations */
604 for (i = 0U; i < 2U; i++)
606 tempVal = (uint32_t) (((q63_t) in * out) >> 31);
607 tempVal = 0x7FFFFFFFu - tempVal;
608 /* 1.31 with exp 1 */
609 /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */
610 out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);
613 /* write output */
614 *dst = out;
616 /* return num of signbits of out = 1/in value */
617 return (signBits + 1U);
622 * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
624 CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q15(
625 q15_t in,
626 q15_t * dst,
627 q15_t * pRecipTable)
629 q15_t out = 0;
630 uint32_t tempVal = 0;
631 uint32_t index = 0, i = 0;
632 uint32_t signBits = 0;
634 if (in > 0)
636 signBits = ((uint32_t)(__CLZ( in) - 17));
638 else
640 signBits = ((uint32_t)(__CLZ(-in) - 17));
643 /* Convert input sample to 1.15 format */
644 in = (in << signBits);
646 /* calculation of index for initial approximated Val */
647 index = (uint32_t)(in >> 8);
648 index = (index & INDEX_MASK);
650 /* 1.15 with exp 1 */
651 out = pRecipTable[index];
653 /* calculation of reciprocal value */
654 /* running approximation for two iterations */
655 for (i = 0U; i < 2U; i++)
657 tempVal = (uint32_t) (((q31_t) in * out) >> 15);
658 tempVal = 0x7FFFu - tempVal;
659 /* 1.15 with exp 1 */
660 out = (q15_t) (((q31_t) out * tempVal) >> 14);
661 /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */
664 /* write output */
665 *dst = out;
667 /* return num of signbits of out = 1/in value */
668 return (signBits + 1);
673 * @brief C custom defined intrinsic function for M3 and M0 processors
675 #if !defined (ARM_MATH_DSP)
678 * @brief C custom defined QADD8 for M3 and M0 processors
680 CMSIS_INLINE __STATIC_INLINE uint32_t __QADD8(
681 uint32_t x,
682 uint32_t y)
684 q31_t r, s, t, u;
686 r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
687 s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
688 t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
689 u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
691 return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
696 * @brief C custom defined QSUB8 for M3 and M0 processors
698 CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB8(
699 uint32_t x,
700 uint32_t y)
702 q31_t r, s, t, u;
704 r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
705 s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
706 t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
707 u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
709 return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
714 * @brief C custom defined QADD16 for M3 and M0 processors
716 CMSIS_INLINE __STATIC_INLINE uint32_t __QADD16(
717 uint32_t x,
718 uint32_t y)
720 /* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */
721 q31_t r = 0, s = 0;
723 r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
724 s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
726 return ((uint32_t)((s << 16) | (r )));
731 * @brief C custom defined SHADD16 for M3 and M0 processors
733 CMSIS_INLINE __STATIC_INLINE uint32_t __SHADD16(
734 uint32_t x,
735 uint32_t y)
737 q31_t r, s;
739 r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
740 s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
742 return ((uint32_t)((s << 16) | (r )));
747 * @brief C custom defined QSUB16 for M3 and M0 processors
749 CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB16(
750 uint32_t x,
751 uint32_t y)
753 q31_t r, s;
755 r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
756 s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
758 return ((uint32_t)((s << 16) | (r )));
763 * @brief C custom defined SHSUB16 for M3 and M0 processors
765 CMSIS_INLINE __STATIC_INLINE uint32_t __SHSUB16(
766 uint32_t x,
767 uint32_t y)
769 q31_t r, s;
771 r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
772 s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
774 return ((uint32_t)((s << 16) | (r )));
779 * @brief C custom defined QASX for M3 and M0 processors
781 CMSIS_INLINE __STATIC_INLINE uint32_t __QASX(
782 uint32_t x,
783 uint32_t y)
785 q31_t r, s;
787 r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
788 s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
790 return ((uint32_t)((s << 16) | (r )));
795 * @brief C custom defined SHASX for M3 and M0 processors
797 CMSIS_INLINE __STATIC_INLINE uint32_t __SHASX(
798 uint32_t x,
799 uint32_t y)
801 q31_t r, s;
803 r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
804 s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
806 return ((uint32_t)((s << 16) | (r )));
811 * @brief C custom defined QSAX for M3 and M0 processors
813 CMSIS_INLINE __STATIC_INLINE uint32_t __QSAX(
814 uint32_t x,
815 uint32_t y)
817 q31_t r, s;
819 r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
820 s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
822 return ((uint32_t)((s << 16) | (r )));
827 * @brief C custom defined SHSAX for M3 and M0 processors
829 CMSIS_INLINE __STATIC_INLINE uint32_t __SHSAX(
830 uint32_t x,
831 uint32_t y)
833 q31_t r, s;
835 r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
836 s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
838 return ((uint32_t)((s << 16) | (r )));
843 * @brief C custom defined SMUSDX for M3 and M0 processors
845 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSDX(
846 uint32_t x,
847 uint32_t y)
849 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
850 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
854 * @brief C custom defined SMUADX for M3 and M0 processors
856 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUADX(
857 uint32_t x,
858 uint32_t y)
860 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
861 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
866 * @brief C custom defined QADD for M3 and M0 processors
868 CMSIS_INLINE __STATIC_INLINE int32_t __QADD(
869 int32_t x,
870 int32_t y)
872 return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));
877 * @brief C custom defined QSUB for M3 and M0 processors
879 CMSIS_INLINE __STATIC_INLINE int32_t __QSUB(
880 int32_t x,
881 int32_t y)
883 return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));
888 * @brief C custom defined SMLAD for M3 and M0 processors
890 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLAD(
891 uint32_t x,
892 uint32_t y,
893 uint32_t sum)
895 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
896 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
897 ( ((q31_t)sum ) ) ));
902 * @brief C custom defined SMLADX for M3 and M0 processors
904 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLADX(
905 uint32_t x,
906 uint32_t y,
907 uint32_t sum)
909 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
910 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
911 ( ((q31_t)sum ) ) ));
916 * @brief C custom defined SMLSDX for M3 and M0 processors
918 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLSDX(
919 uint32_t x,
920 uint32_t y,
921 uint32_t sum)
923 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
924 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
925 ( ((q31_t)sum ) ) ));
930 * @brief C custom defined SMLALD for M3 and M0 processors
932 CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALD(
933 uint32_t x,
934 uint32_t y,
935 uint64_t sum)
937 /* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
938 return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
939 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
940 ( ((q63_t)sum ) ) ));
945 * @brief C custom defined SMLALDX for M3 and M0 processors
947 CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALDX(
948 uint32_t x,
949 uint32_t y,
950 uint64_t sum)
952 /* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
953 return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
954 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
955 ( ((q63_t)sum ) ) ));
960 * @brief C custom defined SMUAD for M3 and M0 processors
962 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUAD(
963 uint32_t x,
964 uint32_t y)
966 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
967 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
972 * @brief C custom defined SMUSD for M3 and M0 processors
974 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSD(
975 uint32_t x,
976 uint32_t y)
978 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -
979 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
984 * @brief C custom defined SXTB16 for M3 and M0 processors
986 CMSIS_INLINE __STATIC_INLINE uint32_t __SXTB16(
987 uint32_t x)
989 return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |
990 ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) ));
994 * @brief C custom defined SMMLA for M3 and M0 processors
996 CMSIS_INLINE __STATIC_INLINE int32_t __SMMLA(
997 int32_t x,
998 int32_t y,
999 int32_t sum)
1001 return (sum + (int32_t) (((int64_t) x * y) >> 32));
1004 #endif /* !defined (ARM_MATH_DSP) */
1008 * @brief Instance structure for the Q7 FIR filter.
1010 typedef struct
1012 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1013 q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1014 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
1015 } arm_fir_instance_q7;
1018 * @brief Instance structure for the Q15 FIR filter.
1020 typedef struct
1022 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1023 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1024 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
1025 } arm_fir_instance_q15;
1028 * @brief Instance structure for the Q31 FIR filter.
1030 typedef struct
1032 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1033 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1034 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
1035 } arm_fir_instance_q31;
1038 * @brief Instance structure for the floating-point FIR filter.
1040 typedef struct
1042 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1043 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1044 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
1045 } arm_fir_instance_f32;
1049 * @brief Processing function for the Q7 FIR filter.
1050 * @param[in] S points to an instance of the Q7 FIR filter structure.
1051 * @param[in] pSrc points to the block of input data.
1052 * @param[out] pDst points to the block of output data.
1053 * @param[in] blockSize number of samples to process.
1055 void arm_fir_q7(
1056 const arm_fir_instance_q7 * S,
1057 q7_t * pSrc,
1058 q7_t * pDst,
1059 uint32_t blockSize);
1063 * @brief Initialization function for the Q7 FIR filter.
1064 * @param[in,out] S points to an instance of the Q7 FIR structure.
1065 * @param[in] numTaps Number of filter coefficients in the filter.
1066 * @param[in] pCoeffs points to the filter coefficients.
1067 * @param[in] pState points to the state buffer.
1068 * @param[in] blockSize number of samples that are processed.
1070 void arm_fir_init_q7(
1071 arm_fir_instance_q7 * S,
1072 uint16_t numTaps,
1073 q7_t * pCoeffs,
1074 q7_t * pState,
1075 uint32_t blockSize);
1079 * @brief Processing function for the Q15 FIR filter.
1080 * @param[in] S points to an instance of the Q15 FIR structure.
1081 * @param[in] pSrc points to the block of input data.
1082 * @param[out] pDst points to the block of output data.
1083 * @param[in] blockSize number of samples to process.
1085 void arm_fir_q15(
1086 const arm_fir_instance_q15 * S,
1087 q15_t * pSrc,
1088 q15_t * pDst,
1089 uint32_t blockSize);
1093 * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
1094 * @param[in] S points to an instance of the Q15 FIR filter structure.
1095 * @param[in] pSrc points to the block of input data.
1096 * @param[out] pDst points to the block of output data.
1097 * @param[in] blockSize number of samples to process.
1099 void arm_fir_fast_q15(
1100 const arm_fir_instance_q15 * S,
1101 q15_t * pSrc,
1102 q15_t * pDst,
1103 uint32_t blockSize);
1107 * @brief Initialization function for the Q15 FIR filter.
1108 * @param[in,out] S points to an instance of the Q15 FIR filter structure.
1109 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
1110 * @param[in] pCoeffs points to the filter coefficients.
1111 * @param[in] pState points to the state buffer.
1112 * @param[in] blockSize number of samples that are processed at a time.
1113 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
1114 * <code>numTaps</code> is not a supported value.
1116 arm_status arm_fir_init_q15(
1117 arm_fir_instance_q15 * S,
1118 uint16_t numTaps,
1119 q15_t * pCoeffs,
1120 q15_t * pState,
1121 uint32_t blockSize);
1125 * @brief Processing function for the Q31 FIR filter.
1126 * @param[in] S points to an instance of the Q31 FIR filter structure.
1127 * @param[in] pSrc points to the block of input data.
1128 * @param[out] pDst points to the block of output data.
1129 * @param[in] blockSize number of samples to process.
1131 void arm_fir_q31(
1132 const arm_fir_instance_q31 * S,
1133 q31_t * pSrc,
1134 q31_t * pDst,
1135 uint32_t blockSize);
1139 * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
1140 * @param[in] S points to an instance of the Q31 FIR structure.
1141 * @param[in] pSrc points to the block of input data.
1142 * @param[out] pDst points to the block of output data.
1143 * @param[in] blockSize number of samples to process.
1145 void arm_fir_fast_q31(
1146 const arm_fir_instance_q31 * S,
1147 q31_t * pSrc,
1148 q31_t * pDst,
1149 uint32_t blockSize);
1153 * @brief Initialization function for the Q31 FIR filter.
1154 * @param[in,out] S points to an instance of the Q31 FIR structure.
1155 * @param[in] numTaps Number of filter coefficients in the filter.
1156 * @param[in] pCoeffs points to the filter coefficients.
1157 * @param[in] pState points to the state buffer.
1158 * @param[in] blockSize number of samples that are processed at a time.
1160 void arm_fir_init_q31(
1161 arm_fir_instance_q31 * S,
1162 uint16_t numTaps,
1163 q31_t * pCoeffs,
1164 q31_t * pState,
1165 uint32_t blockSize);
1169 * @brief Processing function for the floating-point FIR filter.
1170 * @param[in] S points to an instance of the floating-point FIR structure.
1171 * @param[in] pSrc points to the block of input data.
1172 * @param[out] pDst points to the block of output data.
1173 * @param[in] blockSize number of samples to process.
1175 void arm_fir_f32(
1176 const arm_fir_instance_f32 * S,
1177 float32_t * pSrc,
1178 float32_t * pDst,
1179 uint32_t blockSize);
1183 * @brief Initialization function for the floating-point FIR filter.
1184 * @param[in,out] S points to an instance of the floating-point FIR filter structure.
1185 * @param[in] numTaps Number of filter coefficients in the filter.
1186 * @param[in] pCoeffs points to the filter coefficients.
1187 * @param[in] pState points to the state buffer.
1188 * @param[in] blockSize number of samples that are processed at a time.
1190 void arm_fir_init_f32(
1191 arm_fir_instance_f32 * S,
1192 uint16_t numTaps,
1193 float32_t * pCoeffs,
1194 float32_t * pState,
1195 uint32_t blockSize);
1199 * @brief Instance structure for the Q15 Biquad cascade filter.
1201 typedef struct
1203 int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1204 q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1205 q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1206 int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
1207 } arm_biquad_casd_df1_inst_q15;
1210 * @brief Instance structure for the Q31 Biquad cascade filter.
1212 typedef struct
1214 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1215 q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1216 q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1217 uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
1218 } arm_biquad_casd_df1_inst_q31;
1221 * @brief Instance structure for the floating-point Biquad cascade filter.
1223 typedef struct
1225 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1226 float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1227 float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1228 } arm_biquad_casd_df1_inst_f32;
1232 * @brief Processing function for the Q15 Biquad cascade filter.
1233 * @param[in] S points to an instance of the Q15 Biquad cascade structure.
1234 * @param[in] pSrc points to the block of input data.
1235 * @param[out] pDst points to the block of output data.
1236 * @param[in] blockSize number of samples to process.
1238 void arm_biquad_cascade_df1_q15(
1239 const arm_biquad_casd_df1_inst_q15 * S,
1240 q15_t * pSrc,
1241 q15_t * pDst,
1242 uint32_t blockSize);
1246 * @brief Initialization function for the Q15 Biquad cascade filter.
1247 * @param[in,out] S points to an instance of the Q15 Biquad cascade structure.
1248 * @param[in] numStages number of 2nd order stages in the filter.
1249 * @param[in] pCoeffs points to the filter coefficients.
1250 * @param[in] pState points to the state buffer.
1251 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1253 void arm_biquad_cascade_df1_init_q15(
1254 arm_biquad_casd_df1_inst_q15 * S,
1255 uint8_t numStages,
1256 q15_t * pCoeffs,
1257 q15_t * pState,
1258 int8_t postShift);
1262 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1263 * @param[in] S points to an instance of the Q15 Biquad cascade structure.
1264 * @param[in] pSrc points to the block of input data.
1265 * @param[out] pDst points to the block of output data.
1266 * @param[in] blockSize number of samples to process.
1268 void arm_biquad_cascade_df1_fast_q15(
1269 const arm_biquad_casd_df1_inst_q15 * S,
1270 q15_t * pSrc,
1271 q15_t * pDst,
1272 uint32_t blockSize);
1276 * @brief Processing function for the Q31 Biquad cascade filter
1277 * @param[in] S points to an instance of the Q31 Biquad cascade structure.
1278 * @param[in] pSrc points to the block of input data.
1279 * @param[out] pDst points to the block of output data.
1280 * @param[in] blockSize number of samples to process.
1282 void arm_biquad_cascade_df1_q31(
1283 const arm_biquad_casd_df1_inst_q31 * S,
1284 q31_t * pSrc,
1285 q31_t * pDst,
1286 uint32_t blockSize);
1290 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1291 * @param[in] S points to an instance of the Q31 Biquad cascade structure.
1292 * @param[in] pSrc points to the block of input data.
1293 * @param[out] pDst points to the block of output data.
1294 * @param[in] blockSize number of samples to process.
1296 void arm_biquad_cascade_df1_fast_q31(
1297 const arm_biquad_casd_df1_inst_q31 * S,
1298 q31_t * pSrc,
1299 q31_t * pDst,
1300 uint32_t blockSize);
1304 * @brief Initialization function for the Q31 Biquad cascade filter.
1305 * @param[in,out] S points to an instance of the Q31 Biquad cascade structure.
1306 * @param[in] numStages number of 2nd order stages in the filter.
1307 * @param[in] pCoeffs points to the filter coefficients.
1308 * @param[in] pState points to the state buffer.
1309 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1311 void arm_biquad_cascade_df1_init_q31(
1312 arm_biquad_casd_df1_inst_q31 * S,
1313 uint8_t numStages,
1314 q31_t * pCoeffs,
1315 q31_t * pState,
1316 int8_t postShift);
1320 * @brief Processing function for the floating-point Biquad cascade filter.
1321 * @param[in] S points to an instance of the floating-point 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.
1326 void arm_biquad_cascade_df1_f32(
1327 const arm_biquad_casd_df1_inst_f32 * S,
1328 float32_t * pSrc,
1329 float32_t * pDst,
1330 uint32_t blockSize);
1334 * @brief Initialization function for the floating-point Biquad cascade filter.
1335 * @param[in,out] S points to an instance of the floating-point Biquad cascade structure.
1336 * @param[in] numStages number of 2nd order stages in the filter.
1337 * @param[in] pCoeffs points to the filter coefficients.
1338 * @param[in] pState points to the state buffer.
1340 void arm_biquad_cascade_df1_init_f32(
1341 arm_biquad_casd_df1_inst_f32 * S,
1342 uint8_t numStages,
1343 float32_t * pCoeffs,
1344 float32_t * pState);
1348 * @brief Instance structure for the floating-point matrix structure.
1350 typedef struct
1352 uint16_t numRows; /**< number of rows of the matrix. */
1353 uint16_t numCols; /**< number of columns of the matrix. */
1354 float32_t *pData; /**< points to the data of the matrix. */
1355 } arm_matrix_instance_f32;
1359 * @brief Instance structure for the floating-point matrix structure.
1361 typedef struct
1363 uint16_t numRows; /**< number of rows of the matrix. */
1364 uint16_t numCols; /**< number of columns of the matrix. */
1365 float64_t *pData; /**< points to the data of the matrix. */
1366 } arm_matrix_instance_f64;
1369 * @brief Instance structure for the Q15 matrix structure.
1371 typedef struct
1373 uint16_t numRows; /**< number of rows of the matrix. */
1374 uint16_t numCols; /**< number of columns of the matrix. */
1375 q15_t *pData; /**< points to the data of the matrix. */
1376 } arm_matrix_instance_q15;
1379 * @brief Instance structure for the Q31 matrix structure.
1381 typedef struct
1383 uint16_t numRows; /**< number of rows of the matrix. */
1384 uint16_t numCols; /**< number of columns of the matrix. */
1385 q31_t *pData; /**< points to the data of the matrix. */
1386 } arm_matrix_instance_q31;
1390 * @brief Floating-point matrix addition.
1391 * @param[in] pSrcA points to the first input matrix structure
1392 * @param[in] pSrcB points to the second input matrix structure
1393 * @param[out] pDst points to output matrix structure
1394 * @return The function returns either
1395 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1397 arm_status arm_mat_add_f32(
1398 const arm_matrix_instance_f32 * pSrcA,
1399 const arm_matrix_instance_f32 * pSrcB,
1400 arm_matrix_instance_f32 * pDst);
1404 * @brief Q15 matrix addition.
1405 * @param[in] pSrcA points to the first input matrix structure
1406 * @param[in] pSrcB points to the second input matrix structure
1407 * @param[out] pDst points to output matrix structure
1408 * @return The function returns either
1409 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1411 arm_status arm_mat_add_q15(
1412 const arm_matrix_instance_q15 * pSrcA,
1413 const arm_matrix_instance_q15 * pSrcB,
1414 arm_matrix_instance_q15 * pDst);
1418 * @brief Q31 matrix addition.
1419 * @param[in] pSrcA points to the first input matrix structure
1420 * @param[in] pSrcB points to the second input matrix structure
1421 * @param[out] pDst points to output matrix structure
1422 * @return The function returns either
1423 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1425 arm_status arm_mat_add_q31(
1426 const arm_matrix_instance_q31 * pSrcA,
1427 const arm_matrix_instance_q31 * pSrcB,
1428 arm_matrix_instance_q31 * pDst);
1432 * @brief Floating-point, complex, matrix multiplication.
1433 * @param[in] pSrcA points to the first input matrix structure
1434 * @param[in] pSrcB points to the second input matrix structure
1435 * @param[out] pDst points to output matrix structure
1436 * @return The function returns either
1437 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1439 arm_status arm_mat_cmplx_mult_f32(
1440 const arm_matrix_instance_f32 * pSrcA,
1441 const arm_matrix_instance_f32 * pSrcB,
1442 arm_matrix_instance_f32 * pDst);
1446 * @brief Q15, complex, matrix multiplication.
1447 * @param[in] pSrcA points to the first input matrix structure
1448 * @param[in] pSrcB points to the second input matrix structure
1449 * @param[out] pDst points to output matrix structure
1450 * @return The function returns either
1451 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1453 arm_status arm_mat_cmplx_mult_q15(
1454 const arm_matrix_instance_q15 * pSrcA,
1455 const arm_matrix_instance_q15 * pSrcB,
1456 arm_matrix_instance_q15 * pDst,
1457 q15_t * pScratch);
1461 * @brief Q31, complex, matrix multiplication.
1462 * @param[in] pSrcA points to the first input matrix structure
1463 * @param[in] pSrcB points to the second input matrix structure
1464 * @param[out] pDst points to output matrix structure
1465 * @return The function returns either
1466 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1468 arm_status arm_mat_cmplx_mult_q31(
1469 const arm_matrix_instance_q31 * pSrcA,
1470 const arm_matrix_instance_q31 * pSrcB,
1471 arm_matrix_instance_q31 * pDst);
1475 * @brief Floating-point matrix transpose.
1476 * @param[in] pSrc points to the input matrix
1477 * @param[out] pDst points to the output matrix
1478 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1479 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1481 arm_status arm_mat_trans_f32(
1482 const arm_matrix_instance_f32 * pSrc,
1483 arm_matrix_instance_f32 * pDst);
1487 * @brief Q15 matrix transpose.
1488 * @param[in] pSrc points to the input matrix
1489 * @param[out] pDst points to the output matrix
1490 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1491 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1493 arm_status arm_mat_trans_q15(
1494 const arm_matrix_instance_q15 * pSrc,
1495 arm_matrix_instance_q15 * pDst);
1499 * @brief Q31 matrix transpose.
1500 * @param[in] pSrc points to the input matrix
1501 * @param[out] pDst points to the output matrix
1502 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1503 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1505 arm_status arm_mat_trans_q31(
1506 const arm_matrix_instance_q31 * pSrc,
1507 arm_matrix_instance_q31 * pDst);
1511 * @brief Floating-point matrix multiplication
1512 * @param[in] pSrcA points to the first input matrix structure
1513 * @param[in] pSrcB points to the second input matrix structure
1514 * @param[out] pDst points to output matrix structure
1515 * @return The function returns either
1516 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1518 arm_status arm_mat_mult_f32(
1519 const arm_matrix_instance_f32 * pSrcA,
1520 const arm_matrix_instance_f32 * pSrcB,
1521 arm_matrix_instance_f32 * pDst);
1525 * @brief Q15 matrix multiplication
1526 * @param[in] pSrcA points to the first input matrix structure
1527 * @param[in] pSrcB points to the second input matrix structure
1528 * @param[out] pDst points to output matrix structure
1529 * @param[in] pState points to the array for storing intermediate results
1530 * @return The function returns either
1531 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1533 arm_status arm_mat_mult_q15(
1534 const arm_matrix_instance_q15 * pSrcA,
1535 const arm_matrix_instance_q15 * pSrcB,
1536 arm_matrix_instance_q15 * pDst,
1537 q15_t * pState);
1541 * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1542 * @param[in] pSrcA points to the first input matrix structure
1543 * @param[in] pSrcB points to the second input matrix structure
1544 * @param[out] pDst points to output matrix structure
1545 * @param[in] pState points to the array for storing intermediate results
1546 * @return The function returns either
1547 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1549 arm_status arm_mat_mult_fast_q15(
1550 const arm_matrix_instance_q15 * pSrcA,
1551 const arm_matrix_instance_q15 * pSrcB,
1552 arm_matrix_instance_q15 * pDst,
1553 q15_t * pState);
1557 * @brief Q31 matrix multiplication
1558 * @param[in] pSrcA points to the first input matrix structure
1559 * @param[in] pSrcB points to the second input matrix structure
1560 * @param[out] pDst points to output matrix structure
1561 * @return The function returns either
1562 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1564 arm_status arm_mat_mult_q31(
1565 const arm_matrix_instance_q31 * pSrcA,
1566 const arm_matrix_instance_q31 * pSrcB,
1567 arm_matrix_instance_q31 * pDst);
1571 * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1572 * @param[in] pSrcA points to the first input matrix structure
1573 * @param[in] pSrcB points to the second input matrix structure
1574 * @param[out] pDst points to output matrix structure
1575 * @return The function returns either
1576 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1578 arm_status arm_mat_mult_fast_q31(
1579 const arm_matrix_instance_q31 * pSrcA,
1580 const arm_matrix_instance_q31 * pSrcB,
1581 arm_matrix_instance_q31 * pDst);
1585 * @brief Floating-point matrix subtraction
1586 * @param[in] pSrcA points to the first input matrix structure
1587 * @param[in] pSrcB points to the second input matrix structure
1588 * @param[out] pDst points to output matrix structure
1589 * @return The function returns either
1590 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1592 arm_status arm_mat_sub_f32(
1593 const arm_matrix_instance_f32 * pSrcA,
1594 const arm_matrix_instance_f32 * pSrcB,
1595 arm_matrix_instance_f32 * pDst);
1599 * @brief Q15 matrix subtraction
1600 * @param[in] pSrcA points to the first input matrix structure
1601 * @param[in] pSrcB points to the second input matrix structure
1602 * @param[out] pDst points to output matrix structure
1603 * @return The function returns either
1604 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1606 arm_status arm_mat_sub_q15(
1607 const arm_matrix_instance_q15 * pSrcA,
1608 const arm_matrix_instance_q15 * pSrcB,
1609 arm_matrix_instance_q15 * pDst);
1613 * @brief Q31 matrix subtraction
1614 * @param[in] pSrcA points to the first input matrix structure
1615 * @param[in] pSrcB points to the second input matrix structure
1616 * @param[out] pDst points to output matrix structure
1617 * @return The function returns either
1618 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1620 arm_status arm_mat_sub_q31(
1621 const arm_matrix_instance_q31 * pSrcA,
1622 const arm_matrix_instance_q31 * pSrcB,
1623 arm_matrix_instance_q31 * pDst);
1627 * @brief Floating-point matrix scaling.
1628 * @param[in] pSrc points to the input matrix
1629 * @param[in] scale scale factor
1630 * @param[out] pDst points to the output matrix
1631 * @return The function returns either
1632 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1634 arm_status arm_mat_scale_f32(
1635 const arm_matrix_instance_f32 * pSrc,
1636 float32_t scale,
1637 arm_matrix_instance_f32 * pDst);
1641 * @brief Q15 matrix scaling.
1642 * @param[in] pSrc points to input matrix
1643 * @param[in] scaleFract fractional portion of the scale factor
1644 * @param[in] shift number of bits to shift the result by
1645 * @param[out] pDst points to output matrix
1646 * @return The function returns either
1647 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1649 arm_status arm_mat_scale_q15(
1650 const arm_matrix_instance_q15 * pSrc,
1651 q15_t scaleFract,
1652 int32_t shift,
1653 arm_matrix_instance_q15 * pDst);
1657 * @brief Q31 matrix scaling.
1658 * @param[in] pSrc points to input matrix
1659 * @param[in] scaleFract fractional portion of the scale factor
1660 * @param[in] shift number of bits to shift the result by
1661 * @param[out] pDst points to output matrix structure
1662 * @return The function returns either
1663 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1665 arm_status arm_mat_scale_q31(
1666 const arm_matrix_instance_q31 * pSrc,
1667 q31_t scaleFract,
1668 int32_t shift,
1669 arm_matrix_instance_q31 * pDst);
1673 * @brief Q31 matrix initialization.
1674 * @param[in,out] S points to an instance of the floating-point matrix structure.
1675 * @param[in] nRows number of rows in the matrix.
1676 * @param[in] nColumns number of columns in the matrix.
1677 * @param[in] pData points to the matrix data array.
1679 void arm_mat_init_q31(
1680 arm_matrix_instance_q31 * S,
1681 uint16_t nRows,
1682 uint16_t nColumns,
1683 q31_t * pData);
1687 * @brief Q15 matrix initialization.
1688 * @param[in,out] S points to an instance of the floating-point matrix structure.
1689 * @param[in] nRows number of rows in the matrix.
1690 * @param[in] nColumns number of columns in the matrix.
1691 * @param[in] pData points to the matrix data array.
1693 void arm_mat_init_q15(
1694 arm_matrix_instance_q15 * S,
1695 uint16_t nRows,
1696 uint16_t nColumns,
1697 q15_t * pData);
1701 * @brief Floating-point matrix initialization.
1702 * @param[in,out] S points to an instance of the floating-point matrix structure.
1703 * @param[in] nRows number of rows in the matrix.
1704 * @param[in] nColumns number of columns in the matrix.
1705 * @param[in] pData points to the matrix data array.
1707 void arm_mat_init_f32(
1708 arm_matrix_instance_f32 * S,
1709 uint16_t nRows,
1710 uint16_t nColumns,
1711 float32_t * pData);
1716 * @brief Instance structure for the Q15 PID Control.
1718 typedef struct
1720 q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1721 #if !defined (ARM_MATH_DSP)
1722 q15_t A1;
1723 q15_t A2;
1724 #else
1725 q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
1726 #endif
1727 q15_t state[3]; /**< The state array of length 3. */
1728 q15_t Kp; /**< The proportional gain. */
1729 q15_t Ki; /**< The integral gain. */
1730 q15_t Kd; /**< The derivative gain. */
1731 } arm_pid_instance_q15;
1734 * @brief Instance structure for the Q31 PID Control.
1736 typedef struct
1738 q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1739 q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
1740 q31_t A2; /**< The derived gain, A2 = Kd . */
1741 q31_t state[3]; /**< The state array of length 3. */
1742 q31_t Kp; /**< The proportional gain. */
1743 q31_t Ki; /**< The integral gain. */
1744 q31_t Kd; /**< The derivative gain. */
1745 } arm_pid_instance_q31;
1748 * @brief Instance structure for the floating-point PID Control.
1750 typedef struct
1752 float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1753 float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
1754 float32_t A2; /**< The derived gain, A2 = Kd . */
1755 float32_t state[3]; /**< The state array of length 3. */
1756 float32_t Kp; /**< The proportional gain. */
1757 float32_t Ki; /**< The integral gain. */
1758 float32_t Kd; /**< The derivative gain. */
1759 } arm_pid_instance_f32;
1764 * @brief Initialization function for the floating-point PID Control.
1765 * @param[in,out] S points to an instance of the PID structure.
1766 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1768 void arm_pid_init_f32(
1769 arm_pid_instance_f32 * S,
1770 int32_t resetStateFlag);
1774 * @brief Reset function for the floating-point PID Control.
1775 * @param[in,out] S is an instance of the floating-point PID Control structure
1777 void arm_pid_reset_f32(
1778 arm_pid_instance_f32 * S);
1782 * @brief Initialization function for the Q31 PID Control.
1783 * @param[in,out] S points to an instance of the Q15 PID structure.
1784 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1786 void arm_pid_init_q31(
1787 arm_pid_instance_q31 * S,
1788 int32_t resetStateFlag);
1792 * @brief Reset function for the Q31 PID Control.
1793 * @param[in,out] S points to an instance of the Q31 PID Control structure
1796 void arm_pid_reset_q31(
1797 arm_pid_instance_q31 * S);
1801 * @brief Initialization function for the Q15 PID Control.
1802 * @param[in,out] S points to an instance of the Q15 PID structure.
1803 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1805 void arm_pid_init_q15(
1806 arm_pid_instance_q15 * S,
1807 int32_t resetStateFlag);
1811 * @brief Reset function for the Q15 PID Control.
1812 * @param[in,out] S points to an instance of the q15 PID Control structure
1814 void arm_pid_reset_q15(
1815 arm_pid_instance_q15 * S);
1819 * @brief Instance structure for the floating-point Linear Interpolate function.
1821 typedef struct
1823 uint32_t nValues; /**< nValues */
1824 float32_t x1; /**< x1 */
1825 float32_t xSpacing; /**< xSpacing */
1826 float32_t *pYData; /**< pointer to the table of Y values */
1827 } arm_linear_interp_instance_f32;
1830 * @brief Instance structure for the floating-point bilinear interpolation function.
1832 typedef struct
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. */
1837 } arm_bilinear_interp_instance_f32;
1840 * @brief Instance structure for the Q31 bilinear interpolation function.
1842 typedef struct
1844 uint16_t numRows; /**< number of rows in the data table. */
1845 uint16_t numCols; /**< number of columns in the data table. */
1846 q31_t *pData; /**< points to the data table. */
1847 } arm_bilinear_interp_instance_q31;
1850 * @brief Instance structure for the Q15 bilinear interpolation function.
1852 typedef struct
1854 uint16_t numRows; /**< number of rows in the data table. */
1855 uint16_t numCols; /**< number of columns in the data table. */
1856 q15_t *pData; /**< points to the data table. */
1857 } arm_bilinear_interp_instance_q15;
1860 * @brief Instance structure for the Q15 bilinear interpolation function.
1862 typedef struct
1864 uint16_t numRows; /**< number of rows in the data table. */
1865 uint16_t numCols; /**< number of columns in the data table. */
1866 q7_t *pData; /**< points to the data table. */
1867 } arm_bilinear_interp_instance_q7;
1871 * @brief Q7 vector multiplication.
1872 * @param[in] pSrcA points to the first input vector
1873 * @param[in] pSrcB points to the second input vector
1874 * @param[out] pDst points to the output vector
1875 * @param[in] blockSize number of samples in each vector
1877 void arm_mult_q7(
1878 q7_t * pSrcA,
1879 q7_t * pSrcB,
1880 q7_t * pDst,
1881 uint32_t blockSize);
1885 * @brief Q15 vector multiplication.
1886 * @param[in] pSrcA points to the first input vector
1887 * @param[in] pSrcB points to the second input vector
1888 * @param[out] pDst points to the output vector
1889 * @param[in] blockSize number of samples in each vector
1891 void arm_mult_q15(
1892 q15_t * pSrcA,
1893 q15_t * pSrcB,
1894 q15_t * pDst,
1895 uint32_t blockSize);
1899 * @brief Q31 vector multiplication.
1900 * @param[in] pSrcA points to the first input vector
1901 * @param[in] pSrcB points to the second input vector
1902 * @param[out] pDst points to the output vector
1903 * @param[in] blockSize number of samples in each vector
1905 void arm_mult_q31(
1906 q31_t * pSrcA,
1907 q31_t * pSrcB,
1908 q31_t * pDst,
1909 uint32_t blockSize);
1913 * @brief Floating-point vector multiplication.
1914 * @param[in] pSrcA points to the first input vector
1915 * @param[in] pSrcB points to the second input vector
1916 * @param[out] pDst points to the output vector
1917 * @param[in] blockSize number of samples in each vector
1919 void arm_mult_f32(
1920 float32_t * pSrcA,
1921 float32_t * pSrcB,
1922 float32_t * pDst,
1923 uint32_t blockSize);
1927 * @brief Instance structure for the Q15 CFFT/CIFFT function.
1929 typedef struct
1931 uint16_t fftLen; /**< length of the FFT. */
1932 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
1933 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
1934 q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
1935 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
1936 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
1937 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
1938 } arm_cfft_radix2_instance_q15;
1940 /* Deprecated */
1941 arm_status arm_cfft_radix2_init_q15(
1942 arm_cfft_radix2_instance_q15 * S,
1943 uint16_t fftLen,
1944 uint8_t ifftFlag,
1945 uint8_t bitReverseFlag);
1947 /* Deprecated */
1948 void arm_cfft_radix2_q15(
1949 const arm_cfft_radix2_instance_q15 * S,
1950 q15_t * pSrc);
1954 * @brief Instance structure for the Q15 CFFT/CIFFT function.
1956 typedef struct
1958 uint16_t fftLen; /**< length of the FFT. */
1959 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
1960 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
1961 q15_t *pTwiddle; /**< points to the twiddle factor table. */
1962 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
1963 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
1964 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
1965 } arm_cfft_radix4_instance_q15;
1967 /* Deprecated */
1968 arm_status arm_cfft_radix4_init_q15(
1969 arm_cfft_radix4_instance_q15 * S,
1970 uint16_t fftLen,
1971 uint8_t ifftFlag,
1972 uint8_t bitReverseFlag);
1974 /* Deprecated */
1975 void arm_cfft_radix4_q15(
1976 const arm_cfft_radix4_instance_q15 * S,
1977 q15_t * pSrc);
1980 * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
1982 typedef struct
1984 uint16_t fftLen; /**< length of the FFT. */
1985 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
1986 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
1987 q31_t *pTwiddle; /**< points to the Twiddle factor table. */
1988 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
1989 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
1990 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
1991 } arm_cfft_radix2_instance_q31;
1993 /* Deprecated */
1994 arm_status arm_cfft_radix2_init_q31(
1995 arm_cfft_radix2_instance_q31 * S,
1996 uint16_t fftLen,
1997 uint8_t ifftFlag,
1998 uint8_t bitReverseFlag);
2000 /* Deprecated */
2001 void arm_cfft_radix2_q31(
2002 const arm_cfft_radix2_instance_q31 * S,
2003 q31_t * pSrc);
2006 * @brief Instance structure for the Q31 CFFT/CIFFT function.
2008 typedef struct
2010 uint16_t fftLen; /**< length of the FFT. */
2011 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2012 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2013 q31_t *pTwiddle; /**< points to the twiddle factor table. */
2014 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2015 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2016 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2017 } arm_cfft_radix4_instance_q31;
2019 /* Deprecated */
2020 void arm_cfft_radix4_q31(
2021 const arm_cfft_radix4_instance_q31 * S,
2022 q31_t * pSrc);
2024 /* Deprecated */
2025 arm_status arm_cfft_radix4_init_q31(
2026 arm_cfft_radix4_instance_q31 * S,
2027 uint16_t fftLen,
2028 uint8_t ifftFlag,
2029 uint8_t bitReverseFlag);
2032 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2034 typedef struct
2036 uint16_t fftLen; /**< length of the FFT. */
2037 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2038 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2039 float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2040 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2041 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2042 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2043 float32_t onebyfftLen; /**< value of 1/fftLen. */
2044 } arm_cfft_radix2_instance_f32;
2046 /* Deprecated */
2047 arm_status arm_cfft_radix2_init_f32(
2048 arm_cfft_radix2_instance_f32 * S,
2049 uint16_t fftLen,
2050 uint8_t ifftFlag,
2051 uint8_t bitReverseFlag);
2053 /* Deprecated */
2054 void arm_cfft_radix2_f32(
2055 const arm_cfft_radix2_instance_f32 * S,
2056 float32_t * pSrc);
2059 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2061 typedef struct
2063 uint16_t fftLen; /**< length of the FFT. */
2064 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2065 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2066 float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2067 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2068 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2069 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2070 float32_t onebyfftLen; /**< value of 1/fftLen. */
2071 } arm_cfft_radix4_instance_f32;
2073 /* Deprecated */
2074 arm_status arm_cfft_radix4_init_f32(
2075 arm_cfft_radix4_instance_f32 * S,
2076 uint16_t fftLen,
2077 uint8_t ifftFlag,
2078 uint8_t bitReverseFlag);
2080 /* Deprecated */
2081 void arm_cfft_radix4_f32(
2082 const arm_cfft_radix4_instance_f32 * S,
2083 float32_t * pSrc);
2086 * @brief Instance structure for the fixed-point CFFT/CIFFT function.
2088 typedef struct
2090 uint16_t fftLen; /**< length of the FFT. */
2091 const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
2092 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2093 uint16_t bitRevLength; /**< bit reversal table length. */
2094 } arm_cfft_instance_q15;
2096 void arm_cfft_q15(
2097 const arm_cfft_instance_q15 * S,
2098 q15_t * p1,
2099 uint8_t ifftFlag,
2100 uint8_t bitReverseFlag);
2103 * @brief Instance structure for the fixed-point CFFT/CIFFT function.
2105 typedef struct
2107 uint16_t fftLen; /**< length of the FFT. */
2108 const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
2109 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2110 uint16_t bitRevLength; /**< bit reversal table length. */
2111 } arm_cfft_instance_q31;
2113 void arm_cfft_q31(
2114 const arm_cfft_instance_q31 * S,
2115 q31_t * p1,
2116 uint8_t ifftFlag,
2117 uint8_t bitReverseFlag);
2120 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2122 typedef struct
2124 uint16_t fftLen; /**< length of the FFT. */
2125 const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2126 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2127 uint16_t bitRevLength; /**< bit reversal table length. */
2128 } arm_cfft_instance_f32;
2130 void arm_cfft_f32(
2131 const arm_cfft_instance_f32 * S,
2132 float32_t * p1,
2133 uint8_t ifftFlag,
2134 uint8_t bitReverseFlag);
2137 * @brief Instance structure for the Q15 RFFT/RIFFT function.
2139 typedef struct
2141 uint32_t fftLenReal; /**< length of the real FFT. */
2142 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2143 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2144 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2145 q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2146 q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2147 const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
2148 } arm_rfft_instance_q15;
2150 arm_status arm_rfft_init_q15(
2151 arm_rfft_instance_q15 * S,
2152 uint32_t fftLenReal,
2153 uint32_t ifftFlagR,
2154 uint32_t bitReverseFlag);
2156 void arm_rfft_q15(
2157 const arm_rfft_instance_q15 * S,
2158 q15_t * pSrc,
2159 q15_t * pDst);
2162 * @brief Instance structure for the Q31 RFFT/RIFFT function.
2164 typedef struct
2166 uint32_t fftLenReal; /**< length of the real FFT. */
2167 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2168 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2169 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2170 q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2171 q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2172 const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
2173 } arm_rfft_instance_q31;
2175 arm_status arm_rfft_init_q31(
2176 arm_rfft_instance_q31 * S,
2177 uint32_t fftLenReal,
2178 uint32_t ifftFlagR,
2179 uint32_t bitReverseFlag);
2181 void arm_rfft_q31(
2182 const arm_rfft_instance_q31 * S,
2183 q31_t * pSrc,
2184 q31_t * pDst);
2187 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2189 typedef struct
2191 uint32_t fftLenReal; /**< length of the real FFT. */
2192 uint16_t fftLenBy2; /**< length of the complex FFT. */
2193 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2194 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2195 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2196 float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2197 float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2198 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
2199 } arm_rfft_instance_f32;
2201 arm_status arm_rfft_init_f32(
2202 arm_rfft_instance_f32 * S,
2203 arm_cfft_radix4_instance_f32 * S_CFFT,
2204 uint32_t fftLenReal,
2205 uint32_t ifftFlagR,
2206 uint32_t bitReverseFlag);
2208 void arm_rfft_f32(
2209 const arm_rfft_instance_f32 * S,
2210 float32_t * pSrc,
2211 float32_t * pDst);
2214 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2216 typedef struct
2218 arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
2219 uint16_t fftLenRFFT; /**< length of the real sequence */
2220 float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
2221 } arm_rfft_fast_instance_f32 ;
2223 arm_status arm_rfft_fast_init_f32 (
2224 arm_rfft_fast_instance_f32 * S,
2225 uint16_t fftLen);
2227 void arm_rfft_fast_f32(
2228 arm_rfft_fast_instance_f32 * S,
2229 float32_t * p, float32_t * pOut,
2230 uint8_t ifftFlag);
2233 * @brief Instance structure for the floating-point DCT4/IDCT4 function.
2235 typedef struct
2237 uint16_t N; /**< length of the DCT4. */
2238 uint16_t Nby2; /**< half of the length of the DCT4. */
2239 float32_t normalize; /**< normalizing factor. */
2240 float32_t *pTwiddle; /**< points to the twiddle factor table. */
2241 float32_t *pCosFactor; /**< points to the cosFactor table. */
2242 arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
2243 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
2244 } arm_dct4_instance_f32;
2248 * @brief Initialization function for the floating-point DCT4/IDCT4.
2249 * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
2250 * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
2251 * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
2252 * @param[in] N length of the DCT4.
2253 * @param[in] Nby2 half of the length of the DCT4.
2254 * @param[in] normalize normalizing factor.
2255 * @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.
2257 arm_status arm_dct4_init_f32(
2258 arm_dct4_instance_f32 * S,
2259 arm_rfft_instance_f32 * S_RFFT,
2260 arm_cfft_radix4_instance_f32 * S_CFFT,
2261 uint16_t N,
2262 uint16_t Nby2,
2263 float32_t normalize);
2267 * @brief Processing function for the floating-point DCT4/IDCT4.
2268 * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
2269 * @param[in] pState points to state buffer.
2270 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2272 void arm_dct4_f32(
2273 const arm_dct4_instance_f32 * S,
2274 float32_t * pState,
2275 float32_t * pInlineBuffer);
2279 * @brief Instance structure for the Q31 DCT4/IDCT4 function.
2281 typedef struct
2283 uint16_t N; /**< length of the DCT4. */
2284 uint16_t Nby2; /**< half of the length of the DCT4. */
2285 q31_t normalize; /**< normalizing factor. */
2286 q31_t *pTwiddle; /**< points to the twiddle factor table. */
2287 q31_t *pCosFactor; /**< points to the cosFactor table. */
2288 arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
2289 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
2290 } arm_dct4_instance_q31;
2294 * @brief Initialization function for the Q31 DCT4/IDCT4.
2295 * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
2296 * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
2297 * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
2298 * @param[in] N length of the DCT4.
2299 * @param[in] Nby2 half of the length of the DCT4.
2300 * @param[in] normalize normalizing factor.
2301 * @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.
2303 arm_status arm_dct4_init_q31(
2304 arm_dct4_instance_q31 * S,
2305 arm_rfft_instance_q31 * S_RFFT,
2306 arm_cfft_radix4_instance_q31 * S_CFFT,
2307 uint16_t N,
2308 uint16_t Nby2,
2309 q31_t normalize);
2313 * @brief Processing function for the Q31 DCT4/IDCT4.
2314 * @param[in] S points to an instance of the Q31 DCT4 structure.
2315 * @param[in] pState points to state buffer.
2316 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2318 void arm_dct4_q31(
2319 const arm_dct4_instance_q31 * S,
2320 q31_t * pState,
2321 q31_t * pInlineBuffer);
2325 * @brief Instance structure for the Q15 DCT4/IDCT4 function.
2327 typedef struct
2329 uint16_t N; /**< length of the DCT4. */
2330 uint16_t Nby2; /**< half of the length of the DCT4. */
2331 q15_t normalize; /**< normalizing factor. */
2332 q15_t *pTwiddle; /**< points to the twiddle factor table. */
2333 q15_t *pCosFactor; /**< points to the cosFactor table. */
2334 arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
2335 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
2336 } arm_dct4_instance_q15;
2340 * @brief Initialization function for the Q15 DCT4/IDCT4.
2341 * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
2342 * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
2343 * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
2344 * @param[in] N length of the DCT4.
2345 * @param[in] Nby2 half of the length of the DCT4.
2346 * @param[in] normalize normalizing factor.
2347 * @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.
2349 arm_status arm_dct4_init_q15(
2350 arm_dct4_instance_q15 * S,
2351 arm_rfft_instance_q15 * S_RFFT,
2352 arm_cfft_radix4_instance_q15 * S_CFFT,
2353 uint16_t N,
2354 uint16_t Nby2,
2355 q15_t normalize);
2359 * @brief Processing function for the Q15 DCT4/IDCT4.
2360 * @param[in] S points to an instance of the Q15 DCT4 structure.
2361 * @param[in] pState points to state buffer.
2362 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2364 void arm_dct4_q15(
2365 const arm_dct4_instance_q15 * S,
2366 q15_t * pState,
2367 q15_t * pInlineBuffer);
2371 * @brief Floating-point vector addition.
2372 * @param[in] pSrcA points to the first input vector
2373 * @param[in] pSrcB points to the second input vector
2374 * @param[out] pDst points to the output vector
2375 * @param[in] blockSize number of samples in each vector
2377 void arm_add_f32(
2378 float32_t * pSrcA,
2379 float32_t * pSrcB,
2380 float32_t * pDst,
2381 uint32_t blockSize);
2385 * @brief Q7 vector addition.
2386 * @param[in] pSrcA points to the first input vector
2387 * @param[in] pSrcB points to the second input vector
2388 * @param[out] pDst points to the output vector
2389 * @param[in] blockSize number of samples in each vector
2391 void arm_add_q7(
2392 q7_t * pSrcA,
2393 q7_t * pSrcB,
2394 q7_t * pDst,
2395 uint32_t blockSize);
2399 * @brief Q15 vector addition.
2400 * @param[in] pSrcA points to the first input vector
2401 * @param[in] pSrcB points to the second input vector
2402 * @param[out] pDst points to the output vector
2403 * @param[in] blockSize number of samples in each vector
2405 void arm_add_q15(
2406 q15_t * pSrcA,
2407 q15_t * pSrcB,
2408 q15_t * pDst,
2409 uint32_t blockSize);
2413 * @brief Q31 vector addition.
2414 * @param[in] pSrcA points to the first input vector
2415 * @param[in] pSrcB points to the second input vector
2416 * @param[out] pDst points to the output vector
2417 * @param[in] blockSize number of samples in each vector
2419 void arm_add_q31(
2420 q31_t * pSrcA,
2421 q31_t * pSrcB,
2422 q31_t * pDst,
2423 uint32_t blockSize);
2427 * @brief Floating-point vector subtraction.
2428 * @param[in] pSrcA points to the first input vector
2429 * @param[in] pSrcB points to the second input vector
2430 * @param[out] pDst points to the output vector
2431 * @param[in] blockSize number of samples in each vector
2433 void arm_sub_f32(
2434 float32_t * pSrcA,
2435 float32_t * pSrcB,
2436 float32_t * pDst,
2437 uint32_t blockSize);
2441 * @brief Q7 vector subtraction.
2442 * @param[in] pSrcA points to the first input vector
2443 * @param[in] pSrcB points to the second input vector
2444 * @param[out] pDst points to the output vector
2445 * @param[in] blockSize number of samples in each vector
2447 void arm_sub_q7(
2448 q7_t * pSrcA,
2449 q7_t * pSrcB,
2450 q7_t * pDst,
2451 uint32_t blockSize);
2455 * @brief Q15 vector subtraction.
2456 * @param[in] pSrcA points to the first input vector
2457 * @param[in] pSrcB points to the second input vector
2458 * @param[out] pDst points to the output vector
2459 * @param[in] blockSize number of samples in each vector
2461 void arm_sub_q15(
2462 q15_t * pSrcA,
2463 q15_t * pSrcB,
2464 q15_t * pDst,
2465 uint32_t blockSize);
2469 * @brief Q31 vector subtraction.
2470 * @param[in] pSrcA points to the first input vector
2471 * @param[in] pSrcB points to the second input vector
2472 * @param[out] pDst points to the output vector
2473 * @param[in] blockSize number of samples in each vector
2475 void arm_sub_q31(
2476 q31_t * pSrcA,
2477 q31_t * pSrcB,
2478 q31_t * pDst,
2479 uint32_t blockSize);
2483 * @brief Multiplies a floating-point vector by a scalar.
2484 * @param[in] pSrc points to the input vector
2485 * @param[in] scale scale factor to be applied
2486 * @param[out] pDst points to the output vector
2487 * @param[in] blockSize number of samples in the vector
2489 void arm_scale_f32(
2490 float32_t * pSrc,
2491 float32_t scale,
2492 float32_t * pDst,
2493 uint32_t blockSize);
2497 * @brief Multiplies a Q7 vector by a scalar.
2498 * @param[in] pSrc points to the input vector
2499 * @param[in] scaleFract fractional portion of the scale value
2500 * @param[in] shift number of bits to shift the result by
2501 * @param[out] pDst points to the output vector
2502 * @param[in] blockSize number of samples in the vector
2504 void arm_scale_q7(
2505 q7_t * pSrc,
2506 q7_t scaleFract,
2507 int8_t shift,
2508 q7_t * pDst,
2509 uint32_t blockSize);
2513 * @brief Multiplies a Q15 vector by a scalar.
2514 * @param[in] pSrc points to the input vector
2515 * @param[in] scaleFract fractional portion of the scale value
2516 * @param[in] shift number of bits to shift the result by
2517 * @param[out] pDst points to the output vector
2518 * @param[in] blockSize number of samples in the vector
2520 void arm_scale_q15(
2521 q15_t * pSrc,
2522 q15_t scaleFract,
2523 int8_t shift,
2524 q15_t * pDst,
2525 uint32_t blockSize);
2529 * @brief Multiplies a Q31 vector by a scalar.
2530 * @param[in] pSrc points to the input vector
2531 * @param[in] scaleFract fractional portion of the scale value
2532 * @param[in] shift number of bits to shift the result by
2533 * @param[out] pDst points to the output vector
2534 * @param[in] blockSize number of samples in the vector
2536 void arm_scale_q31(
2537 q31_t * pSrc,
2538 q31_t scaleFract,
2539 int8_t shift,
2540 q31_t * pDst,
2541 uint32_t blockSize);
2545 * @brief Q7 vector absolute value.
2546 * @param[in] pSrc points to the input buffer
2547 * @param[out] pDst points to the output buffer
2548 * @param[in] blockSize number of samples in each vector
2550 void arm_abs_q7(
2551 q7_t * pSrc,
2552 q7_t * pDst,
2553 uint32_t blockSize);
2557 * @brief Floating-point vector absolute value.
2558 * @param[in] pSrc points to the input buffer
2559 * @param[out] pDst points to the output buffer
2560 * @param[in] blockSize number of samples in each vector
2562 void arm_abs_f32(
2563 float32_t * pSrc,
2564 float32_t * pDst,
2565 uint32_t blockSize);
2569 * @brief Q15 vector absolute value.
2570 * @param[in] pSrc points to the input buffer
2571 * @param[out] pDst points to the output buffer
2572 * @param[in] blockSize number of samples in each vector
2574 void arm_abs_q15(
2575 q15_t * pSrc,
2576 q15_t * pDst,
2577 uint32_t blockSize);
2581 * @brief Q31 vector absolute value.
2582 * @param[in] pSrc points to the input buffer
2583 * @param[out] pDst points to the output buffer
2584 * @param[in] blockSize number of samples in each vector
2586 void arm_abs_q31(
2587 q31_t * pSrc,
2588 q31_t * pDst,
2589 uint32_t blockSize);
2593 * @brief Dot product of floating-point vectors.
2594 * @param[in] pSrcA points to the first input vector
2595 * @param[in] pSrcB points to the second input vector
2596 * @param[in] blockSize number of samples in each vector
2597 * @param[out] result output result returned here
2599 void arm_dot_prod_f32(
2600 float32_t * pSrcA,
2601 float32_t * pSrcB,
2602 uint32_t blockSize,
2603 float32_t * result);
2607 * @brief Dot product of Q7 vectors.
2608 * @param[in] pSrcA points to the first input vector
2609 * @param[in] pSrcB points to the second input vector
2610 * @param[in] blockSize number of samples in each vector
2611 * @param[out] result output result returned here
2613 void arm_dot_prod_q7(
2614 q7_t * pSrcA,
2615 q7_t * pSrcB,
2616 uint32_t blockSize,
2617 q31_t * result);
2621 * @brief Dot product of Q15 vectors.
2622 * @param[in] pSrcA points to the first input vector
2623 * @param[in] pSrcB points to the second input vector
2624 * @param[in] blockSize number of samples in each vector
2625 * @param[out] result output result returned here
2627 void arm_dot_prod_q15(
2628 q15_t * pSrcA,
2629 q15_t * pSrcB,
2630 uint32_t blockSize,
2631 q63_t * result);
2635 * @brief Dot product of Q31 vectors.
2636 * @param[in] pSrcA points to the first input vector
2637 * @param[in] pSrcB points to the second input vector
2638 * @param[in] blockSize number of samples in each vector
2639 * @param[out] result output result returned here
2641 void arm_dot_prod_q31(
2642 q31_t * pSrcA,
2643 q31_t * pSrcB,
2644 uint32_t blockSize,
2645 q63_t * result);
2649 * @brief Shifts the elements of a Q7 vector a specified number of bits.
2650 * @param[in] pSrc points to the input vector
2651 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2652 * @param[out] pDst points to the output vector
2653 * @param[in] blockSize number of samples in the vector
2655 void arm_shift_q7(
2656 q7_t * pSrc,
2657 int8_t shiftBits,
2658 q7_t * pDst,
2659 uint32_t blockSize);
2663 * @brief Shifts the elements of a Q15 vector a specified number of bits.
2664 * @param[in] pSrc points to the input vector
2665 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2666 * @param[out] pDst points to the output vector
2667 * @param[in] blockSize number of samples in the vector
2669 void arm_shift_q15(
2670 q15_t * pSrc,
2671 int8_t shiftBits,
2672 q15_t * pDst,
2673 uint32_t blockSize);
2677 * @brief Shifts the elements of a Q31 vector a specified number of bits.
2678 * @param[in] pSrc points to the input vector
2679 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2680 * @param[out] pDst points to the output vector
2681 * @param[in] blockSize number of samples in the vector
2683 void arm_shift_q31(
2684 q31_t * pSrc,
2685 int8_t shiftBits,
2686 q31_t * pDst,
2687 uint32_t blockSize);
2691 * @brief Adds a constant offset to a floating-point vector.
2692 * @param[in] pSrc points to the input vector
2693 * @param[in] offset is the offset to be added
2694 * @param[out] pDst points to the output vector
2695 * @param[in] blockSize number of samples in the vector
2697 void arm_offset_f32(
2698 float32_t * pSrc,
2699 float32_t offset,
2700 float32_t * pDst,
2701 uint32_t blockSize);
2705 * @brief Adds a constant offset to a Q7 vector.
2706 * @param[in] pSrc points to the input vector
2707 * @param[in] offset is the offset to be added
2708 * @param[out] pDst points to the output vector
2709 * @param[in] blockSize number of samples in the vector
2711 void arm_offset_q7(
2712 q7_t * pSrc,
2713 q7_t offset,
2714 q7_t * pDst,
2715 uint32_t blockSize);
2719 * @brief Adds a constant offset to a Q15 vector.
2720 * @param[in] pSrc points to the input vector
2721 * @param[in] offset is the offset to be added
2722 * @param[out] pDst points to the output vector
2723 * @param[in] blockSize number of samples in the vector
2725 void arm_offset_q15(
2726 q15_t * pSrc,
2727 q15_t offset,
2728 q15_t * pDst,
2729 uint32_t blockSize);
2733 * @brief Adds a constant offset to a Q31 vector.
2734 * @param[in] pSrc points to the input vector
2735 * @param[in] offset is the offset to be added
2736 * @param[out] pDst points to the output vector
2737 * @param[in] blockSize number of samples in the vector
2739 void arm_offset_q31(
2740 q31_t * pSrc,
2741 q31_t offset,
2742 q31_t * pDst,
2743 uint32_t blockSize);
2747 * @brief Negates the elements of a floating-point vector.
2748 * @param[in] pSrc points to the input vector
2749 * @param[out] pDst points to the output vector
2750 * @param[in] blockSize number of samples in the vector
2752 void arm_negate_f32(
2753 float32_t * pSrc,
2754 float32_t * pDst,
2755 uint32_t blockSize);
2759 * @brief Negates the elements of a Q7 vector.
2760 * @param[in] pSrc points to the input vector
2761 * @param[out] pDst points to the output vector
2762 * @param[in] blockSize number of samples in the vector
2764 void arm_negate_q7(
2765 q7_t * pSrc,
2766 q7_t * pDst,
2767 uint32_t blockSize);
2771 * @brief Negates the elements of a Q15 vector.
2772 * @param[in] pSrc points to the input vector
2773 * @param[out] pDst points to the output vector
2774 * @param[in] blockSize number of samples in the vector
2776 void arm_negate_q15(
2777 q15_t * pSrc,
2778 q15_t * pDst,
2779 uint32_t blockSize);
2783 * @brief Negates the elements of a Q31 vector.
2784 * @param[in] pSrc points to the input vector
2785 * @param[out] pDst points to the output vector
2786 * @param[in] blockSize number of samples in the vector
2788 void arm_negate_q31(
2789 q31_t * pSrc,
2790 q31_t * pDst,
2791 uint32_t blockSize);
2795 * @brief Copies the elements of a floating-point vector.
2796 * @param[in] pSrc input pointer
2797 * @param[out] pDst output pointer
2798 * @param[in] blockSize number of samples to process
2800 void arm_copy_f32(
2801 float32_t * pSrc,
2802 float32_t * pDst,
2803 uint32_t blockSize);
2807 * @brief Copies the elements of a Q7 vector.
2808 * @param[in] pSrc input pointer
2809 * @param[out] pDst output pointer
2810 * @param[in] blockSize number of samples to process
2812 void arm_copy_q7(
2813 q7_t * pSrc,
2814 q7_t * pDst,
2815 uint32_t blockSize);
2819 * @brief Copies the elements of a Q15 vector.
2820 * @param[in] pSrc input pointer
2821 * @param[out] pDst output pointer
2822 * @param[in] blockSize number of samples to process
2824 void arm_copy_q15(
2825 q15_t * pSrc,
2826 q15_t * pDst,
2827 uint32_t blockSize);
2831 * @brief Copies the elements of a Q31 vector.
2832 * @param[in] pSrc input pointer
2833 * @param[out] pDst output pointer
2834 * @param[in] blockSize number of samples to process
2836 void arm_copy_q31(
2837 q31_t * pSrc,
2838 q31_t * pDst,
2839 uint32_t blockSize);
2843 * @brief Fills a constant value into a floating-point vector.
2844 * @param[in] value input value to be filled
2845 * @param[out] pDst output pointer
2846 * @param[in] blockSize number of samples to process
2848 void arm_fill_f32(
2849 float32_t value,
2850 float32_t * pDst,
2851 uint32_t blockSize);
2855 * @brief Fills a constant value into a Q7 vector.
2856 * @param[in] value input value to be filled
2857 * @param[out] pDst output pointer
2858 * @param[in] blockSize number of samples to process
2860 void arm_fill_q7(
2861 q7_t value,
2862 q7_t * pDst,
2863 uint32_t blockSize);
2867 * @brief Fills a constant value into a Q15 vector.
2868 * @param[in] value input value to be filled
2869 * @param[out] pDst output pointer
2870 * @param[in] blockSize number of samples to process
2872 void arm_fill_q15(
2873 q15_t value,
2874 q15_t * pDst,
2875 uint32_t blockSize);
2879 * @brief Fills a constant value into a Q31 vector.
2880 * @param[in] value input value to be filled
2881 * @param[out] pDst output pointer
2882 * @param[in] blockSize number of samples to process
2884 void arm_fill_q31(
2885 q31_t value,
2886 q31_t * pDst,
2887 uint32_t blockSize);
2891 * @brief Convolution of floating-point sequences.
2892 * @param[in] pSrcA points to the first input sequence.
2893 * @param[in] srcALen length of the first input sequence.
2894 * @param[in] pSrcB points to the second input sequence.
2895 * @param[in] srcBLen length of the second input sequence.
2896 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
2898 void arm_conv_f32(
2899 float32_t * pSrcA,
2900 uint32_t srcALen,
2901 float32_t * pSrcB,
2902 uint32_t srcBLen,
2903 float32_t * pDst);
2907 * @brief Convolution of Q15 sequences.
2908 * @param[in] pSrcA points to the first input sequence.
2909 * @param[in] srcALen length of the first input sequence.
2910 * @param[in] pSrcB points to the second input sequence.
2911 * @param[in] srcBLen length of the second input sequence.
2912 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
2913 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
2914 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
2916 void arm_conv_opt_q15(
2917 q15_t * pSrcA,
2918 uint32_t srcALen,
2919 q15_t * pSrcB,
2920 uint32_t srcBLen,
2921 q15_t * pDst,
2922 q15_t * pScratch1,
2923 q15_t * pScratch2);
2927 * @brief Convolution of Q15 sequences.
2928 * @param[in] pSrcA points to the first input sequence.
2929 * @param[in] srcALen length of the first input sequence.
2930 * @param[in] pSrcB points to the second input sequence.
2931 * @param[in] srcBLen length of the second input sequence.
2932 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
2934 void arm_conv_q15(
2935 q15_t * pSrcA,
2936 uint32_t srcALen,
2937 q15_t * pSrcB,
2938 uint32_t srcBLen,
2939 q15_t * pDst);
2943 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
2944 * @param[in] pSrcA points to the first input sequence.
2945 * @param[in] srcALen length of the first input sequence.
2946 * @param[in] pSrcB points to the second input sequence.
2947 * @param[in] srcBLen length of the second input sequence.
2948 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
2950 void arm_conv_fast_q15(
2951 q15_t * pSrcA,
2952 uint32_t srcALen,
2953 q15_t * pSrcB,
2954 uint32_t srcBLen,
2955 q15_t * pDst);
2959 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
2960 * @param[in] pSrcA points to the first input sequence.
2961 * @param[in] srcALen length of the first input sequence.
2962 * @param[in] pSrcB points to the second input sequence.
2963 * @param[in] srcBLen length of the second input sequence.
2964 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
2965 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
2966 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
2968 void arm_conv_fast_opt_q15(
2969 q15_t * pSrcA,
2970 uint32_t srcALen,
2971 q15_t * pSrcB,
2972 uint32_t srcBLen,
2973 q15_t * pDst,
2974 q15_t * pScratch1,
2975 q15_t * pScratch2);
2979 * @brief Convolution of Q31 sequences.
2980 * @param[in] pSrcA points to the first input sequence.
2981 * @param[in] srcALen length of the first input sequence.
2982 * @param[in] pSrcB points to the second input sequence.
2983 * @param[in] srcBLen length of the second input sequence.
2984 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
2986 void arm_conv_q31(
2987 q31_t * pSrcA,
2988 uint32_t srcALen,
2989 q31_t * pSrcB,
2990 uint32_t srcBLen,
2991 q31_t * pDst);
2995 * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
2996 * @param[in] pSrcA points to the first input sequence.
2997 * @param[in] srcALen length of the first input sequence.
2998 * @param[in] pSrcB points to the second input sequence.
2999 * @param[in] srcBLen length of the second input sequence.
3000 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3002 void arm_conv_fast_q31(
3003 q31_t * pSrcA,
3004 uint32_t srcALen,
3005 q31_t * pSrcB,
3006 uint32_t srcBLen,
3007 q31_t * pDst);
3011 * @brief Convolution of Q7 sequences.
3012 * @param[in] pSrcA points to the first input sequence.
3013 * @param[in] srcALen length of the first input sequence.
3014 * @param[in] pSrcB points to the second input sequence.
3015 * @param[in] srcBLen length of the second input sequence.
3016 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3017 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3018 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3020 void arm_conv_opt_q7(
3021 q7_t * pSrcA,
3022 uint32_t srcALen,
3023 q7_t * pSrcB,
3024 uint32_t srcBLen,
3025 q7_t * pDst,
3026 q15_t * pScratch1,
3027 q15_t * pScratch2);
3031 * @brief Convolution of Q7 sequences.
3032 * @param[in] pSrcA points to the first input sequence.
3033 * @param[in] srcALen length of the first input sequence.
3034 * @param[in] pSrcB points to the second input sequence.
3035 * @param[in] srcBLen length of the second input sequence.
3036 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3038 void arm_conv_q7(
3039 q7_t * pSrcA,
3040 uint32_t srcALen,
3041 q7_t * pSrcB,
3042 uint32_t srcBLen,
3043 q7_t * pDst);
3047 * @brief Partial convolution of floating-point sequences.
3048 * @param[in] pSrcA points to the first input sequence.
3049 * @param[in] srcALen length of the first input sequence.
3050 * @param[in] pSrcB points to the second input sequence.
3051 * @param[in] srcBLen length of the second input sequence.
3052 * @param[out] pDst points to the block of output data
3053 * @param[in] firstIndex is the first output sample to start with.
3054 * @param[in] numPoints is the number of output points to be computed.
3055 * @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].
3057 arm_status arm_conv_partial_f32(
3058 float32_t * pSrcA,
3059 uint32_t srcALen,
3060 float32_t * pSrcB,
3061 uint32_t srcBLen,
3062 float32_t * pDst,
3063 uint32_t firstIndex,
3064 uint32_t numPoints);
3068 * @brief Partial convolution of Q15 sequences.
3069 * @param[in] pSrcA points to the first input sequence.
3070 * @param[in] srcALen length of the first input sequence.
3071 * @param[in] pSrcB points to the second input sequence.
3072 * @param[in] srcBLen length of the second input sequence.
3073 * @param[out] pDst points to the block of output data
3074 * @param[in] firstIndex is the first output sample to start with.
3075 * @param[in] numPoints is the number of output points to be computed.
3076 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3077 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3078 * @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].
3080 arm_status arm_conv_partial_opt_q15(
3081 q15_t * pSrcA,
3082 uint32_t srcALen,
3083 q15_t * pSrcB,
3084 uint32_t srcBLen,
3085 q15_t * pDst,
3086 uint32_t firstIndex,
3087 uint32_t numPoints,
3088 q15_t * pScratch1,
3089 q15_t * pScratch2);
3093 * @brief Partial convolution of Q15 sequences.
3094 * @param[in] pSrcA points to the first input sequence.
3095 * @param[in] srcALen length of the first input sequence.
3096 * @param[in] pSrcB points to the second input sequence.
3097 * @param[in] srcBLen length of the second input sequence.
3098 * @param[out] pDst points to the block of output data
3099 * @param[in] firstIndex is the first output sample to start with.
3100 * @param[in] numPoints is the number of output points to be computed.
3101 * @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].
3103 arm_status arm_conv_partial_q15(
3104 q15_t * pSrcA,
3105 uint32_t srcALen,
3106 q15_t * pSrcB,
3107 uint32_t srcBLen,
3108 q15_t * pDst,
3109 uint32_t firstIndex,
3110 uint32_t numPoints);
3114 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3115 * @param[in] pSrcA points to the first input sequence.
3116 * @param[in] srcALen length of the first input sequence.
3117 * @param[in] pSrcB points to the second input sequence.
3118 * @param[in] srcBLen length of the second input sequence.
3119 * @param[out] pDst points to the block of output data
3120 * @param[in] firstIndex is the first output sample to start with.
3121 * @param[in] numPoints is the number of output points to be computed.
3122 * @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].
3124 arm_status arm_conv_partial_fast_q15(
3125 q15_t * pSrcA,
3126 uint32_t srcALen,
3127 q15_t * pSrcB,
3128 uint32_t srcBLen,
3129 q15_t * pDst,
3130 uint32_t firstIndex,
3131 uint32_t numPoints);
3135 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3136 * @param[in] pSrcA points to the first input sequence.
3137 * @param[in] srcALen length of the first input sequence.
3138 * @param[in] pSrcB points to the second input sequence.
3139 * @param[in] srcBLen length of the second input sequence.
3140 * @param[out] pDst points to the block of output data
3141 * @param[in] firstIndex is the first output sample to start with.
3142 * @param[in] numPoints is the number of output points to be computed.
3143 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3144 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3145 * @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].
3147 arm_status arm_conv_partial_fast_opt_q15(
3148 q15_t * pSrcA,
3149 uint32_t srcALen,
3150 q15_t * pSrcB,
3151 uint32_t srcBLen,
3152 q15_t * pDst,
3153 uint32_t firstIndex,
3154 uint32_t numPoints,
3155 q15_t * pScratch1,
3156 q15_t * pScratch2);
3160 * @brief Partial convolution of Q31 sequences.
3161 * @param[in] pSrcA points to the first input sequence.
3162 * @param[in] srcALen length of the first input sequence.
3163 * @param[in] pSrcB points to the second input sequence.
3164 * @param[in] srcBLen length of the second input sequence.
3165 * @param[out] pDst points to the block of output data
3166 * @param[in] firstIndex is the first output sample to start with.
3167 * @param[in] numPoints is the number of output points to be computed.
3168 * @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].
3170 arm_status arm_conv_partial_q31(
3171 q31_t * pSrcA,
3172 uint32_t srcALen,
3173 q31_t * pSrcB,
3174 uint32_t srcBLen,
3175 q31_t * pDst,
3176 uint32_t firstIndex,
3177 uint32_t numPoints);
3181 * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3182 * @param[in] pSrcA points to the first input sequence.
3183 * @param[in] srcALen length of the first input sequence.
3184 * @param[in] pSrcB points to the second input sequence.
3185 * @param[in] srcBLen length of the second input sequence.
3186 * @param[out] pDst points to the block of output data
3187 * @param[in] firstIndex is the first output sample to start with.
3188 * @param[in] numPoints is the number of output points to be computed.
3189 * @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].
3191 arm_status arm_conv_partial_fast_q31(
3192 q31_t * pSrcA,
3193 uint32_t srcALen,
3194 q31_t * pSrcB,
3195 uint32_t srcBLen,
3196 q31_t * pDst,
3197 uint32_t firstIndex,
3198 uint32_t numPoints);
3202 * @brief Partial convolution of Q7 sequences
3203 * @param[in] pSrcA points to the first input sequence.
3204 * @param[in] srcALen length of the first input sequence.
3205 * @param[in] pSrcB points to the second input sequence.
3206 * @param[in] srcBLen length of the second input sequence.
3207 * @param[out] pDst points to the block of output data
3208 * @param[in] firstIndex is the first output sample to start with.
3209 * @param[in] numPoints is the number of output points to be computed.
3210 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3211 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3212 * @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].
3214 arm_status arm_conv_partial_opt_q7(
3215 q7_t * pSrcA,
3216 uint32_t srcALen,
3217 q7_t * pSrcB,
3218 uint32_t srcBLen,
3219 q7_t * pDst,
3220 uint32_t firstIndex,
3221 uint32_t numPoints,
3222 q15_t * pScratch1,
3223 q15_t * pScratch2);
3227 * @brief Partial convolution of Q7 sequences.
3228 * @param[in] pSrcA points to the first input sequence.
3229 * @param[in] srcALen length of the first input sequence.
3230 * @param[in] pSrcB points to the second input sequence.
3231 * @param[in] srcBLen length of the second input sequence.
3232 * @param[out] pDst points to the block of output data
3233 * @param[in] firstIndex is the first output sample to start with.
3234 * @param[in] numPoints is the number of output points to be computed.
3235 * @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].
3237 arm_status arm_conv_partial_q7(
3238 q7_t * pSrcA,
3239 uint32_t srcALen,
3240 q7_t * pSrcB,
3241 uint32_t srcBLen,
3242 q7_t * pDst,
3243 uint32_t firstIndex,
3244 uint32_t numPoints);
3248 * @brief Instance structure for the Q15 FIR decimator.
3250 typedef struct
3252 uint8_t M; /**< decimation factor. */
3253 uint16_t numTaps; /**< number of coefficients in the filter. */
3254 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3255 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3256 } arm_fir_decimate_instance_q15;
3259 * @brief Instance structure for the Q31 FIR decimator.
3261 typedef struct
3263 uint8_t M; /**< decimation factor. */
3264 uint16_t numTaps; /**< number of coefficients in the filter. */
3265 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3266 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3267 } arm_fir_decimate_instance_q31;
3270 * @brief Instance structure for the floating-point FIR decimator.
3272 typedef struct
3274 uint8_t M; /**< decimation factor. */
3275 uint16_t numTaps; /**< number of coefficients in the filter. */
3276 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3277 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3278 } arm_fir_decimate_instance_f32;
3282 * @brief Processing function for the floating-point FIR decimator.
3283 * @param[in] S points to an instance of the floating-point FIR decimator structure.
3284 * @param[in] pSrc points to the block of input data.
3285 * @param[out] pDst points to the block of output data
3286 * @param[in] blockSize number of input samples to process per call.
3288 void arm_fir_decimate_f32(
3289 const arm_fir_decimate_instance_f32 * S,
3290 float32_t * pSrc,
3291 float32_t * pDst,
3292 uint32_t blockSize);
3296 * @brief Initialization function for the floating-point FIR decimator.
3297 * @param[in,out] S points to an instance of the floating-point FIR decimator structure.
3298 * @param[in] numTaps number of coefficients in the filter.
3299 * @param[in] M decimation factor.
3300 * @param[in] pCoeffs points to the filter coefficients.
3301 * @param[in] pState points to the state buffer.
3302 * @param[in] blockSize number of input samples to process per call.
3303 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3304 * <code>blockSize</code> is not a multiple of <code>M</code>.
3306 arm_status arm_fir_decimate_init_f32(
3307 arm_fir_decimate_instance_f32 * S,
3308 uint16_t numTaps,
3309 uint8_t M,
3310 float32_t * pCoeffs,
3311 float32_t * pState,
3312 uint32_t blockSize);
3316 * @brief Processing function for the Q15 FIR decimator.
3317 * @param[in] S points to an instance of the Q15 FIR decimator structure.
3318 * @param[in] pSrc points to the block of input data.
3319 * @param[out] pDst points to the block of output data
3320 * @param[in] blockSize number of input samples to process per call.
3322 void arm_fir_decimate_q15(
3323 const arm_fir_decimate_instance_q15 * S,
3324 q15_t * pSrc,
3325 q15_t * pDst,
3326 uint32_t blockSize);
3330 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3331 * @param[in] S points to an instance of the Q15 FIR decimator structure.
3332 * @param[in] pSrc points to the block of input data.
3333 * @param[out] pDst points to the block of output data
3334 * @param[in] blockSize number of input samples to process per call.
3336 void arm_fir_decimate_fast_q15(
3337 const arm_fir_decimate_instance_q15 * S,
3338 q15_t * pSrc,
3339 q15_t * pDst,
3340 uint32_t blockSize);
3344 * @brief Initialization function for the Q15 FIR decimator.
3345 * @param[in,out] S points to an instance of the Q15 FIR decimator structure.
3346 * @param[in] numTaps number of coefficients in the filter.
3347 * @param[in] M decimation factor.
3348 * @param[in] pCoeffs points to the filter coefficients.
3349 * @param[in] pState points to the state buffer.
3350 * @param[in] blockSize number of input samples to process per call.
3351 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3352 * <code>blockSize</code> is not a multiple of <code>M</code>.
3354 arm_status arm_fir_decimate_init_q15(
3355 arm_fir_decimate_instance_q15 * S,
3356 uint16_t numTaps,
3357 uint8_t M,
3358 q15_t * pCoeffs,
3359 q15_t * pState,
3360 uint32_t blockSize);
3364 * @brief Processing function for the Q31 FIR decimator.
3365 * @param[in] S points to an instance of the Q31 FIR decimator structure.
3366 * @param[in] pSrc points to the block of input data.
3367 * @param[out] pDst points to the block of output data
3368 * @param[in] blockSize number of input samples to process per call.
3370 void arm_fir_decimate_q31(
3371 const arm_fir_decimate_instance_q31 * S,
3372 q31_t * pSrc,
3373 q31_t * pDst,
3374 uint32_t blockSize);
3377 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3378 * @param[in] S points to an instance of the Q31 FIR decimator structure.
3379 * @param[in] pSrc points to the block of input data.
3380 * @param[out] pDst points to the block of output data
3381 * @param[in] blockSize number of input samples to process per call.
3383 void arm_fir_decimate_fast_q31(
3384 arm_fir_decimate_instance_q31 * S,
3385 q31_t * pSrc,
3386 q31_t * pDst,
3387 uint32_t blockSize);
3391 * @brief Initialization function for the Q31 FIR decimator.
3392 * @param[in,out] S points to an instance of the Q31 FIR decimator structure.
3393 * @param[in] numTaps number of coefficients in the filter.
3394 * @param[in] M decimation factor.
3395 * @param[in] pCoeffs points to the filter coefficients.
3396 * @param[in] pState points to the state buffer.
3397 * @param[in] blockSize number of input samples to process per call.
3398 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3399 * <code>blockSize</code> is not a multiple of <code>M</code>.
3401 arm_status arm_fir_decimate_init_q31(
3402 arm_fir_decimate_instance_q31 * S,
3403 uint16_t numTaps,
3404 uint8_t M,
3405 q31_t * pCoeffs,
3406 q31_t * pState,
3407 uint32_t blockSize);
3411 * @brief Instance structure for the Q15 FIR interpolator.
3413 typedef struct
3415 uint8_t L; /**< upsample factor. */
3416 uint16_t phaseLength; /**< length of each polyphase filter component. */
3417 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3418 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3419 } arm_fir_interpolate_instance_q15;
3422 * @brief Instance structure for the Q31 FIR interpolator.
3424 typedef struct
3426 uint8_t L; /**< upsample factor. */
3427 uint16_t phaseLength; /**< length of each polyphase filter component. */
3428 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3429 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3430 } arm_fir_interpolate_instance_q31;
3433 * @brief Instance structure for the floating-point FIR interpolator.
3435 typedef struct
3437 uint8_t L; /**< upsample factor. */
3438 uint16_t phaseLength; /**< length of each polyphase filter component. */
3439 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3440 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
3441 } arm_fir_interpolate_instance_f32;
3445 * @brief Processing function for the Q15 FIR interpolator.
3446 * @param[in] S points to an instance of the Q15 FIR interpolator structure.
3447 * @param[in] pSrc points to the block of input data.
3448 * @param[out] pDst points to the block of output data.
3449 * @param[in] blockSize number of input samples to process per call.
3451 void arm_fir_interpolate_q15(
3452 const arm_fir_interpolate_instance_q15 * S,
3453 q15_t * pSrc,
3454 q15_t * pDst,
3455 uint32_t blockSize);
3459 * @brief Initialization function for the Q15 FIR interpolator.
3460 * @param[in,out] S points to an instance of the Q15 FIR interpolator structure.
3461 * @param[in] L upsample factor.
3462 * @param[in] numTaps number of filter coefficients in the filter.
3463 * @param[in] pCoeffs points to the filter coefficient buffer.
3464 * @param[in] pState points to the state buffer.
3465 * @param[in] blockSize number of input samples to process per call.
3466 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3467 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3469 arm_status arm_fir_interpolate_init_q15(
3470 arm_fir_interpolate_instance_q15 * S,
3471 uint8_t L,
3472 uint16_t numTaps,
3473 q15_t * pCoeffs,
3474 q15_t * pState,
3475 uint32_t blockSize);
3479 * @brief Processing function for the Q31 FIR interpolator.
3480 * @param[in] S points to an instance of the Q15 FIR interpolator structure.
3481 * @param[in] pSrc points to the block of input data.
3482 * @param[out] pDst points to the block of output data.
3483 * @param[in] blockSize number of input samples to process per call.
3485 void arm_fir_interpolate_q31(
3486 const arm_fir_interpolate_instance_q31 * S,
3487 q31_t * pSrc,
3488 q31_t * pDst,
3489 uint32_t blockSize);
3493 * @brief Initialization function for the Q31 FIR interpolator.
3494 * @param[in,out] S points to an instance of the Q31 FIR interpolator structure.
3495 * @param[in] L upsample factor.
3496 * @param[in] numTaps number of filter coefficients in the filter.
3497 * @param[in] pCoeffs points to the filter coefficient buffer.
3498 * @param[in] pState points to the state buffer.
3499 * @param[in] blockSize number of input samples to process per call.
3500 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3501 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3503 arm_status arm_fir_interpolate_init_q31(
3504 arm_fir_interpolate_instance_q31 * S,
3505 uint8_t L,
3506 uint16_t numTaps,
3507 q31_t * pCoeffs,
3508 q31_t * pState,
3509 uint32_t blockSize);
3513 * @brief Processing function for the floating-point FIR interpolator.
3514 * @param[in] S points to an instance of the floating-point FIR interpolator structure.
3515 * @param[in] pSrc points to the block of input data.
3516 * @param[out] pDst points to the block of output data.
3517 * @param[in] blockSize number of input samples to process per call.
3519 void arm_fir_interpolate_f32(
3520 const arm_fir_interpolate_instance_f32 * S,
3521 float32_t * pSrc,
3522 float32_t * pDst,
3523 uint32_t blockSize);
3527 * @brief Initialization function for the floating-point FIR interpolator.
3528 * @param[in,out] S points to an instance of the floating-point FIR interpolator structure.
3529 * @param[in] L upsample factor.
3530 * @param[in] numTaps number of filter coefficients in the filter.
3531 * @param[in] pCoeffs points to the filter coefficient buffer.
3532 * @param[in] pState points to the state buffer.
3533 * @param[in] blockSize number of input samples to process per call.
3534 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3535 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3537 arm_status arm_fir_interpolate_init_f32(
3538 arm_fir_interpolate_instance_f32 * S,
3539 uint8_t L,
3540 uint16_t numTaps,
3541 float32_t * pCoeffs,
3542 float32_t * pState,
3543 uint32_t blockSize);
3547 * @brief Instance structure for the high precision Q31 Biquad cascade filter.
3549 typedef struct
3551 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3552 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3553 q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3554 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
3555 } arm_biquad_cas_df1_32x64_ins_q31;
3559 * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure.
3560 * @param[in] pSrc points to the block of input data.
3561 * @param[out] pDst points to the block of output data
3562 * @param[in] blockSize number of samples to process.
3564 void arm_biquad_cas_df1_32x64_q31(
3565 const arm_biquad_cas_df1_32x64_ins_q31 * S,
3566 q31_t * pSrc,
3567 q31_t * pDst,
3568 uint32_t blockSize);
3572 * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure.
3573 * @param[in] numStages number of 2nd order stages in the filter.
3574 * @param[in] pCoeffs points to the filter coefficients.
3575 * @param[in] pState points to the state buffer.
3576 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
3578 void arm_biquad_cas_df1_32x64_init_q31(
3579 arm_biquad_cas_df1_32x64_ins_q31 * S,
3580 uint8_t numStages,
3581 q31_t * pCoeffs,
3582 q63_t * pState,
3583 uint8_t postShift);
3587 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3589 typedef struct
3591 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3592 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3593 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3594 } arm_biquad_cascade_df2T_instance_f32;
3597 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3599 typedef struct
3601 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3602 float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3603 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3604 } arm_biquad_cascade_stereo_df2T_instance_f32;
3607 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3609 typedef struct
3611 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3612 float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3613 float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3614 } arm_biquad_cascade_df2T_instance_f64;
3618 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3619 * @param[in] S points to an instance of the filter data structure.
3620 * @param[in] pSrc points to the block of input data.
3621 * @param[out] pDst points to the block of output data
3622 * @param[in] blockSize number of samples to process.
3624 void arm_biquad_cascade_df2T_f32(
3625 const arm_biquad_cascade_df2T_instance_f32 * S,
3626 float32_t * pSrc,
3627 float32_t * pDst,
3628 uint32_t blockSize);
3632 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
3633 * @param[in] S points to an instance of the filter data structure.
3634 * @param[in] pSrc points to the block of input data.
3635 * @param[out] pDst points to the block of output data
3636 * @param[in] blockSize number of samples to process.
3638 void arm_biquad_cascade_stereo_df2T_f32(
3639 const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
3640 float32_t * pSrc,
3641 float32_t * pDst,
3642 uint32_t blockSize);
3646 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3647 * @param[in] S points to an instance of the filter data structure.
3648 * @param[in] pSrc points to the block of input data.
3649 * @param[out] pDst points to the block of output data
3650 * @param[in] blockSize number of samples to process.
3652 void arm_biquad_cascade_df2T_f64(
3653 const arm_biquad_cascade_df2T_instance_f64 * S,
3654 float64_t * pSrc,
3655 float64_t * pDst,
3656 uint32_t blockSize);
3660 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3661 * @param[in,out] S points to an instance of the filter data structure.
3662 * @param[in] numStages number of 2nd order stages in the filter.
3663 * @param[in] pCoeffs points to the filter coefficients.
3664 * @param[in] pState points to the state buffer.
3666 void arm_biquad_cascade_df2T_init_f32(
3667 arm_biquad_cascade_df2T_instance_f32 * S,
3668 uint8_t numStages,
3669 float32_t * pCoeffs,
3670 float32_t * pState);
3674 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3675 * @param[in,out] S points to an instance of the filter data structure.
3676 * @param[in] numStages number of 2nd order stages in the filter.
3677 * @param[in] pCoeffs points to the filter coefficients.
3678 * @param[in] pState points to the state buffer.
3680 void arm_biquad_cascade_stereo_df2T_init_f32(
3681 arm_biquad_cascade_stereo_df2T_instance_f32 * S,
3682 uint8_t numStages,
3683 float32_t * pCoeffs,
3684 float32_t * pState);
3688 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3689 * @param[in,out] S points to an instance of the filter data structure.
3690 * @param[in] numStages number of 2nd order stages in the filter.
3691 * @param[in] pCoeffs points to the filter coefficients.
3692 * @param[in] pState points to the state buffer.
3694 void arm_biquad_cascade_df2T_init_f64(
3695 arm_biquad_cascade_df2T_instance_f64 * S,
3696 uint8_t numStages,
3697 float64_t * pCoeffs,
3698 float64_t * pState);
3702 * @brief Instance structure for the Q15 FIR lattice filter.
3704 typedef struct
3706 uint16_t numStages; /**< number of filter stages. */
3707 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
3708 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3709 } arm_fir_lattice_instance_q15;
3712 * @brief Instance structure for the Q31 FIR lattice filter.
3714 typedef struct
3716 uint16_t numStages; /**< number of filter stages. */
3717 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
3718 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3719 } arm_fir_lattice_instance_q31;
3722 * @brief Instance structure for the floating-point FIR lattice filter.
3724 typedef struct
3726 uint16_t numStages; /**< number of filter stages. */
3727 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
3728 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3729 } arm_fir_lattice_instance_f32;
3733 * @brief Initialization function for the Q15 FIR lattice filter.
3734 * @param[in] S points to an instance of the Q15 FIR lattice structure.
3735 * @param[in] numStages number of filter stages.
3736 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3737 * @param[in] pState points to the state buffer. The array is of length numStages.
3739 void arm_fir_lattice_init_q15(
3740 arm_fir_lattice_instance_q15 * S,
3741 uint16_t numStages,
3742 q15_t * pCoeffs,
3743 q15_t * pState);
3747 * @brief Processing function for the Q15 FIR lattice filter.
3748 * @param[in] S points to an instance of the Q15 FIR lattice structure.
3749 * @param[in] pSrc points to the block of input data.
3750 * @param[out] pDst points to the block of output data.
3751 * @param[in] blockSize number of samples to process.
3753 void arm_fir_lattice_q15(
3754 const arm_fir_lattice_instance_q15 * S,
3755 q15_t * pSrc,
3756 q15_t * pDst,
3757 uint32_t blockSize);
3761 * @brief Initialization function for the Q31 FIR lattice filter.
3762 * @param[in] S points to an instance of the Q31 FIR lattice structure.
3763 * @param[in] numStages number of filter stages.
3764 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3765 * @param[in] pState points to the state buffer. The array is of length numStages.
3767 void arm_fir_lattice_init_q31(
3768 arm_fir_lattice_instance_q31 * S,
3769 uint16_t numStages,
3770 q31_t * pCoeffs,
3771 q31_t * pState);
3775 * @brief Processing function for the Q31 FIR lattice filter.
3776 * @param[in] S points to an instance of the Q31 FIR lattice structure.
3777 * @param[in] pSrc points to the block of input data.
3778 * @param[out] pDst points to the block of output data
3779 * @param[in] blockSize number of samples to process.
3781 void arm_fir_lattice_q31(
3782 const arm_fir_lattice_instance_q31 * S,
3783 q31_t * pSrc,
3784 q31_t * pDst,
3785 uint32_t blockSize);
3789 * @brief Initialization function for the floating-point FIR lattice filter.
3790 * @param[in] S points to an instance of the floating-point FIR lattice structure.
3791 * @param[in] numStages number of filter stages.
3792 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3793 * @param[in] pState points to the state buffer. The array is of length numStages.
3795 void arm_fir_lattice_init_f32(
3796 arm_fir_lattice_instance_f32 * S,
3797 uint16_t numStages,
3798 float32_t * pCoeffs,
3799 float32_t * pState);
3803 * @brief Processing function for the floating-point FIR lattice filter.
3804 * @param[in] S points to an instance of the floating-point FIR lattice structure.
3805 * @param[in] pSrc points to the block of input data.
3806 * @param[out] pDst points to the block of output data
3807 * @param[in] blockSize number of samples to process.
3809 void arm_fir_lattice_f32(
3810 const arm_fir_lattice_instance_f32 * S,
3811 float32_t * pSrc,
3812 float32_t * pDst,
3813 uint32_t blockSize);
3817 * @brief Instance structure for the Q15 IIR lattice filter.
3819 typedef struct
3821 uint16_t numStages; /**< number of stages in the filter. */
3822 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3823 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3824 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3825 } arm_iir_lattice_instance_q15;
3828 * @brief Instance structure for the Q31 IIR lattice filter.
3830 typedef struct
3832 uint16_t numStages; /**< number of stages in the filter. */
3833 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3834 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3835 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3836 } arm_iir_lattice_instance_q31;
3839 * @brief Instance structure for the floating-point IIR lattice filter.
3841 typedef struct
3843 uint16_t numStages; /**< number of stages in the filter. */
3844 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3845 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3846 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3847 } arm_iir_lattice_instance_f32;
3851 * @brief Processing function for the floating-point IIR lattice filter.
3852 * @param[in] S points to an instance of the floating-point IIR lattice structure.
3853 * @param[in] pSrc points to the block of input data.
3854 * @param[out] pDst points to the block of output data.
3855 * @param[in] blockSize number of samples to process.
3857 void arm_iir_lattice_f32(
3858 const arm_iir_lattice_instance_f32 * S,
3859 float32_t * pSrc,
3860 float32_t * pDst,
3861 uint32_t blockSize);
3865 * @brief Initialization function for the floating-point IIR lattice filter.
3866 * @param[in] S points to an instance of the floating-point IIR lattice structure.
3867 * @param[in] numStages number of stages in the filter.
3868 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3869 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3870 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1.
3871 * @param[in] blockSize number of samples to process.
3873 void arm_iir_lattice_init_f32(
3874 arm_iir_lattice_instance_f32 * S,
3875 uint16_t numStages,
3876 float32_t * pkCoeffs,
3877 float32_t * pvCoeffs,
3878 float32_t * pState,
3879 uint32_t blockSize);
3883 * @brief Processing function for the Q31 IIR lattice filter.
3884 * @param[in] S points to an instance of the Q31 IIR lattice structure.
3885 * @param[in] pSrc points to the block of input data.
3886 * @param[out] pDst points to the block of output data.
3887 * @param[in] blockSize number of samples to process.
3889 void arm_iir_lattice_q31(
3890 const arm_iir_lattice_instance_q31 * S,
3891 q31_t * pSrc,
3892 q31_t * pDst,
3893 uint32_t blockSize);
3897 * @brief Initialization function for the Q31 IIR lattice filter.
3898 * @param[in] S points to an instance of the Q31 IIR lattice structure.
3899 * @param[in] numStages number of stages in the filter.
3900 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3901 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3902 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize.
3903 * @param[in] blockSize number of samples to process.
3905 void arm_iir_lattice_init_q31(
3906 arm_iir_lattice_instance_q31 * S,
3907 uint16_t numStages,
3908 q31_t * pkCoeffs,
3909 q31_t * pvCoeffs,
3910 q31_t * pState,
3911 uint32_t blockSize);
3915 * @brief Processing function for the Q15 IIR lattice filter.
3916 * @param[in] S points to an instance of the Q15 IIR lattice structure.
3917 * @param[in] pSrc points to the block of input data.
3918 * @param[out] pDst points to the block of output data.
3919 * @param[in] blockSize number of samples to process.
3921 void arm_iir_lattice_q15(
3922 const arm_iir_lattice_instance_q15 * S,
3923 q15_t * pSrc,
3924 q15_t * pDst,
3925 uint32_t blockSize);
3929 * @brief Initialization function for the Q15 IIR lattice filter.
3930 * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure.
3931 * @param[in] numStages number of stages in the filter.
3932 * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
3933 * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
3934 * @param[in] pState points to state buffer. The array is of length numStages+blockSize.
3935 * @param[in] blockSize number of samples to process per call.
3937 void arm_iir_lattice_init_q15(
3938 arm_iir_lattice_instance_q15 * S,
3939 uint16_t numStages,
3940 q15_t * pkCoeffs,
3941 q15_t * pvCoeffs,
3942 q15_t * pState,
3943 uint32_t blockSize);
3947 * @brief Instance structure for the floating-point LMS filter.
3949 typedef struct
3951 uint16_t numTaps; /**< number of coefficients in the filter. */
3952 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3953 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
3954 float32_t mu; /**< step size that controls filter coefficient updates. */
3955 } arm_lms_instance_f32;
3959 * @brief Processing function for floating-point LMS filter.
3960 * @param[in] S points to an instance of the floating-point LMS filter structure.
3961 * @param[in] pSrc points to the block of input data.
3962 * @param[in] pRef points to the block of reference data.
3963 * @param[out] pOut points to the block of output data.
3964 * @param[out] pErr points to the block of error data.
3965 * @param[in] blockSize number of samples to process.
3967 void arm_lms_f32(
3968 const arm_lms_instance_f32 * S,
3969 float32_t * pSrc,
3970 float32_t * pRef,
3971 float32_t * pOut,
3972 float32_t * pErr,
3973 uint32_t blockSize);
3977 * @brief Initialization function for floating-point LMS filter.
3978 * @param[in] S points to an instance of the floating-point LMS filter structure.
3979 * @param[in] numTaps number of filter coefficients.
3980 * @param[in] pCoeffs points to the coefficient buffer.
3981 * @param[in] pState points to state buffer.
3982 * @param[in] mu step size that controls filter coefficient updates.
3983 * @param[in] blockSize number of samples to process.
3985 void arm_lms_init_f32(
3986 arm_lms_instance_f32 * S,
3987 uint16_t numTaps,
3988 float32_t * pCoeffs,
3989 float32_t * pState,
3990 float32_t mu,
3991 uint32_t blockSize);
3995 * @brief Instance structure for the Q15 LMS filter.
3997 typedef struct
3999 uint16_t numTaps; /**< number of coefficients in the filter. */
4000 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4001 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4002 q15_t mu; /**< step size that controls filter coefficient updates. */
4003 uint32_t postShift; /**< bit shift applied to coefficients. */
4004 } arm_lms_instance_q15;
4008 * @brief Initialization function for the Q15 LMS filter.
4009 * @param[in] S points to an instance of the Q15 LMS filter structure.
4010 * @param[in] numTaps number of filter coefficients.
4011 * @param[in] pCoeffs points to the coefficient buffer.
4012 * @param[in] pState points to the state buffer.
4013 * @param[in] mu step size that controls filter coefficient updates.
4014 * @param[in] blockSize number of samples to process.
4015 * @param[in] postShift bit shift applied to coefficients.
4017 void arm_lms_init_q15(
4018 arm_lms_instance_q15 * S,
4019 uint16_t numTaps,
4020 q15_t * pCoeffs,
4021 q15_t * pState,
4022 q15_t mu,
4023 uint32_t blockSize,
4024 uint32_t postShift);
4028 * @brief Processing function for Q15 LMS filter.
4029 * @param[in] S points to an instance of the Q15 LMS filter structure.
4030 * @param[in] pSrc points to the block of input data.
4031 * @param[in] pRef points to the block of reference data.
4032 * @param[out] pOut points to the block of output data.
4033 * @param[out] pErr points to the block of error data.
4034 * @param[in] blockSize number of samples to process.
4036 void arm_lms_q15(
4037 const arm_lms_instance_q15 * S,
4038 q15_t * pSrc,
4039 q15_t * pRef,
4040 q15_t * pOut,
4041 q15_t * pErr,
4042 uint32_t blockSize);
4046 * @brief Instance structure for the Q31 LMS filter.
4048 typedef struct
4050 uint16_t numTaps; /**< number of coefficients in the filter. */
4051 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4052 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4053 q31_t mu; /**< step size that controls filter coefficient updates. */
4054 uint32_t postShift; /**< bit shift applied to coefficients. */
4055 } arm_lms_instance_q31;
4059 * @brief Processing function for Q31 LMS filter.
4060 * @param[in] S points to an instance of the Q15 LMS filter structure.
4061 * @param[in] pSrc points to the block of input data.
4062 * @param[in] pRef points to the block of reference data.
4063 * @param[out] pOut points to the block of output data.
4064 * @param[out] pErr points to the block of error data.
4065 * @param[in] blockSize number of samples to process.
4067 void arm_lms_q31(
4068 const arm_lms_instance_q31 * S,
4069 q31_t * pSrc,
4070 q31_t * pRef,
4071 q31_t * pOut,
4072 q31_t * pErr,
4073 uint32_t blockSize);
4077 * @brief Initialization function for Q31 LMS filter.
4078 * @param[in] S points to an instance of the Q31 LMS filter structure.
4079 * @param[in] numTaps number of filter coefficients.
4080 * @param[in] pCoeffs points to coefficient buffer.
4081 * @param[in] pState points to state buffer.
4082 * @param[in] mu step size that controls filter coefficient updates.
4083 * @param[in] blockSize number of samples to process.
4084 * @param[in] postShift bit shift applied to coefficients.
4086 void arm_lms_init_q31(
4087 arm_lms_instance_q31 * S,
4088 uint16_t numTaps,
4089 q31_t * pCoeffs,
4090 q31_t * pState,
4091 q31_t mu,
4092 uint32_t blockSize,
4093 uint32_t postShift);
4097 * @brief Instance structure for the floating-point normalized LMS filter.
4099 typedef struct
4101 uint16_t numTaps; /**< number of coefficients in the filter. */
4102 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4103 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4104 float32_t mu; /**< step size that control filter coefficient updates. */
4105 float32_t energy; /**< saves previous frame energy. */
4106 float32_t x0; /**< saves previous input sample. */
4107 } arm_lms_norm_instance_f32;
4111 * @brief Processing function for floating-point normalized LMS filter.
4112 * @param[in] S points to an instance of the floating-point normalized LMS filter structure.
4113 * @param[in] pSrc points to the block of input data.
4114 * @param[in] pRef points to the block of reference data.
4115 * @param[out] pOut points to the block of output data.
4116 * @param[out] pErr points to the block of error data.
4117 * @param[in] blockSize number of samples to process.
4119 void arm_lms_norm_f32(
4120 arm_lms_norm_instance_f32 * S,
4121 float32_t * pSrc,
4122 float32_t * pRef,
4123 float32_t * pOut,
4124 float32_t * pErr,
4125 uint32_t blockSize);
4129 * @brief Initialization function for floating-point normalized LMS filter.
4130 * @param[in] S points to an instance of the floating-point LMS filter structure.
4131 * @param[in] numTaps number of filter coefficients.
4132 * @param[in] pCoeffs points to coefficient buffer.
4133 * @param[in] pState points to state buffer.
4134 * @param[in] mu step size that controls filter coefficient updates.
4135 * @param[in] blockSize number of samples to process.
4137 void arm_lms_norm_init_f32(
4138 arm_lms_norm_instance_f32 * S,
4139 uint16_t numTaps,
4140 float32_t * pCoeffs,
4141 float32_t * pState,
4142 float32_t mu,
4143 uint32_t blockSize);
4147 * @brief Instance structure for the Q31 normalized LMS filter.
4149 typedef struct
4151 uint16_t numTaps; /**< number of coefficients in the filter. */
4152 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4153 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4154 q31_t mu; /**< step size that controls filter coefficient updates. */
4155 uint8_t postShift; /**< bit shift applied to coefficients. */
4156 q31_t *recipTable; /**< points to the reciprocal initial value table. */
4157 q31_t energy; /**< saves previous frame energy. */
4158 q31_t x0; /**< saves previous input sample. */
4159 } arm_lms_norm_instance_q31;
4163 * @brief Processing function for Q31 normalized LMS filter.
4164 * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
4165 * @param[in] pSrc points to the block of input data.
4166 * @param[in] pRef points to the block of reference data.
4167 * @param[out] pOut points to the block of output data.
4168 * @param[out] pErr points to the block of error data.
4169 * @param[in] blockSize number of samples to process.
4171 void arm_lms_norm_q31(
4172 arm_lms_norm_instance_q31 * S,
4173 q31_t * pSrc,
4174 q31_t * pRef,
4175 q31_t * pOut,
4176 q31_t * pErr,
4177 uint32_t blockSize);
4181 * @brief Initialization function for Q31 normalized LMS filter.
4182 * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
4183 * @param[in] numTaps number of filter coefficients.
4184 * @param[in] pCoeffs points to coefficient buffer.
4185 * @param[in] pState points to state buffer.
4186 * @param[in] mu step size that controls filter coefficient updates.
4187 * @param[in] blockSize number of samples to process.
4188 * @param[in] postShift bit shift applied to coefficients.
4190 void arm_lms_norm_init_q31(
4191 arm_lms_norm_instance_q31 * S,
4192 uint16_t numTaps,
4193 q31_t * pCoeffs,
4194 q31_t * pState,
4195 q31_t mu,
4196 uint32_t blockSize,
4197 uint8_t postShift);
4201 * @brief Instance structure for the Q15 normalized LMS filter.
4203 typedef struct
4205 uint16_t numTaps; /**< Number of coefficients in the filter. */
4206 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4207 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4208 q15_t mu; /**< step size that controls filter coefficient updates. */
4209 uint8_t postShift; /**< bit shift applied to coefficients. */
4210 q15_t *recipTable; /**< Points to the reciprocal initial value table. */
4211 q15_t energy; /**< saves previous frame energy. */
4212 q15_t x0; /**< saves previous input sample. */
4213 } arm_lms_norm_instance_q15;
4217 * @brief Processing function for Q15 normalized LMS filter.
4218 * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
4219 * @param[in] pSrc points to the block of input data.
4220 * @param[in] pRef points to the block of reference data.
4221 * @param[out] pOut points to the block of output data.
4222 * @param[out] pErr points to the block of error data.
4223 * @param[in] blockSize number of samples to process.
4225 void arm_lms_norm_q15(
4226 arm_lms_norm_instance_q15 * S,
4227 q15_t * pSrc,
4228 q15_t * pRef,
4229 q15_t * pOut,
4230 q15_t * pErr,
4231 uint32_t blockSize);
4235 * @brief Initialization function for Q15 normalized LMS filter.
4236 * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
4237 * @param[in] numTaps number of filter coefficients.
4238 * @param[in] pCoeffs points to coefficient buffer.
4239 * @param[in] pState points to state buffer.
4240 * @param[in] mu step size that controls filter coefficient updates.
4241 * @param[in] blockSize number of samples to process.
4242 * @param[in] postShift bit shift applied to coefficients.
4244 void arm_lms_norm_init_q15(
4245 arm_lms_norm_instance_q15 * S,
4246 uint16_t numTaps,
4247 q15_t * pCoeffs,
4248 q15_t * pState,
4249 q15_t mu,
4250 uint32_t blockSize,
4251 uint8_t postShift);
4255 * @brief Correlation of floating-point sequences.
4256 * @param[in] pSrcA points to the first input sequence.
4257 * @param[in] srcALen length of the first input sequence.
4258 * @param[in] pSrcB points to the second input sequence.
4259 * @param[in] srcBLen length of the second input sequence.
4260 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4262 void arm_correlate_f32(
4263 float32_t * pSrcA,
4264 uint32_t srcALen,
4265 float32_t * pSrcB,
4266 uint32_t srcBLen,
4267 float32_t * pDst);
4271 * @brief Correlation of Q15 sequences
4272 * @param[in] pSrcA points to the first input sequence.
4273 * @param[in] srcALen length of the first input sequence.
4274 * @param[in] pSrcB points to the second input sequence.
4275 * @param[in] srcBLen length of the second input sequence.
4276 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4277 * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4279 void arm_correlate_opt_q15(
4280 q15_t * pSrcA,
4281 uint32_t srcALen,
4282 q15_t * pSrcB,
4283 uint32_t srcBLen,
4284 q15_t * pDst,
4285 q15_t * pScratch);
4289 * @brief Correlation of Q15 sequences.
4290 * @param[in] pSrcA points to the first input sequence.
4291 * @param[in] srcALen length of the first input sequence.
4292 * @param[in] pSrcB points to the second input sequence.
4293 * @param[in] srcBLen length of the second input sequence.
4294 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4297 void arm_correlate_q15(
4298 q15_t * pSrcA,
4299 uint32_t srcALen,
4300 q15_t * pSrcB,
4301 uint32_t srcBLen,
4302 q15_t * pDst);
4306 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4307 * @param[in] pSrcA points to the first input sequence.
4308 * @param[in] srcALen length of the first input sequence.
4309 * @param[in] pSrcB points to the second input sequence.
4310 * @param[in] srcBLen length of the second input sequence.
4311 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4314 void arm_correlate_fast_q15(
4315 q15_t * pSrcA,
4316 uint32_t srcALen,
4317 q15_t * pSrcB,
4318 uint32_t srcBLen,
4319 q15_t * pDst);
4323 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4324 * @param[in] pSrcA points to the first input sequence.
4325 * @param[in] srcALen length of the first input sequence.
4326 * @param[in] pSrcB points to the second input sequence.
4327 * @param[in] srcBLen length of the second input sequence.
4328 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4329 * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4331 void arm_correlate_fast_opt_q15(
4332 q15_t * pSrcA,
4333 uint32_t srcALen,
4334 q15_t * pSrcB,
4335 uint32_t srcBLen,
4336 q15_t * pDst,
4337 q15_t * pScratch);
4341 * @brief Correlation of Q31 sequences.
4342 * @param[in] pSrcA points to the first input sequence.
4343 * @param[in] srcALen length of the first input sequence.
4344 * @param[in] pSrcB points to the second input sequence.
4345 * @param[in] srcBLen length of the second input sequence.
4346 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4348 void arm_correlate_q31(
4349 q31_t * pSrcA,
4350 uint32_t srcALen,
4351 q31_t * pSrcB,
4352 uint32_t srcBLen,
4353 q31_t * pDst);
4357 * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
4358 * @param[in] pSrcA points to the first input sequence.
4359 * @param[in] srcALen length of the first input sequence.
4360 * @param[in] pSrcB points to the second input sequence.
4361 * @param[in] srcBLen length of the second input sequence.
4362 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4364 void arm_correlate_fast_q31(
4365 q31_t * pSrcA,
4366 uint32_t srcALen,
4367 q31_t * pSrcB,
4368 uint32_t srcBLen,
4369 q31_t * pDst);
4373 * @brief Correlation of Q7 sequences.
4374 * @param[in] pSrcA points to the first input sequence.
4375 * @param[in] srcALen length of the first input sequence.
4376 * @param[in] pSrcB points to the second input sequence.
4377 * @param[in] srcBLen length of the second input sequence.
4378 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4379 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4380 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
4382 void arm_correlate_opt_q7(
4383 q7_t * pSrcA,
4384 uint32_t srcALen,
4385 q7_t * pSrcB,
4386 uint32_t srcBLen,
4387 q7_t * pDst,
4388 q15_t * pScratch1,
4389 q15_t * pScratch2);
4393 * @brief Correlation of Q7 sequences.
4394 * @param[in] pSrcA points to the first input sequence.
4395 * @param[in] srcALen length of the first input sequence.
4396 * @param[in] pSrcB points to the second input sequence.
4397 * @param[in] srcBLen length of the second input sequence.
4398 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4400 void arm_correlate_q7(
4401 q7_t * pSrcA,
4402 uint32_t srcALen,
4403 q7_t * pSrcB,
4404 uint32_t srcBLen,
4405 q7_t * pDst);
4409 * @brief Instance structure for the floating-point sparse FIR filter.
4411 typedef struct
4413 uint16_t numTaps; /**< number of coefficients in the filter. */
4414 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4415 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4416 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4417 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4418 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4419 } arm_fir_sparse_instance_f32;
4422 * @brief Instance structure for the Q31 sparse FIR filter.
4424 typedef struct
4426 uint16_t numTaps; /**< number of coefficients in the filter. */
4427 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4428 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4429 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4430 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4431 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4432 } arm_fir_sparse_instance_q31;
4435 * @brief Instance structure for the Q15 sparse FIR filter.
4437 typedef struct
4439 uint16_t numTaps; /**< number of coefficients in the filter. */
4440 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4441 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4442 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4443 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4444 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4445 } arm_fir_sparse_instance_q15;
4448 * @brief Instance structure for the Q7 sparse FIR filter.
4450 typedef struct
4452 uint16_t numTaps; /**< number of coefficients in the filter. */
4453 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4454 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4455 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4456 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4457 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4458 } arm_fir_sparse_instance_q7;
4462 * @brief Processing function for the floating-point sparse FIR filter.
4463 * @param[in] S points to an instance of the floating-point sparse FIR structure.
4464 * @param[in] pSrc points to the block of input data.
4465 * @param[out] pDst points to the block of output data
4466 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4467 * @param[in] blockSize number of input samples to process per call.
4469 void arm_fir_sparse_f32(
4470 arm_fir_sparse_instance_f32 * S,
4471 float32_t * pSrc,
4472 float32_t * pDst,
4473 float32_t * pScratchIn,
4474 uint32_t blockSize);
4478 * @brief Initialization function for the floating-point sparse FIR filter.
4479 * @param[in,out] S points to an instance of the floating-point sparse FIR structure.
4480 * @param[in] numTaps number of nonzero coefficients in the filter.
4481 * @param[in] pCoeffs points to the array of filter coefficients.
4482 * @param[in] pState points to the state buffer.
4483 * @param[in] pTapDelay points to the array of offset times.
4484 * @param[in] maxDelay maximum offset time supported.
4485 * @param[in] blockSize number of samples that will be processed per block.
4487 void arm_fir_sparse_init_f32(
4488 arm_fir_sparse_instance_f32 * S,
4489 uint16_t numTaps,
4490 float32_t * pCoeffs,
4491 float32_t * pState,
4492 int32_t * pTapDelay,
4493 uint16_t maxDelay,
4494 uint32_t blockSize);
4498 * @brief Processing function for the Q31 sparse FIR filter.
4499 * @param[in] S points to an instance of the Q31 sparse FIR structure.
4500 * @param[in] pSrc points to the block of input data.
4501 * @param[out] pDst points to the block of output data
4502 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4503 * @param[in] blockSize number of input samples to process per call.
4505 void arm_fir_sparse_q31(
4506 arm_fir_sparse_instance_q31 * S,
4507 q31_t * pSrc,
4508 q31_t * pDst,
4509 q31_t * pScratchIn,
4510 uint32_t blockSize);
4514 * @brief Initialization function for the Q31 sparse FIR filter.
4515 * @param[in,out] S points to an instance of the Q31 sparse FIR structure.
4516 * @param[in] numTaps number of nonzero coefficients in the filter.
4517 * @param[in] pCoeffs points to the array of filter coefficients.
4518 * @param[in] pState points to the state buffer.
4519 * @param[in] pTapDelay points to the array of offset times.
4520 * @param[in] maxDelay maximum offset time supported.
4521 * @param[in] blockSize number of samples that will be processed per block.
4523 void arm_fir_sparse_init_q31(
4524 arm_fir_sparse_instance_q31 * S,
4525 uint16_t numTaps,
4526 q31_t * pCoeffs,
4527 q31_t * pState,
4528 int32_t * pTapDelay,
4529 uint16_t maxDelay,
4530 uint32_t blockSize);
4534 * @brief Processing function for the Q15 sparse FIR filter.
4535 * @param[in] S points to an instance of the Q15 sparse FIR structure.
4536 * @param[in] pSrc points to the block of input data.
4537 * @param[out] pDst points to the block of output data
4538 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4539 * @param[in] pScratchOut points to a temporary buffer of size blockSize.
4540 * @param[in] blockSize number of input samples to process per call.
4542 void arm_fir_sparse_q15(
4543 arm_fir_sparse_instance_q15 * S,
4544 q15_t * pSrc,
4545 q15_t * pDst,
4546 q15_t * pScratchIn,
4547 q31_t * pScratchOut,
4548 uint32_t blockSize);
4552 * @brief Initialization function for the Q15 sparse FIR filter.
4553 * @param[in,out] S points to an instance of the Q15 sparse FIR structure.
4554 * @param[in] numTaps number of nonzero coefficients in the filter.
4555 * @param[in] pCoeffs points to the array of filter coefficients.
4556 * @param[in] pState points to the state buffer.
4557 * @param[in] pTapDelay points to the array of offset times.
4558 * @param[in] maxDelay maximum offset time supported.
4559 * @param[in] blockSize number of samples that will be processed per block.
4561 void arm_fir_sparse_init_q15(
4562 arm_fir_sparse_instance_q15 * S,
4563 uint16_t numTaps,
4564 q15_t * pCoeffs,
4565 q15_t * pState,
4566 int32_t * pTapDelay,
4567 uint16_t maxDelay,
4568 uint32_t blockSize);
4572 * @brief Processing function for the Q7 sparse FIR filter.
4573 * @param[in] S points to an instance of the Q7 sparse FIR structure.
4574 * @param[in] pSrc points to the block of input data.
4575 * @param[out] pDst points to the block of output data
4576 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4577 * @param[in] pScratchOut points to a temporary buffer of size blockSize.
4578 * @param[in] blockSize number of input samples to process per call.
4580 void arm_fir_sparse_q7(
4581 arm_fir_sparse_instance_q7 * S,
4582 q7_t * pSrc,
4583 q7_t * pDst,
4584 q7_t * pScratchIn,
4585 q31_t * pScratchOut,
4586 uint32_t blockSize);
4590 * @brief Initialization function for the Q7 sparse FIR filter.
4591 * @param[in,out] S points to an instance of the Q7 sparse FIR structure.
4592 * @param[in] numTaps number of nonzero coefficients in the filter.
4593 * @param[in] pCoeffs points to the array of filter coefficients.
4594 * @param[in] pState points to the state buffer.
4595 * @param[in] pTapDelay points to the array of offset times.
4596 * @param[in] maxDelay maximum offset time supported.
4597 * @param[in] blockSize number of samples that will be processed per block.
4599 void arm_fir_sparse_init_q7(
4600 arm_fir_sparse_instance_q7 * S,
4601 uint16_t numTaps,
4602 q7_t * pCoeffs,
4603 q7_t * pState,
4604 int32_t * pTapDelay,
4605 uint16_t maxDelay,
4606 uint32_t blockSize);
4610 * @brief Floating-point sin_cos function.
4611 * @param[in] theta input value in degrees
4612 * @param[out] pSinVal points to the processed sine output.
4613 * @param[out] pCosVal points to the processed cos output.
4615 void arm_sin_cos_f32(
4616 float32_t theta,
4617 float32_t * pSinVal,
4618 float32_t * pCosVal);
4622 * @brief Q31 sin_cos function.
4623 * @param[in] theta scaled input value in degrees
4624 * @param[out] pSinVal points to the processed sine output.
4625 * @param[out] pCosVal points to the processed cosine output.
4627 void arm_sin_cos_q31(
4628 q31_t theta,
4629 q31_t * pSinVal,
4630 q31_t * pCosVal);
4634 * @brief Floating-point complex conjugate.
4635 * @param[in] pSrc points to the input vector
4636 * @param[out] pDst points to the output vector
4637 * @param[in] numSamples number of complex samples in each vector
4639 void arm_cmplx_conj_f32(
4640 float32_t * pSrc,
4641 float32_t * pDst,
4642 uint32_t numSamples);
4645 * @brief Q31 complex conjugate.
4646 * @param[in] pSrc points to the input vector
4647 * @param[out] pDst points to the output vector
4648 * @param[in] numSamples number of complex samples in each vector
4650 void arm_cmplx_conj_q31(
4651 q31_t * pSrc,
4652 q31_t * pDst,
4653 uint32_t numSamples);
4657 * @brief Q15 complex conjugate.
4658 * @param[in] pSrc points to the input vector
4659 * @param[out] pDst points to the output vector
4660 * @param[in] numSamples number of complex samples in each vector
4662 void arm_cmplx_conj_q15(
4663 q15_t * pSrc,
4664 q15_t * pDst,
4665 uint32_t numSamples);
4669 * @brief Floating-point complex magnitude squared
4670 * @param[in] pSrc points to the complex input vector
4671 * @param[out] pDst points to the real output vector
4672 * @param[in] numSamples number of complex samples in the input vector
4674 void arm_cmplx_mag_squared_f32(
4675 float32_t * pSrc,
4676 float32_t * pDst,
4677 uint32_t numSamples);
4681 * @brief Q31 complex magnitude squared
4682 * @param[in] pSrc points to the complex input vector
4683 * @param[out] pDst points to the real output vector
4684 * @param[in] numSamples number of complex samples in the input vector
4686 void arm_cmplx_mag_squared_q31(
4687 q31_t * pSrc,
4688 q31_t * pDst,
4689 uint32_t numSamples);
4693 * @brief Q15 complex magnitude squared
4694 * @param[in] pSrc points to the complex input vector
4695 * @param[out] pDst points to the real output vector
4696 * @param[in] numSamples number of complex samples in the input vector
4698 void arm_cmplx_mag_squared_q15(
4699 q15_t * pSrc,
4700 q15_t * pDst,
4701 uint32_t numSamples);
4705 * @ingroup groupController
4709 * @defgroup PID PID Motor Control
4711 * A Proportional Integral Derivative (PID) controller is a generic feedback control
4712 * loop mechanism widely used in industrial control systems.
4713 * A PID controller is the most commonly used type of feedback controller.
4715 * This set of functions implements (PID) controllers
4716 * for Q15, Q31, and floating-point data types. The functions operate on a single sample
4717 * of data and each call to the function returns a single processed value.
4718 * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
4719 * is the input sample value. The functions return the output value.
4721 * \par Algorithm:
4722 * <pre>
4723 * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
4724 * A0 = Kp + Ki + Kd
4725 * A1 = (-Kp ) - (2 * Kd )
4726 * A2 = Kd </pre>
4728 * \par
4729 * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
4731 * \par
4732 * \image html PID.gif "Proportional Integral Derivative Controller"
4734 * \par
4735 * The PID controller calculates an "error" value as the difference between
4736 * the measured output and the reference input.
4737 * The controller attempts to minimize the error by adjusting the process control inputs.
4738 * The proportional value determines the reaction to the current error,
4739 * the integral value determines the reaction based on the sum of recent errors,
4740 * and the derivative value determines the reaction based on the rate at which the error has been changing.
4742 * \par Instance Structure
4743 * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
4744 * A separate instance structure must be defined for each PID Controller.
4745 * There are separate instance structure declarations for each of the 3 supported data types.
4747 * \par Reset Functions
4748 * There is also an associated reset function for each data type which clears the state array.
4750 * \par Initialization Functions
4751 * There is also an associated initialization function for each data type.
4752 * The initialization function performs the following operations:
4753 * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
4754 * - Zeros out the values in the state buffer.
4756 * \par
4757 * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
4759 * \par Fixed-Point Behavior
4760 * Care must be taken when using the fixed-point versions of the PID Controller functions.
4761 * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
4762 * Refer to the function specific documentation below for usage guidelines.
4766 * @addtogroup PID
4767 * @{
4771 * @brief Process function for the floating-point PID Control.
4772 * @param[in,out] S is an instance of the floating-point PID Control structure
4773 * @param[in] in input sample to process
4774 * @return out processed output sample.
4776 CMSIS_INLINE __STATIC_INLINE float32_t arm_pid_f32(
4777 arm_pid_instance_f32 * S,
4778 float32_t in)
4780 float32_t out;
4782 /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
4783 out = (S->A0 * in) +
4784 (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
4786 /* Update state */
4787 S->state[1] = S->state[0];
4788 S->state[0] = in;
4789 S->state[2] = out;
4791 /* return to application */
4792 return (out);
4797 * @brief Process function for the Q31 PID Control.
4798 * @param[in,out] S points to an instance of the Q31 PID Control structure
4799 * @param[in] in input sample to process
4800 * @return out processed output sample.
4802 * <b>Scaling and Overflow Behavior:</b>
4803 * \par
4804 * The function is implemented using an internal 64-bit accumulator.
4805 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
4806 * Thus, if the accumulator result overflows it wraps around rather than clip.
4807 * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
4808 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
4810 CMSIS_INLINE __STATIC_INLINE q31_t arm_pid_q31(
4811 arm_pid_instance_q31 * S,
4812 q31_t in)
4814 q63_t acc;
4815 q31_t out;
4817 /* acc = A0 * x[n] */
4818 acc = (q63_t) S->A0 * in;
4820 /* acc += A1 * x[n-1] */
4821 acc += (q63_t) S->A1 * S->state[0];
4823 /* acc += A2 * x[n-2] */
4824 acc += (q63_t) S->A2 * S->state[1];
4826 /* convert output to 1.31 format to add y[n-1] */
4827 out = (q31_t) (acc >> 31U);
4829 /* out += y[n-1] */
4830 out += S->state[2];
4832 /* Update state */
4833 S->state[1] = S->state[0];
4834 S->state[0] = in;
4835 S->state[2] = out;
4837 /* return to application */
4838 return (out);
4843 * @brief Process function for the Q15 PID Control.
4844 * @param[in,out] S points to an instance of the Q15 PID Control structure
4845 * @param[in] in input sample to process
4846 * @return out processed output sample.
4848 * <b>Scaling and Overflow Behavior:</b>
4849 * \par
4850 * The function is implemented using a 64-bit internal accumulator.
4851 * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
4852 * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
4853 * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
4854 * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
4855 * Lastly, the accumulator is saturated to yield a result in 1.15 format.
4857 CMSIS_INLINE __STATIC_INLINE q15_t arm_pid_q15(
4858 arm_pid_instance_q15 * S,
4859 q15_t in)
4861 q63_t acc;
4862 q15_t out;
4864 #if defined (ARM_MATH_DSP)
4865 __SIMD32_TYPE *vstate;
4867 /* Implementation of PID controller */
4869 /* acc = A0 * x[n] */
4870 acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);
4872 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4873 vstate = __SIMD32_CONST(S->state);
4874 acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (uint64_t)acc);
4875 #else
4876 /* acc = A0 * x[n] */
4877 acc = ((q31_t) S->A0) * in;
4879 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4880 acc += (q31_t) S->A1 * S->state[0];
4881 acc += (q31_t) S->A2 * S->state[1];
4882 #endif
4884 /* acc += y[n-1] */
4885 acc += (q31_t) S->state[2] << 15;
4887 /* saturate the output */
4888 out = (q15_t) (__SSAT((acc >> 15), 16));
4890 /* Update state */
4891 S->state[1] = S->state[0];
4892 S->state[0] = in;
4893 S->state[2] = out;
4895 /* return to application */
4896 return (out);
4900 * @} end of PID group
4905 * @brief Floating-point matrix inverse.
4906 * @param[in] src points to the instance of the input floating-point matrix structure.
4907 * @param[out] dst points to the instance of the output floating-point matrix structure.
4908 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
4909 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
4911 arm_status arm_mat_inverse_f32(
4912 const arm_matrix_instance_f32 * src,
4913 arm_matrix_instance_f32 * dst);
4917 * @brief Floating-point matrix inverse.
4918 * @param[in] src points to the instance of the input floating-point matrix structure.
4919 * @param[out] dst points to the instance of the output floating-point matrix structure.
4920 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
4921 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
4923 arm_status arm_mat_inverse_f64(
4924 const arm_matrix_instance_f64 * src,
4925 arm_matrix_instance_f64 * dst);
4930 * @ingroup groupController
4934 * @defgroup clarke Vector Clarke Transform
4935 * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
4936 * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
4937 * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
4938 * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
4939 * \image html clarke.gif Stator current space vector and its components in (a,b).
4940 * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
4941 * can be calculated using only <code>Ia</code> and <code>Ib</code>.
4943 * The function operates on a single sample of data and each call to the function returns the processed output.
4944 * The library provides separate functions for Q31 and floating-point data types.
4945 * \par Algorithm
4946 * \image html clarkeFormula.gif
4947 * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
4948 * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
4949 * \par Fixed-Point Behavior
4950 * Care must be taken when using the Q31 version of the Clarke transform.
4951 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
4952 * Refer to the function specific documentation below for usage guidelines.
4956 * @addtogroup clarke
4957 * @{
4962 * @brief Floating-point Clarke transform
4963 * @param[in] Ia input three-phase coordinate <code>a</code>
4964 * @param[in] Ib input three-phase coordinate <code>b</code>
4965 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
4966 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
4968 CMSIS_INLINE __STATIC_INLINE void arm_clarke_f32(
4969 float32_t Ia,
4970 float32_t Ib,
4971 float32_t * pIalpha,
4972 float32_t * pIbeta)
4974 /* Calculate pIalpha using the equation, pIalpha = Ia */
4975 *pIalpha = Ia;
4977 /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
4978 *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
4983 * @brief Clarke transform for Q31 version
4984 * @param[in] Ia input three-phase coordinate <code>a</code>
4985 * @param[in] Ib input three-phase coordinate <code>b</code>
4986 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
4987 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
4989 * <b>Scaling and Overflow Behavior:</b>
4990 * \par
4991 * The function is implemented using an internal 32-bit accumulator.
4992 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
4993 * There is saturation on the addition, hence there is no risk of overflow.
4995 CMSIS_INLINE __STATIC_INLINE void arm_clarke_q31(
4996 q31_t Ia,
4997 q31_t Ib,
4998 q31_t * pIalpha,
4999 q31_t * pIbeta)
5001 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5003 /* Calculating pIalpha from Ia by equation pIalpha = Ia */
5004 *pIalpha = Ia;
5006 /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
5007 product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
5009 /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
5010 product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
5012 /* pIbeta is calculated by adding the intermediate products */
5013 *pIbeta = __QADD(product1, product2);
5017 * @} end of clarke group
5021 * @brief Converts the elements of the Q7 vector to Q31 vector.
5022 * @param[in] pSrc input pointer
5023 * @param[out] pDst output pointer
5024 * @param[in] blockSize number of samples to process
5026 void arm_q7_to_q31(
5027 q7_t * pSrc,
5028 q31_t * pDst,
5029 uint32_t blockSize);
5034 * @ingroup groupController
5038 * @defgroup inv_clarke Vector Inverse Clarke Transform
5039 * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
5041 * The function operates on a single sample of data and each call to the function returns the processed output.
5042 * The library provides separate functions for Q31 and floating-point data types.
5043 * \par Algorithm
5044 * \image html clarkeInvFormula.gif
5045 * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
5046 * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
5047 * \par Fixed-Point Behavior
5048 * Care must be taken when using the Q31 version of the Clarke transform.
5049 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5050 * Refer to the function specific documentation below for usage guidelines.
5054 * @addtogroup inv_clarke
5055 * @{
5059 * @brief Floating-point Inverse Clarke transform
5060 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5061 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5062 * @param[out] pIa points to output three-phase coordinate <code>a</code>
5063 * @param[out] pIb points to output three-phase coordinate <code>b</code>
5065 CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_f32(
5066 float32_t Ialpha,
5067 float32_t Ibeta,
5068 float32_t * pIa,
5069 float32_t * pIb)
5071 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5072 *pIa = Ialpha;
5074 /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
5075 *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;
5080 * @brief Inverse Clarke transform for Q31 version
5081 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5082 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5083 * @param[out] pIa points to output three-phase coordinate <code>a</code>
5084 * @param[out] pIb points to output three-phase coordinate <code>b</code>
5086 * <b>Scaling and Overflow Behavior:</b>
5087 * \par
5088 * The function is implemented using an internal 32-bit accumulator.
5089 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5090 * There is saturation on the subtraction, hence there is no risk of overflow.
5092 CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_q31(
5093 q31_t Ialpha,
5094 q31_t Ibeta,
5095 q31_t * pIa,
5096 q31_t * pIb)
5098 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5100 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5101 *pIa = Ialpha;
5103 /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
5104 product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
5106 /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
5107 product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
5109 /* pIb is calculated by subtracting the products */
5110 *pIb = __QSUB(product2, product1);
5114 * @} end of inv_clarke group
5118 * @brief Converts the elements of the Q7 vector to Q15 vector.
5119 * @param[in] pSrc input pointer
5120 * @param[out] pDst output pointer
5121 * @param[in] blockSize number of samples to process
5123 void arm_q7_to_q15(
5124 q7_t * pSrc,
5125 q15_t * pDst,
5126 uint32_t blockSize);
5131 * @ingroup groupController
5135 * @defgroup park Vector Park Transform
5137 * Forward Park transform converts the input two-coordinate vector to flux and torque components.
5138 * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
5139 * from the stationary to the moving reference frame and control the spatial relationship between
5140 * the stator vector current and rotor flux vector.
5141 * If we consider the d axis aligned with the rotor flux, the diagram below shows the
5142 * current vector and the relationship from the two reference frames:
5143 * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
5145 * The function operates on a single sample of data and each call to the function returns the processed output.
5146 * The library provides separate functions for Q31 and floating-point data types.
5147 * \par Algorithm
5148 * \image html parkFormula.gif
5149 * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
5150 * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5151 * cosine and sine values of theta (rotor flux position).
5152 * \par Fixed-Point Behavior
5153 * Care must be taken when using the Q31 version of the Park transform.
5154 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5155 * Refer to the function specific documentation below for usage guidelines.
5159 * @addtogroup park
5160 * @{
5164 * @brief Floating-point Park transform
5165 * @param[in] Ialpha input two-phase vector coordinate alpha
5166 * @param[in] Ibeta input two-phase vector coordinate beta
5167 * @param[out] pId points to output rotor reference frame d
5168 * @param[out] pIq points to output rotor reference frame q
5169 * @param[in] sinVal sine value of rotation angle theta
5170 * @param[in] cosVal cosine value of rotation angle theta
5172 * The function implements the forward Park transform.
5175 CMSIS_INLINE __STATIC_INLINE void arm_park_f32(
5176 float32_t Ialpha,
5177 float32_t Ibeta,
5178 float32_t * pId,
5179 float32_t * pIq,
5180 float32_t sinVal,
5181 float32_t cosVal)
5183 /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
5184 *pId = Ialpha * cosVal + Ibeta * sinVal;
5186 /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
5187 *pIq = -Ialpha * sinVal + Ibeta * cosVal;
5192 * @brief Park transform for Q31 version
5193 * @param[in] Ialpha input two-phase vector coordinate alpha
5194 * @param[in] Ibeta input two-phase vector coordinate beta
5195 * @param[out] pId points to output rotor reference frame d
5196 * @param[out] pIq points to output rotor reference frame q
5197 * @param[in] sinVal sine value of rotation angle theta
5198 * @param[in] cosVal cosine value of rotation angle theta
5200 * <b>Scaling and Overflow Behavior:</b>
5201 * \par
5202 * The function is implemented using an internal 32-bit accumulator.
5203 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5204 * There is saturation on the addition and subtraction, hence there is no risk of overflow.
5206 CMSIS_INLINE __STATIC_INLINE void arm_park_q31(
5207 q31_t Ialpha,
5208 q31_t Ibeta,
5209 q31_t * pId,
5210 q31_t * pIq,
5211 q31_t sinVal,
5212 q31_t cosVal)
5214 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5215 q31_t product3, product4; /* Temporary variables used to store intermediate results */
5217 /* Intermediate product is calculated by (Ialpha * cosVal) */
5218 product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
5220 /* Intermediate product is calculated by (Ibeta * sinVal) */
5221 product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
5224 /* Intermediate product is calculated by (Ialpha * sinVal) */
5225 product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
5227 /* Intermediate product is calculated by (Ibeta * cosVal) */
5228 product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
5230 /* Calculate pId by adding the two intermediate products 1 and 2 */
5231 *pId = __QADD(product1, product2);
5233 /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
5234 *pIq = __QSUB(product4, product3);
5238 * @} end of park group
5242 * @brief Converts the elements of the Q7 vector to floating-point vector.
5243 * @param[in] pSrc is input pointer
5244 * @param[out] pDst is output pointer
5245 * @param[in] blockSize is the number of samples to process
5247 void arm_q7_to_float(
5248 q7_t * pSrc,
5249 float32_t * pDst,
5250 uint32_t blockSize);
5254 * @ingroup groupController
5258 * @defgroup inv_park Vector Inverse Park transform
5259 * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
5261 * The function operates on a single sample of data and each call to the function returns the processed output.
5262 * The library provides separate functions for Q31 and floating-point data types.
5263 * \par Algorithm
5264 * \image html parkInvFormula.gif
5265 * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
5266 * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5267 * cosine and sine values of theta (rotor flux position).
5268 * \par Fixed-Point Behavior
5269 * Care must be taken when using the Q31 version of the Park transform.
5270 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5271 * Refer to the function specific documentation below for usage guidelines.
5275 * @addtogroup inv_park
5276 * @{
5280 * @brief Floating-point Inverse Park transform
5281 * @param[in] Id input coordinate of rotor reference frame d
5282 * @param[in] Iq input coordinate of rotor reference frame q
5283 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5284 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5285 * @param[in] sinVal sine value of rotation angle theta
5286 * @param[in] cosVal cosine value of rotation angle theta
5288 CMSIS_INLINE __STATIC_INLINE void arm_inv_park_f32(
5289 float32_t Id,
5290 float32_t Iq,
5291 float32_t * pIalpha,
5292 float32_t * pIbeta,
5293 float32_t sinVal,
5294 float32_t cosVal)
5296 /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
5297 *pIalpha = Id * cosVal - Iq * sinVal;
5299 /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
5300 *pIbeta = Id * sinVal + Iq * cosVal;
5305 * @brief Inverse Park transform for Q31 version
5306 * @param[in] Id input coordinate of rotor reference frame d
5307 * @param[in] Iq input coordinate of rotor reference frame q
5308 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5309 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5310 * @param[in] sinVal sine value of rotation angle theta
5311 * @param[in] cosVal cosine value of rotation angle theta
5313 * <b>Scaling and Overflow Behavior:</b>
5314 * \par
5315 * The function is implemented using an internal 32-bit accumulator.
5316 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5317 * There is saturation on the addition, hence there is no risk of overflow.
5319 CMSIS_INLINE __STATIC_INLINE void arm_inv_park_q31(
5320 q31_t Id,
5321 q31_t Iq,
5322 q31_t * pIalpha,
5323 q31_t * pIbeta,
5324 q31_t sinVal,
5325 q31_t cosVal)
5327 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5328 q31_t product3, product4; /* Temporary variables used to store intermediate results */
5330 /* Intermediate product is calculated by (Id * cosVal) */
5331 product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
5333 /* Intermediate product is calculated by (Iq * sinVal) */
5334 product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
5337 /* Intermediate product is calculated by (Id * sinVal) */
5338 product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
5340 /* Intermediate product is calculated by (Iq * cosVal) */
5341 product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
5343 /* Calculate pIalpha by using the two intermediate products 1 and 2 */
5344 *pIalpha = __QSUB(product1, product2);
5346 /* Calculate pIbeta by using the two intermediate products 3 and 4 */
5347 *pIbeta = __QADD(product4, product3);
5351 * @} end of Inverse park group
5356 * @brief Converts the elements of the Q31 vector to floating-point vector.
5357 * @param[in] pSrc is input pointer
5358 * @param[out] pDst is output pointer
5359 * @param[in] blockSize is the number of samples to process
5361 void arm_q31_to_float(
5362 q31_t * pSrc,
5363 float32_t * pDst,
5364 uint32_t blockSize);
5367 * @ingroup groupInterpolation
5371 * @defgroup LinearInterpolate Linear Interpolation
5373 * Linear interpolation is a method of curve fitting using linear polynomials.
5374 * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
5376 * \par
5377 * \image html LinearInterp.gif "Linear interpolation"
5379 * \par
5380 * A Linear Interpolate function calculates an output value(y), for the input(x)
5381 * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
5383 * \par Algorithm:
5384 * <pre>
5385 * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
5386 * where x0, x1 are nearest values of input x
5387 * y0, y1 are nearest values to output y
5388 * </pre>
5390 * \par
5391 * This set of functions implements Linear interpolation process
5392 * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
5393 * sample of data and each call to the function returns a single processed value.
5394 * <code>S</code> points to an instance of the Linear Interpolate function data structure.
5395 * <code>x</code> is the input sample value. The functions returns the output value.
5397 * \par
5398 * if x is outside of the table boundary, Linear interpolation returns first value of the table
5399 * if x is below input range and returns last value of table if x is above range.
5403 * @addtogroup LinearInterpolate
5404 * @{
5408 * @brief Process function for the floating-point Linear Interpolation Function.
5409 * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
5410 * @param[in] x input sample to process
5411 * @return y processed output sample.
5414 CMSIS_INLINE __STATIC_INLINE float32_t arm_linear_interp_f32(
5415 arm_linear_interp_instance_f32 * S,
5416 float32_t x)
5418 float32_t y;
5419 float32_t x0, x1; /* Nearest input values */
5420 float32_t y0, y1; /* Nearest output values */
5421 float32_t xSpacing = S->xSpacing; /* spacing between input values */
5422 int32_t i; /* Index variable */
5423 float32_t *pYData = S->pYData; /* pointer to output table */
5425 /* Calculation of index */
5426 i = (int32_t) ((x - S->x1) / xSpacing);
5428 if (i < 0)
5430 /* Iniatilize output for below specified range as least output value of table */
5431 y = pYData[0];
5433 else if ((uint32_t)i >= S->nValues)
5435 /* Iniatilize output for above specified range as last output value of table */
5436 y = pYData[S->nValues - 1];
5438 else
5440 /* Calculation of nearest input values */
5441 x0 = S->x1 + i * xSpacing;
5442 x1 = S->x1 + (i + 1) * xSpacing;
5444 /* Read of nearest output values */
5445 y0 = pYData[i];
5446 y1 = pYData[i + 1];
5448 /* Calculation of output */
5449 y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
5453 /* returns output value */
5454 return (y);
5460 * @brief Process function for the Q31 Linear Interpolation Function.
5461 * @param[in] pYData pointer to Q31 Linear Interpolation table
5462 * @param[in] x input sample to process
5463 * @param[in] nValues number of table values
5464 * @return y processed output sample.
5466 * \par
5467 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5468 * This function can support maximum of table size 2^12.
5471 CMSIS_INLINE __STATIC_INLINE q31_t arm_linear_interp_q31(
5472 q31_t * pYData,
5473 q31_t x,
5474 uint32_t nValues)
5476 q31_t y; /* output */
5477 q31_t y0, y1; /* Nearest output values */
5478 q31_t fract; /* fractional part */
5479 int32_t index; /* Index to read nearest output values */
5481 /* Input is in 12.20 format */
5482 /* 12 bits for the table index */
5483 /* Index value calculation */
5484 index = ((x & (q31_t)0xFFF00000) >> 20);
5486 if (index >= (int32_t)(nValues - 1))
5488 return (pYData[nValues - 1]);
5490 else if (index < 0)
5492 return (pYData[0]);
5494 else
5496 /* 20 bits for the fractional part */
5497 /* shift left by 11 to keep fract in 1.31 format */
5498 fract = (x & 0x000FFFFF) << 11;
5500 /* Read two nearest output values from the index in 1.31(q31) format */
5501 y0 = pYData[index];
5502 y1 = pYData[index + 1];
5504 /* Calculation of y0 * (1-fract) and y is in 2.30 format */
5505 y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
5507 /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
5508 y += ((q31_t) (((q63_t) y1 * fract) >> 32));
5510 /* Convert y to 1.31 format */
5511 return (y << 1U);
5518 * @brief Process function for the Q15 Linear Interpolation Function.
5519 * @param[in] pYData pointer to Q15 Linear Interpolation table
5520 * @param[in] x input sample to process
5521 * @param[in] nValues number of table values
5522 * @return y processed output sample.
5524 * \par
5525 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5526 * This function can support maximum of table size 2^12.
5529 CMSIS_INLINE __STATIC_INLINE q15_t arm_linear_interp_q15(
5530 q15_t * pYData,
5531 q31_t x,
5532 uint32_t nValues)
5534 q63_t y; /* output */
5535 q15_t y0, y1; /* Nearest output values */
5536 q31_t fract; /* fractional part */
5537 int32_t index; /* Index to read nearest output values */
5539 /* Input is in 12.20 format */
5540 /* 12 bits for the table index */
5541 /* Index value calculation */
5542 index = ((x & (int32_t)0xFFF00000) >> 20);
5544 if (index >= (int32_t)(nValues - 1))
5546 return (pYData[nValues - 1]);
5548 else if (index < 0)
5550 return (pYData[0]);
5552 else
5554 /* 20 bits for the fractional part */
5555 /* fract is in 12.20 format */
5556 fract = (x & 0x000FFFFF);
5558 /* Read two nearest output values from the index */
5559 y0 = pYData[index];
5560 y1 = pYData[index + 1];
5562 /* Calculation of y0 * (1-fract) and y is in 13.35 format */
5563 y = ((q63_t) y0 * (0xFFFFF - fract));
5565 /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
5566 y += ((q63_t) y1 * (fract));
5568 /* convert y to 1.15 format */
5569 return (q15_t) (y >> 20);
5576 * @brief Process function for the Q7 Linear Interpolation Function.
5577 * @param[in] pYData pointer to Q7 Linear Interpolation table
5578 * @param[in] x input sample to process
5579 * @param[in] nValues number of table values
5580 * @return y processed output sample.
5582 * \par
5583 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5584 * This function can support maximum of table size 2^12.
5586 CMSIS_INLINE __STATIC_INLINE q7_t arm_linear_interp_q7(
5587 q7_t * pYData,
5588 q31_t x,
5589 uint32_t nValues)
5591 q31_t y; /* output */
5592 q7_t y0, y1; /* Nearest output values */
5593 q31_t fract; /* fractional part */
5594 uint32_t index; /* Index to read nearest output values */
5596 /* Input is in 12.20 format */
5597 /* 12 bits for the table index */
5598 /* Index value calculation */
5599 if (x < 0)
5601 return (pYData[0]);
5603 index = (x >> 20) & 0xfff;
5605 if (index >= (nValues - 1))
5607 return (pYData[nValues - 1]);
5609 else
5611 /* 20 bits for the fractional part */
5612 /* fract is in 12.20 format */
5613 fract = (x & 0x000FFFFF);
5615 /* Read two nearest output values from the index and are in 1.7(q7) format */
5616 y0 = pYData[index];
5617 y1 = pYData[index + 1];
5619 /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
5620 y = ((y0 * (0xFFFFF - fract)));
5622 /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
5623 y += (y1 * fract);
5625 /* convert y to 1.7(q7) format */
5626 return (q7_t) (y >> 20);
5631 * @} end of LinearInterpolate group
5635 * @brief Fast approximation to the trigonometric sine function for floating-point data.
5636 * @param[in] x input value in radians.
5637 * @return sin(x).
5639 float32_t arm_sin_f32(
5640 float32_t x);
5644 * @brief Fast approximation to the trigonometric sine function for Q31 data.
5645 * @param[in] x Scaled input value in radians.
5646 * @return sin(x).
5648 q31_t arm_sin_q31(
5649 q31_t x);
5653 * @brief Fast approximation to the trigonometric sine function for Q15 data.
5654 * @param[in] x Scaled input value in radians.
5655 * @return sin(x).
5657 q15_t arm_sin_q15(
5658 q15_t x);
5662 * @brief Fast approximation to the trigonometric cosine function for floating-point data.
5663 * @param[in] x input value in radians.
5664 * @return cos(x).
5666 float32_t arm_cos_f32(
5667 float32_t x);
5671 * @brief Fast approximation to the trigonometric cosine function for Q31 data.
5672 * @param[in] x Scaled input value in radians.
5673 * @return cos(x).
5675 q31_t arm_cos_q31(
5676 q31_t x);
5680 * @brief Fast approximation to the trigonometric cosine function for Q15 data.
5681 * @param[in] x Scaled input value in radians.
5682 * @return cos(x).
5684 q15_t arm_cos_q15(
5685 q15_t x);
5689 * @ingroup groupFastMath
5694 * @defgroup SQRT Square Root
5696 * Computes the square root of a number.
5697 * There are separate functions for Q15, Q31, and floating-point data types.
5698 * The square root function is computed using the Newton-Raphson algorithm.
5699 * This is an iterative algorithm of the form:
5700 * <pre>
5701 * x1 = x0 - f(x0)/f'(x0)
5702 * </pre>
5703 * where <code>x1</code> is the current estimate,
5704 * <code>x0</code> is the previous estimate, and
5705 * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
5706 * For the square root function, the algorithm reduces to:
5707 * <pre>
5708 * x0 = in/2 [initial guess]
5709 * x1 = 1/2 * ( x0 + in / x0) [each iteration]
5710 * </pre>
5715 * @addtogroup SQRT
5716 * @{
5720 * @brief Floating-point square root function.
5721 * @param[in] in input value.
5722 * @param[out] pOut square root of input value.
5723 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5724 * <code>in</code> is negative value and returns zero output for negative values.
5726 CMSIS_INLINE __STATIC_INLINE arm_status arm_sqrt_f32(
5727 float32_t in,
5728 float32_t * pOut)
5730 if (in >= 0.0f)
5733 #if (__FPU_USED == 1) && defined ( __CC_ARM )
5734 *pOut = __sqrtf(in);
5735 #elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
5736 *pOut = __builtin_sqrtf(in);
5737 #elif (__FPU_USED == 1) && defined(__GNUC__)
5738 *pOut = __builtin_sqrtf(in);
5739 #elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000)
5740 __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));
5741 #else
5742 *pOut = sqrtf(in);
5743 #endif
5745 return (ARM_MATH_SUCCESS);
5747 else
5749 *pOut = 0.0f;
5750 return (ARM_MATH_ARGUMENT_ERROR);
5756 * @brief Q31 square root function.
5757 * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
5758 * @param[out] pOut square root of input value.
5759 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5760 * <code>in</code> is negative value and returns zero output for negative values.
5762 arm_status arm_sqrt_q31(
5763 q31_t in,
5764 q31_t * pOut);
5768 * @brief Q15 square root function.
5769 * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
5770 * @param[out] pOut square root of input value.
5771 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5772 * <code>in</code> is negative value and returns zero output for negative values.
5774 arm_status arm_sqrt_q15(
5775 q15_t in,
5776 q15_t * pOut);
5779 * @} end of SQRT group
5784 * @brief floating-point Circular write function.
5786 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_f32(
5787 int32_t * circBuffer,
5788 int32_t L,
5789 uint16_t * writeOffset,
5790 int32_t bufferInc,
5791 const int32_t * src,
5792 int32_t srcInc,
5793 uint32_t blockSize)
5795 uint32_t i = 0U;
5796 int32_t wOffset;
5798 /* Copy the value of Index pointer that points
5799 * to the current location where the input samples to be copied */
5800 wOffset = *writeOffset;
5802 /* Loop over the blockSize */
5803 i = blockSize;
5805 while (i > 0U)
5807 /* copy the input sample to the circular buffer */
5808 circBuffer[wOffset] = *src;
5810 /* Update the input pointer */
5811 src += srcInc;
5813 /* Circularly update wOffset. Watch out for positive and negative value */
5814 wOffset += bufferInc;
5815 if (wOffset >= L)
5816 wOffset -= L;
5818 /* Decrement the loop counter */
5819 i--;
5822 /* Update the index pointer */
5823 *writeOffset = (uint16_t)wOffset;
5829 * @brief floating-point Circular Read function.
5831 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_f32(
5832 int32_t * circBuffer,
5833 int32_t L,
5834 int32_t * readOffset,
5835 int32_t bufferInc,
5836 int32_t * dst,
5837 int32_t * dst_base,
5838 int32_t dst_length,
5839 int32_t dstInc,
5840 uint32_t blockSize)
5842 uint32_t i = 0U;
5843 int32_t rOffset, dst_end;
5845 /* Copy the value of Index pointer that points
5846 * to the current location from where the input samples to be read */
5847 rOffset = *readOffset;
5848 dst_end = (int32_t) (dst_base + dst_length);
5850 /* Loop over the blockSize */
5851 i = blockSize;
5853 while (i > 0U)
5855 /* copy the sample from the circular buffer to the destination buffer */
5856 *dst = circBuffer[rOffset];
5858 /* Update the input pointer */
5859 dst += dstInc;
5861 if (dst == (int32_t *) dst_end)
5863 dst = dst_base;
5866 /* Circularly update rOffset. Watch out for positive and negative value */
5867 rOffset += bufferInc;
5869 if (rOffset >= L)
5871 rOffset -= L;
5874 /* Decrement the loop counter */
5875 i--;
5878 /* Update the index pointer */
5879 *readOffset = rOffset;
5884 * @brief Q15 Circular write function.
5886 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q15(
5887 q15_t * circBuffer,
5888 int32_t L,
5889 uint16_t * writeOffset,
5890 int32_t bufferInc,
5891 const q15_t * src,
5892 int32_t srcInc,
5893 uint32_t blockSize)
5895 uint32_t i = 0U;
5896 int32_t wOffset;
5898 /* Copy the value of Index pointer that points
5899 * to the current location where the input samples to be copied */
5900 wOffset = *writeOffset;
5902 /* Loop over the blockSize */
5903 i = blockSize;
5905 while (i > 0U)
5907 /* copy the input sample to the circular buffer */
5908 circBuffer[wOffset] = *src;
5910 /* Update the input pointer */
5911 src += srcInc;
5913 /* Circularly update wOffset. Watch out for positive and negative value */
5914 wOffset += bufferInc;
5915 if (wOffset >= L)
5916 wOffset -= L;
5918 /* Decrement the loop counter */
5919 i--;
5922 /* Update the index pointer */
5923 *writeOffset = (uint16_t)wOffset;
5928 * @brief Q15 Circular Read function.
5930 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q15(
5931 q15_t * circBuffer,
5932 int32_t L,
5933 int32_t * readOffset,
5934 int32_t bufferInc,
5935 q15_t * dst,
5936 q15_t * dst_base,
5937 int32_t dst_length,
5938 int32_t dstInc,
5939 uint32_t blockSize)
5941 uint32_t i = 0;
5942 int32_t rOffset, dst_end;
5944 /* Copy the value of Index pointer that points
5945 * to the current location from where the input samples to be read */
5946 rOffset = *readOffset;
5948 dst_end = (int32_t) (dst_base + dst_length);
5950 /* Loop over the blockSize */
5951 i = blockSize;
5953 while (i > 0U)
5955 /* copy the sample from the circular buffer to the destination buffer */
5956 *dst = circBuffer[rOffset];
5958 /* Update the input pointer */
5959 dst += dstInc;
5961 if (dst == (q15_t *) dst_end)
5963 dst = dst_base;
5966 /* Circularly update wOffset. Watch out for positive and negative value */
5967 rOffset += bufferInc;
5969 if (rOffset >= L)
5971 rOffset -= L;
5974 /* Decrement the loop counter */
5975 i--;
5978 /* Update the index pointer */
5979 *readOffset = rOffset;
5984 * @brief Q7 Circular write function.
5986 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q7(
5987 q7_t * circBuffer,
5988 int32_t L,
5989 uint16_t * writeOffset,
5990 int32_t bufferInc,
5991 const q7_t * src,
5992 int32_t srcInc,
5993 uint32_t blockSize)
5995 uint32_t i = 0U;
5996 int32_t wOffset;
5998 /* Copy the value of Index pointer that points
5999 * to the current location where the input samples to be copied */
6000 wOffset = *writeOffset;
6002 /* Loop over the blockSize */
6003 i = blockSize;
6005 while (i > 0U)
6007 /* copy the input sample to the circular buffer */
6008 circBuffer[wOffset] = *src;
6010 /* Update the input pointer */
6011 src += srcInc;
6013 /* Circularly update wOffset. Watch out for positive and negative value */
6014 wOffset += bufferInc;
6015 if (wOffset >= L)
6016 wOffset -= L;
6018 /* Decrement the loop counter */
6019 i--;
6022 /* Update the index pointer */
6023 *writeOffset = (uint16_t)wOffset;
6028 * @brief Q7 Circular Read function.
6030 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q7(
6031 q7_t * circBuffer,
6032 int32_t L,
6033 int32_t * readOffset,
6034 int32_t bufferInc,
6035 q7_t * dst,
6036 q7_t * dst_base,
6037 int32_t dst_length,
6038 int32_t dstInc,
6039 uint32_t blockSize)
6041 uint32_t i = 0;
6042 int32_t rOffset, dst_end;
6044 /* Copy the value of Index pointer that points
6045 * to the current location from where the input samples to be read */
6046 rOffset = *readOffset;
6048 dst_end = (int32_t) (dst_base + dst_length);
6050 /* Loop over the blockSize */
6051 i = blockSize;
6053 while (i > 0U)
6055 /* copy the sample from the circular buffer to the destination buffer */
6056 *dst = circBuffer[rOffset];
6058 /* Update the input pointer */
6059 dst += dstInc;
6061 if (dst == (q7_t *) dst_end)
6063 dst = dst_base;
6066 /* Circularly update rOffset. Watch out for positive and negative value */
6067 rOffset += bufferInc;
6069 if (rOffset >= L)
6071 rOffset -= L;
6074 /* Decrement the loop counter */
6075 i--;
6078 /* Update the index pointer */
6079 *readOffset = rOffset;
6084 * @brief Sum of the squares of the elements of a Q31 vector.
6085 * @param[in] pSrc is input pointer
6086 * @param[in] blockSize is the number of samples to process
6087 * @param[out] pResult is output value.
6089 void arm_power_q31(
6090 q31_t * pSrc,
6091 uint32_t blockSize,
6092 q63_t * pResult);
6096 * @brief Sum of the squares of the elements of a floating-point vector.
6097 * @param[in] pSrc is input pointer
6098 * @param[in] blockSize is the number of samples to process
6099 * @param[out] pResult is output value.
6101 void arm_power_f32(
6102 float32_t * pSrc,
6103 uint32_t blockSize,
6104 float32_t * pResult);
6108 * @brief Sum of the squares of the elements of a Q15 vector.
6109 * @param[in] pSrc is input pointer
6110 * @param[in] blockSize is the number of samples to process
6111 * @param[out] pResult is output value.
6113 void arm_power_q15(
6114 q15_t * pSrc,
6115 uint32_t blockSize,
6116 q63_t * pResult);
6120 * @brief Sum of the squares of the elements of a Q7 vector.
6121 * @param[in] pSrc is input pointer
6122 * @param[in] blockSize is the number of samples to process
6123 * @param[out] pResult is output value.
6125 void arm_power_q7(
6126 q7_t * pSrc,
6127 uint32_t blockSize,
6128 q31_t * pResult);
6132 * @brief Mean value of a Q7 vector.
6133 * @param[in] pSrc is input pointer
6134 * @param[in] blockSize is the number of samples to process
6135 * @param[out] pResult is output value.
6137 void arm_mean_q7(
6138 q7_t * pSrc,
6139 uint32_t blockSize,
6140 q7_t * pResult);
6144 * @brief Mean value of a Q15 vector.
6145 * @param[in] pSrc is input pointer
6146 * @param[in] blockSize is the number of samples to process
6147 * @param[out] pResult is output value.
6149 void arm_mean_q15(
6150 q15_t * pSrc,
6151 uint32_t blockSize,
6152 q15_t * pResult);
6156 * @brief Mean value of a Q31 vector.
6157 * @param[in] pSrc is input pointer
6158 * @param[in] blockSize is the number of samples to process
6159 * @param[out] pResult is output value.
6161 void arm_mean_q31(
6162 q31_t * pSrc,
6163 uint32_t blockSize,
6164 q31_t * pResult);
6168 * @brief Mean value of a floating-point vector.
6169 * @param[in] pSrc is input pointer
6170 * @param[in] blockSize is the number of samples to process
6171 * @param[out] pResult is output value.
6173 void arm_mean_f32(
6174 float32_t * pSrc,
6175 uint32_t blockSize,
6176 float32_t * pResult);
6180 * @brief Variance of the elements of a floating-point vector.
6181 * @param[in] pSrc is input pointer
6182 * @param[in] blockSize is the number of samples to process
6183 * @param[out] pResult is output value.
6185 void arm_var_f32(
6186 float32_t * pSrc,
6187 uint32_t blockSize,
6188 float32_t * pResult);
6192 * @brief Variance of the elements of a Q31 vector.
6193 * @param[in] pSrc is input pointer
6194 * @param[in] blockSize is the number of samples to process
6195 * @param[out] pResult is output value.
6197 void arm_var_q31(
6198 q31_t * pSrc,
6199 uint32_t blockSize,
6200 q31_t * pResult);
6204 * @brief Variance of the elements of a Q15 vector.
6205 * @param[in] pSrc is input pointer
6206 * @param[in] blockSize is the number of samples to process
6207 * @param[out] pResult is output value.
6209 void arm_var_q15(
6210 q15_t * pSrc,
6211 uint32_t blockSize,
6212 q15_t * pResult);
6216 * @brief Root Mean Square of the elements of a floating-point vector.
6217 * @param[in] pSrc is input pointer
6218 * @param[in] blockSize is the number of samples to process
6219 * @param[out] pResult is output value.
6221 void arm_rms_f32(
6222 float32_t * pSrc,
6223 uint32_t blockSize,
6224 float32_t * pResult);
6228 * @brief Root Mean Square of the elements of a Q31 vector.
6229 * @param[in] pSrc is input pointer
6230 * @param[in] blockSize is the number of samples to process
6231 * @param[out] pResult is output value.
6233 void arm_rms_q31(
6234 q31_t * pSrc,
6235 uint32_t blockSize,
6236 q31_t * pResult);
6240 * @brief Root Mean Square of the elements of a Q15 vector.
6241 * @param[in] pSrc is input pointer
6242 * @param[in] blockSize is the number of samples to process
6243 * @param[out] pResult is output value.
6245 void arm_rms_q15(
6246 q15_t * pSrc,
6247 uint32_t blockSize,
6248 q15_t * pResult);
6252 * @brief Standard deviation of the elements of a floating-point vector.
6253 * @param[in] pSrc is input pointer
6254 * @param[in] blockSize is the number of samples to process
6255 * @param[out] pResult is output value.
6257 void arm_std_f32(
6258 float32_t * pSrc,
6259 uint32_t blockSize,
6260 float32_t * pResult);
6264 * @brief Standard deviation of the elements of a Q31 vector.
6265 * @param[in] pSrc is input pointer
6266 * @param[in] blockSize is the number of samples to process
6267 * @param[out] pResult is output value.
6269 void arm_std_q31(
6270 q31_t * pSrc,
6271 uint32_t blockSize,
6272 q31_t * pResult);
6276 * @brief Standard deviation of the elements of a Q15 vector.
6277 * @param[in] pSrc is input pointer
6278 * @param[in] blockSize is the number of samples to process
6279 * @param[out] pResult is output value.
6281 void arm_std_q15(
6282 q15_t * pSrc,
6283 uint32_t blockSize,
6284 q15_t * pResult);
6288 * @brief Floating-point complex magnitude
6289 * @param[in] pSrc points to the complex input vector
6290 * @param[out] pDst points to the real output vector
6291 * @param[in] numSamples number of complex samples in the input vector
6293 void arm_cmplx_mag_f32(
6294 float32_t * pSrc,
6295 float32_t * pDst,
6296 uint32_t numSamples);
6300 * @brief Q31 complex magnitude
6301 * @param[in] pSrc points to the complex input vector
6302 * @param[out] pDst points to the real output vector
6303 * @param[in] numSamples number of complex samples in the input vector
6305 void arm_cmplx_mag_q31(
6306 q31_t * pSrc,
6307 q31_t * pDst,
6308 uint32_t numSamples);
6312 * @brief Q15 complex magnitude
6313 * @param[in] pSrc points to the complex input vector
6314 * @param[out] pDst points to the real output vector
6315 * @param[in] numSamples number of complex samples in the input vector
6317 void arm_cmplx_mag_q15(
6318 q15_t * pSrc,
6319 q15_t * pDst,
6320 uint32_t numSamples);
6324 * @brief Q15 complex dot product
6325 * @param[in] pSrcA points to the first input vector
6326 * @param[in] pSrcB points to the second input vector
6327 * @param[in] numSamples number of complex samples in each vector
6328 * @param[out] realResult real part of the result returned here
6329 * @param[out] imagResult imaginary part of the result returned here
6331 void arm_cmplx_dot_prod_q15(
6332 q15_t * pSrcA,
6333 q15_t * pSrcB,
6334 uint32_t numSamples,
6335 q31_t * realResult,
6336 q31_t * imagResult);
6340 * @brief Q31 complex dot product
6341 * @param[in] pSrcA points to the first input vector
6342 * @param[in] pSrcB points to the second input vector
6343 * @param[in] numSamples number of complex samples in each vector
6344 * @param[out] realResult real part of the result returned here
6345 * @param[out] imagResult imaginary part of the result returned here
6347 void arm_cmplx_dot_prod_q31(
6348 q31_t * pSrcA,
6349 q31_t * pSrcB,
6350 uint32_t numSamples,
6351 q63_t * realResult,
6352 q63_t * imagResult);
6356 * @brief Floating-point complex dot product
6357 * @param[in] pSrcA points to the first input vector
6358 * @param[in] pSrcB points to the second input vector
6359 * @param[in] numSamples number of complex samples in each vector
6360 * @param[out] realResult real part of the result returned here
6361 * @param[out] imagResult imaginary part of the result returned here
6363 void arm_cmplx_dot_prod_f32(
6364 float32_t * pSrcA,
6365 float32_t * pSrcB,
6366 uint32_t numSamples,
6367 float32_t * realResult,
6368 float32_t * imagResult);
6372 * @brief Q15 complex-by-real multiplication
6373 * @param[in] pSrcCmplx points to the complex input vector
6374 * @param[in] pSrcReal points to the real input vector
6375 * @param[out] pCmplxDst points to the complex output vector
6376 * @param[in] numSamples number of samples in each vector
6378 void arm_cmplx_mult_real_q15(
6379 q15_t * pSrcCmplx,
6380 q15_t * pSrcReal,
6381 q15_t * pCmplxDst,
6382 uint32_t numSamples);
6386 * @brief Q31 complex-by-real multiplication
6387 * @param[in] pSrcCmplx points to the complex input vector
6388 * @param[in] pSrcReal points to the real input vector
6389 * @param[out] pCmplxDst points to the complex output vector
6390 * @param[in] numSamples number of samples in each vector
6392 void arm_cmplx_mult_real_q31(
6393 q31_t * pSrcCmplx,
6394 q31_t * pSrcReal,
6395 q31_t * pCmplxDst,
6396 uint32_t numSamples);
6400 * @brief Floating-point complex-by-real multiplication
6401 * @param[in] pSrcCmplx points to the complex input vector
6402 * @param[in] pSrcReal points to the real input vector
6403 * @param[out] pCmplxDst points to the complex output vector
6404 * @param[in] numSamples number of samples in each vector
6406 void arm_cmplx_mult_real_f32(
6407 float32_t * pSrcCmplx,
6408 float32_t * pSrcReal,
6409 float32_t * pCmplxDst,
6410 uint32_t numSamples);
6414 * @brief Minimum value of a Q7 vector.
6415 * @param[in] pSrc is input pointer
6416 * @param[in] blockSize is the number of samples to process
6417 * @param[out] result is output pointer
6418 * @param[in] index is the array index of the minimum value in the input buffer.
6420 void arm_min_q7(
6421 q7_t * pSrc,
6422 uint32_t blockSize,
6423 q7_t * result,
6424 uint32_t * index);
6428 * @brief Minimum value of a Q15 vector.
6429 * @param[in] pSrc is input pointer
6430 * @param[in] blockSize is the number of samples to process
6431 * @param[out] pResult is output pointer
6432 * @param[in] pIndex is the array index of the minimum value in the input buffer.
6434 void arm_min_q15(
6435 q15_t * pSrc,
6436 uint32_t blockSize,
6437 q15_t * pResult,
6438 uint32_t * pIndex);
6442 * @brief Minimum value of a Q31 vector.
6443 * @param[in] pSrc is input pointer
6444 * @param[in] blockSize is the number of samples to process
6445 * @param[out] pResult is output pointer
6446 * @param[out] pIndex is the array index of the minimum value in the input buffer.
6448 void arm_min_q31(
6449 q31_t * pSrc,
6450 uint32_t blockSize,
6451 q31_t * pResult,
6452 uint32_t * pIndex);
6456 * @brief Minimum value of a floating-point vector.
6457 * @param[in] pSrc is input pointer
6458 * @param[in] blockSize is the number of samples to process
6459 * @param[out] pResult is output pointer
6460 * @param[out] pIndex is the array index of the minimum value in the input buffer.
6462 void arm_min_f32(
6463 float32_t * pSrc,
6464 uint32_t blockSize,
6465 float32_t * pResult,
6466 uint32_t * pIndex);
6470 * @brief Maximum value of a Q7 vector.
6471 * @param[in] pSrc points to the input buffer
6472 * @param[in] blockSize length of the input vector
6473 * @param[out] pResult maximum value returned here
6474 * @param[out] pIndex index of maximum value returned here
6476 void arm_max_q7(
6477 q7_t * pSrc,
6478 uint32_t blockSize,
6479 q7_t * pResult,
6480 uint32_t * pIndex);
6484 * @brief Maximum value of a Q15 vector.
6485 * @param[in] pSrc points to the input buffer
6486 * @param[in] blockSize length of the input vector
6487 * @param[out] pResult maximum value returned here
6488 * @param[out] pIndex index of maximum value returned here
6490 void arm_max_q15(
6491 q15_t * pSrc,
6492 uint32_t blockSize,
6493 q15_t * pResult,
6494 uint32_t * pIndex);
6498 * @brief Maximum value of a Q31 vector.
6499 * @param[in] pSrc points to the input buffer
6500 * @param[in] blockSize length of the input vector
6501 * @param[out] pResult maximum value returned here
6502 * @param[out] pIndex index of maximum value returned here
6504 void arm_max_q31(
6505 q31_t * pSrc,
6506 uint32_t blockSize,
6507 q31_t * pResult,
6508 uint32_t * pIndex);
6512 * @brief Maximum value of a floating-point vector.
6513 * @param[in] pSrc points to the input buffer
6514 * @param[in] blockSize length of the input vector
6515 * @param[out] pResult maximum value returned here
6516 * @param[out] pIndex index of maximum value returned here
6518 void arm_max_f32(
6519 float32_t * pSrc,
6520 uint32_t blockSize,
6521 float32_t * pResult,
6522 uint32_t * pIndex);
6526 * @brief Q15 complex-by-complex multiplication
6527 * @param[in] pSrcA points to the first input vector
6528 * @param[in] pSrcB points to the second input vector
6529 * @param[out] pDst points to the output vector
6530 * @param[in] numSamples number of complex samples in each vector
6532 void arm_cmplx_mult_cmplx_q15(
6533 q15_t * pSrcA,
6534 q15_t * pSrcB,
6535 q15_t * pDst,
6536 uint32_t numSamples);
6540 * @brief Q31 complex-by-complex multiplication
6541 * @param[in] pSrcA points to the first input vector
6542 * @param[in] pSrcB points to the second input vector
6543 * @param[out] pDst points to the output vector
6544 * @param[in] numSamples number of complex samples in each vector
6546 void arm_cmplx_mult_cmplx_q31(
6547 q31_t * pSrcA,
6548 q31_t * pSrcB,
6549 q31_t * pDst,
6550 uint32_t numSamples);
6554 * @brief Floating-point complex-by-complex multiplication
6555 * @param[in] pSrcA points to the first input vector
6556 * @param[in] pSrcB points to the second input vector
6557 * @param[out] pDst points to the output vector
6558 * @param[in] numSamples number of complex samples in each vector
6560 void arm_cmplx_mult_cmplx_f32(
6561 float32_t * pSrcA,
6562 float32_t * pSrcB,
6563 float32_t * pDst,
6564 uint32_t numSamples);
6568 * @brief Converts the elements of the floating-point vector to Q31 vector.
6569 * @param[in] pSrc points to the floating-point input vector
6570 * @param[out] pDst points to the Q31 output vector
6571 * @param[in] blockSize length of the input vector
6573 void arm_float_to_q31(
6574 float32_t * pSrc,
6575 q31_t * pDst,
6576 uint32_t blockSize);
6580 * @brief Converts the elements of the floating-point vector to Q15 vector.
6581 * @param[in] pSrc points to the floating-point input vector
6582 * @param[out] pDst points to the Q15 output vector
6583 * @param[in] blockSize length of the input vector
6585 void arm_float_to_q15(
6586 float32_t * pSrc,
6587 q15_t * pDst,
6588 uint32_t blockSize);
6592 * @brief Converts the elements of the floating-point vector to Q7 vector.
6593 * @param[in] pSrc points to the floating-point input vector
6594 * @param[out] pDst points to the Q7 output vector
6595 * @param[in] blockSize length of the input vector
6597 void arm_float_to_q7(
6598 float32_t * pSrc,
6599 q7_t * pDst,
6600 uint32_t blockSize);
6604 * @brief Converts the elements of the Q31 vector to Q15 vector.
6605 * @param[in] pSrc is input pointer
6606 * @param[out] pDst is output pointer
6607 * @param[in] blockSize is the number of samples to process
6609 void arm_q31_to_q15(
6610 q31_t * pSrc,
6611 q15_t * pDst,
6612 uint32_t blockSize);
6616 * @brief Converts the elements of the Q31 vector to Q7 vector.
6617 * @param[in] pSrc is input pointer
6618 * @param[out] pDst is output pointer
6619 * @param[in] blockSize is the number of samples to process
6621 void arm_q31_to_q7(
6622 q31_t * pSrc,
6623 q7_t * pDst,
6624 uint32_t blockSize);
6628 * @brief Converts the elements of the Q15 vector to floating-point vector.
6629 * @param[in] pSrc is input pointer
6630 * @param[out] pDst is output pointer
6631 * @param[in] blockSize is the number of samples to process
6633 void arm_q15_to_float(
6634 q15_t * pSrc,
6635 float32_t * pDst,
6636 uint32_t blockSize);
6640 * @brief Converts the elements of the Q15 vector to Q31 vector.
6641 * @param[in] pSrc is input pointer
6642 * @param[out] pDst is output pointer
6643 * @param[in] blockSize is the number of samples to process
6645 void arm_q15_to_q31(
6646 q15_t * pSrc,
6647 q31_t * pDst,
6648 uint32_t blockSize);
6652 * @brief Converts the elements of the Q15 vector to Q7 vector.
6653 * @param[in] pSrc is input pointer
6654 * @param[out] pDst is output pointer
6655 * @param[in] blockSize is the number of samples to process
6657 void arm_q15_to_q7(
6658 q15_t * pSrc,
6659 q7_t * pDst,
6660 uint32_t blockSize);
6664 * @ingroup groupInterpolation
6668 * @defgroup BilinearInterpolate Bilinear Interpolation
6670 * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
6671 * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
6672 * determines values between the grid points.
6673 * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
6674 * Bilinear interpolation is often used in image processing to rescale images.
6675 * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
6677 * <b>Algorithm</b>
6678 * \par
6679 * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
6680 * For floating-point, the instance structure is defined as:
6681 * <pre>
6682 * typedef struct
6684 * uint16_t numRows;
6685 * uint16_t numCols;
6686 * float32_t *pData;
6687 * } arm_bilinear_interp_instance_f32;
6688 * </pre>
6690 * \par
6691 * where <code>numRows</code> specifies the number of rows in the table;
6692 * <code>numCols</code> specifies the number of columns in the table;
6693 * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
6694 * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
6695 * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
6697 * \par
6698 * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
6699 * <pre>
6700 * XF = floor(x)
6701 * YF = floor(y)
6702 * </pre>
6703 * \par
6704 * The interpolated output point is computed as:
6705 * <pre>
6706 * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
6707 * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
6708 * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
6709 * + f(XF+1, YF+1) * (x-XF)*(y-YF)
6710 * </pre>
6711 * Note that the coordinates (x, y) contain integer and fractional components.
6712 * The integer components specify which portion of the table to use while the
6713 * fractional components control the interpolation processor.
6715 * \par
6716 * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
6720 * @addtogroup BilinearInterpolate
6721 * @{
6727 * @brief Floating-point bilinear interpolation.
6728 * @param[in,out] S points to an instance of the interpolation structure.
6729 * @param[in] X interpolation coordinate.
6730 * @param[in] Y interpolation coordinate.
6731 * @return out interpolated value.
6733 CMSIS_INLINE __STATIC_INLINE float32_t arm_bilinear_interp_f32(
6734 const arm_bilinear_interp_instance_f32 * S,
6735 float32_t X,
6736 float32_t Y)
6738 float32_t out;
6739 float32_t f00, f01, f10, f11;
6740 float32_t *pData = S->pData;
6741 int32_t xIndex, yIndex, index;
6742 float32_t xdiff, ydiff;
6743 float32_t b1, b2, b3, b4;
6745 xIndex = (int32_t) X;
6746 yIndex = (int32_t) Y;
6748 /* Care taken for table outside boundary */
6749 /* Returns zero output when values are outside table boundary */
6750 if (xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1))
6752 return (0);
6755 /* Calculation of index for two nearest points in X-direction */
6756 index = (xIndex - 1) + (yIndex - 1) * S->numCols;
6759 /* Read two nearest points in X-direction */
6760 f00 = pData[index];
6761 f01 = pData[index + 1];
6763 /* Calculation of index for two nearest points in Y-direction */
6764 index = (xIndex - 1) + (yIndex) * S->numCols;
6767 /* Read two nearest points in Y-direction */
6768 f10 = pData[index];
6769 f11 = pData[index + 1];
6771 /* Calculation of intermediate values */
6772 b1 = f00;
6773 b2 = f01 - f00;
6774 b3 = f10 - f00;
6775 b4 = f00 - f01 - f10 + f11;
6777 /* Calculation of fractional part in X */
6778 xdiff = X - xIndex;
6780 /* Calculation of fractional part in Y */
6781 ydiff = Y - yIndex;
6783 /* Calculation of bi-linear interpolated output */
6784 out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
6786 /* return to application */
6787 return (out);
6793 * @brief Q31 bilinear interpolation.
6794 * @param[in,out] S points to an instance of the interpolation structure.
6795 * @param[in] X interpolation coordinate in 12.20 format.
6796 * @param[in] Y interpolation coordinate in 12.20 format.
6797 * @return out interpolated value.
6799 CMSIS_INLINE __STATIC_INLINE q31_t arm_bilinear_interp_q31(
6800 arm_bilinear_interp_instance_q31 * S,
6801 q31_t X,
6802 q31_t Y)
6804 q31_t out; /* Temporary output */
6805 q31_t acc = 0; /* output */
6806 q31_t xfract, yfract; /* X, Y fractional parts */
6807 q31_t x1, x2, y1, y2; /* Nearest output values */
6808 int32_t rI, cI; /* Row and column indices */
6809 q31_t *pYData = S->pData; /* pointer to output table values */
6810 uint32_t nCols = S->numCols; /* num of rows */
6812 /* Input is in 12.20 format */
6813 /* 12 bits for the table index */
6814 /* Index value calculation */
6815 rI = ((X & (q31_t)0xFFF00000) >> 20);
6817 /* Input is in 12.20 format */
6818 /* 12 bits for the table index */
6819 /* Index value calculation */
6820 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6822 /* Care taken for table outside boundary */
6823 /* Returns zero output when values are outside table boundary */
6824 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6826 return (0);
6829 /* 20 bits for the fractional part */
6830 /* shift left xfract by 11 to keep 1.31 format */
6831 xfract = (X & 0x000FFFFF) << 11U;
6833 /* Read two nearest output values from the index */
6834 x1 = pYData[(rI) + (int32_t)nCols * (cI) ];
6835 x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];
6837 /* 20 bits for the fractional part */
6838 /* shift left yfract by 11 to keep 1.31 format */
6839 yfract = (Y & 0x000FFFFF) << 11U;
6841 /* Read two nearest output values from the index */
6842 y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ];
6843 y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];
6845 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
6846 out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
6847 acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
6849 /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
6850 out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
6851 acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
6853 /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
6854 out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
6855 acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
6857 /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
6858 out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
6859 acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
6861 /* Convert acc to 1.31(q31) format */
6862 return ((q31_t)(acc << 2));
6867 * @brief Q15 bilinear interpolation.
6868 * @param[in,out] S points to an instance of the interpolation structure.
6869 * @param[in] X interpolation coordinate in 12.20 format.
6870 * @param[in] Y interpolation coordinate in 12.20 format.
6871 * @return out interpolated value.
6873 CMSIS_INLINE __STATIC_INLINE q15_t arm_bilinear_interp_q15(
6874 arm_bilinear_interp_instance_q15 * S,
6875 q31_t X,
6876 q31_t Y)
6878 q63_t acc = 0; /* output */
6879 q31_t out; /* Temporary output */
6880 q15_t x1, x2, y1, y2; /* Nearest output values */
6881 q31_t xfract, yfract; /* X, Y fractional parts */
6882 int32_t rI, cI; /* Row and column indices */
6883 q15_t *pYData = S->pData; /* pointer to output table values */
6884 uint32_t nCols = S->numCols; /* num of rows */
6886 /* Input is in 12.20 format */
6887 /* 12 bits for the table index */
6888 /* Index value calculation */
6889 rI = ((X & (q31_t)0xFFF00000) >> 20);
6891 /* Input is in 12.20 format */
6892 /* 12 bits for the table index */
6893 /* Index value calculation */
6894 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6896 /* Care taken for table outside boundary */
6897 /* Returns zero output when values are outside table boundary */
6898 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6900 return (0);
6903 /* 20 bits for the fractional part */
6904 /* xfract should be in 12.20 format */
6905 xfract = (X & 0x000FFFFF);
6907 /* Read two nearest output values from the index */
6908 x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
6909 x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
6911 /* 20 bits for the fractional part */
6912 /* yfract should be in 12.20 format */
6913 yfract = (Y & 0x000FFFFF);
6915 /* Read two nearest output values from the index */
6916 y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
6917 y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
6919 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
6921 /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
6922 /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
6923 out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4U);
6924 acc = ((q63_t) out * (0xFFFFF - yfract));
6926 /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
6927 out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4U);
6928 acc += ((q63_t) out * (xfract));
6930 /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
6931 out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4U);
6932 acc += ((q63_t) out * (yfract));
6934 /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
6935 out = (q31_t) (((q63_t) y2 * (xfract)) >> 4U);
6936 acc += ((q63_t) out * (yfract));
6938 /* acc is in 13.51 format and down shift acc by 36 times */
6939 /* Convert out to 1.15 format */
6940 return ((q15_t)(acc >> 36));
6945 * @brief Q7 bilinear interpolation.
6946 * @param[in,out] S points to an instance of the interpolation structure.
6947 * @param[in] X interpolation coordinate in 12.20 format.
6948 * @param[in] Y interpolation coordinate in 12.20 format.
6949 * @return out interpolated value.
6951 CMSIS_INLINE __STATIC_INLINE q7_t arm_bilinear_interp_q7(
6952 arm_bilinear_interp_instance_q7 * S,
6953 q31_t X,
6954 q31_t Y)
6956 q63_t acc = 0; /* output */
6957 q31_t out; /* Temporary output */
6958 q31_t xfract, yfract; /* X, Y fractional parts */
6959 q7_t x1, x2, y1, y2; /* Nearest output values */
6960 int32_t rI, cI; /* Row and column indices */
6961 q7_t *pYData = S->pData; /* pointer to output table values */
6962 uint32_t nCols = S->numCols; /* num of rows */
6964 /* Input is in 12.20 format */
6965 /* 12 bits for the table index */
6966 /* Index value calculation */
6967 rI = ((X & (q31_t)0xFFF00000) >> 20);
6969 /* Input is in 12.20 format */
6970 /* 12 bits for the table index */
6971 /* Index value calculation */
6972 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6974 /* Care taken for table outside boundary */
6975 /* Returns zero output when values are outside table boundary */
6976 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6978 return (0);
6981 /* 20 bits for the fractional part */
6982 /* xfract should be in 12.20 format */
6983 xfract = (X & (q31_t)0x000FFFFF);
6985 /* Read two nearest output values from the index */
6986 x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
6987 x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
6989 /* 20 bits for the fractional part */
6990 /* yfract should be in 12.20 format */
6991 yfract = (Y & (q31_t)0x000FFFFF);
6993 /* Read two nearest output values from the index */
6994 y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
6995 y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
6997 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
6998 out = ((x1 * (0xFFFFF - xfract)));
6999 acc = (((q63_t) out * (0xFFFFF - yfract)));
7001 /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
7002 out = ((x2 * (0xFFFFF - yfract)));
7003 acc += (((q63_t) out * (xfract)));
7005 /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
7006 out = ((y1 * (0xFFFFF - xfract)));
7007 acc += (((q63_t) out * (yfract)));
7009 /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
7010 out = ((y2 * (yfract)));
7011 acc += (((q63_t) out * (xfract)));
7013 /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
7014 return ((q7_t)(acc >> 40));
7018 * @} end of BilinearInterpolate group
7022 /* SMMLAR */
7023 #define multAcc_32x32_keep32_R(a, x, y) \
7024 a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
7026 /* SMMLSR */
7027 #define multSub_32x32_keep32_R(a, x, y) \
7028 a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
7030 /* SMMULR */
7031 #define mult_32x32_keep32_R(a, x, y) \
7032 a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
7034 /* SMMLA */
7035 #define multAcc_32x32_keep32(a, x, y) \
7036 a += (q31_t) (((q63_t) x * y) >> 32)
7038 /* SMMLS */
7039 #define multSub_32x32_keep32(a, x, y) \
7040 a -= (q31_t) (((q63_t) x * y) >> 32)
7042 /* SMMUL */
7043 #define mult_32x32_keep32(a, x, y) \
7044 a = (q31_t) (((q63_t) x * y ) >> 32)
7047 #if defined ( __CC_ARM )
7048 /* Enter low optimization region - place directly above function definition */
7049 #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
7050 #define LOW_OPTIMIZATION_ENTER \
7051 _Pragma ("push") \
7052 _Pragma ("O1")
7053 #else
7054 #define LOW_OPTIMIZATION_ENTER
7055 #endif
7057 /* Exit low optimization region - place directly after end of function definition */
7058 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7059 #define LOW_OPTIMIZATION_EXIT \
7060 _Pragma ("pop")
7061 #else
7062 #define LOW_OPTIMIZATION_EXIT
7063 #endif
7065 /* Enter low optimization region - place directly above function definition */
7066 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7068 /* Exit low optimization region - place directly after end of function definition */
7069 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7071 #elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
7072 #define LOW_OPTIMIZATION_ENTER
7073 #define LOW_OPTIMIZATION_EXIT
7074 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7075 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7077 #elif defined ( __GNUC__ )
7078 #define LOW_OPTIMIZATION_ENTER \
7079 __attribute__(( optimize("-O1") ))
7080 #define LOW_OPTIMIZATION_EXIT
7081 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7082 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7084 #elif defined ( __ICCARM__ )
7085 /* Enter low optimization region - place directly above function definition */
7086 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7087 #define LOW_OPTIMIZATION_ENTER \
7088 _Pragma ("optimize=low")
7089 #else
7090 #define LOW_OPTIMIZATION_ENTER
7091 #endif
7093 /* Exit low optimization region - place directly after end of function definition */
7094 #define LOW_OPTIMIZATION_EXIT
7096 /* Enter low optimization region - place directly above function definition */
7097 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7098 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
7099 _Pragma ("optimize=low")
7100 #else
7101 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7102 #endif
7104 /* Exit low optimization region - place directly after end of function definition */
7105 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7107 #elif defined ( __TI_ARM__ )
7108 #define LOW_OPTIMIZATION_ENTER
7109 #define LOW_OPTIMIZATION_EXIT
7110 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7111 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7113 #elif defined ( __CSMC__ )
7114 #define LOW_OPTIMIZATION_ENTER
7115 #define LOW_OPTIMIZATION_EXIT
7116 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7117 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7119 #elif defined ( __TASKING__ )
7120 #define LOW_OPTIMIZATION_ENTER
7121 #define LOW_OPTIMIZATION_EXIT
7122 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7123 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7125 #endif
7128 #ifdef __cplusplus
7130 #endif
7132 /* Compiler specific diagnostic adjustment */
7133 #if defined ( __CC_ARM )
7135 #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
7137 #elif defined ( __GNUC__ )
7138 #pragma GCC diagnostic pop
7140 #elif defined ( __ICCARM__ )
7142 #elif defined ( __TI_ARM__ )
7144 #elif defined ( __CSMC__ )
7146 #elif defined ( __TASKING__ )
7148 #else
7149 #error Unknown compiler
7150 #endif
7152 #endif /* _ARM_MATH_H */
7156 * End of file.