1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
4 * $Date: 17. January 2013
7 * Project: CMSIS DSP Library
10 * Description: Public header file for CMSIS DSP Library
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * - Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * - Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the
23 * - Neither the name of ARM LIMITED nor the names of its contributors
24 * may be used to endorse or promote products derived from this
25 * software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 * -------------------------------------------------------------------- */
42 \mainpage CMSIS DSP Software Library
46 * This user manual describes the CMSIS DSP software library,
47 * a suite of common signal processing functions for use on Cortex-M processor based devices.
49 * The library is divided into a number of functions each covering a specific category:
50 * - Basic math functions
51 * - Fast math functions
52 * - Complex math functions
56 * - Motor control functions
57 * - Statistical functions
59 * - Interpolation functions
61 * The library has separate functions for operating on 8-bit integers, 16-bit integers,
62 * 32-bit integer and 32-bit floating-point values.
64 * <b>Using the Library</b>
66 * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
67 * - arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4)
68 * - arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4)
69 * - arm_cortexM4l_math.lib (Little endian on Cortex-M4)
70 * - arm_cortexM4b_math.lib (Big endian on Cortex-M4)
71 * - arm_cortexM3l_math.lib (Little endian on Cortex-M3)
72 * - arm_cortexM3b_math.lib (Big endian on Cortex-M3)
73 * - arm_cortexM0l_math.lib (Little endian on Cortex-M0)
74 * - arm_cortexM0b_math.lib (Big endian on Cortex-M3)
76 * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
77 * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
78 * public header file <code> arm_math.h</code> for Cortex-M4/M3/M0 with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
79 * Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or
80 * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
84 * The library ships with a number of examples which demonstrate how to use the library functions.
86 * <b>Toolchain Support</b>
88 * The library has been developed and tested with MDK-ARM version 4.60.
89 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
91 * <b>Building the Library</b>
93 * The library installer contains project files to re build libraries on MDK Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
94 * - arm_cortexM0b_math.uvproj
95 * - arm_cortexM0l_math.uvproj
96 * - arm_cortexM3b_math.uvproj
97 * - arm_cortexM3l_math.uvproj
98 * - arm_cortexM4b_math.uvproj
99 * - arm_cortexM4l_math.uvproj
100 * - arm_cortexM4bf_math.uvproj
101 * - arm_cortexM4lf_math.uvproj
104 * The project can be built by opening the appropriate project in MDK-ARM 4.60 chain and defining the optional pre processor MACROs detailed above.
106 * <b>Pre-processor Macros</b>
108 * Each library project have differant pre-processor macros.
110 * - UNALIGNED_SUPPORT_DISABLE:
112 * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
114 * - ARM_MATH_BIG_ENDIAN:
116 * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
118 * - ARM_MATH_MATRIX_CHECK:
120 * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
122 * - ARM_MATH_ROUNDING:
124 * Define macro ARM_MATH_ROUNDING for rounding on support functions
128 * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
129 * and ARM_MATH_CM0 for building library on cortex-M0 target, ARM_MATH_CM0PLUS for building library on cortex-M0+ target.
133 * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries
135 * <b>Copyright Notice</b>
137 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
142 * @defgroup groupMath Basic Math Functions
146 * @defgroup groupFastMath Fast Math Functions
147 * This set of functions provides a fast approximation to sine, cosine, and square root.
148 * As compared to most of the other functions in the CMSIS math library, the fast math functions
149 * operate on individual values and not arrays.
150 * There are separate functions for Q15, Q31, and floating-point data.
155 * @defgroup groupCmplxMath Complex Math Functions
156 * This set of functions operates on complex data vectors.
157 * The data in the complex arrays is stored in an interleaved fashion
158 * (real, imag, real, imag, ...).
159 * In the API functions, the number of samples in a complex array refers
160 * to the number of complex values; the array contains twice this number of
165 * @defgroup groupFilters Filtering Functions
169 * @defgroup groupMatrix Matrix Functions
171 * This set of functions provides basic matrix math operations.
172 * The functions operate on matrix data structures. For example,
174 * definition for the floating-point matrix structure is shown
179 * uint16_t numRows; // number of rows of the matrix.
180 * uint16_t numCols; // number of columns of the matrix.
181 * float32_t *pData; // points to the data of the matrix.
182 * } arm_matrix_instance_f32;
184 * There are similar definitions for Q15 and Q31 data types.
186 * The structure specifies the size of the matrix and then points to
187 * an array of data. The array is of size <code>numRows X numCols</code>
188 * and the values are arranged in row order. That is, the
189 * matrix element (i, j) is stored at:
191 * pData[i*numCols + j]
194 * \par Init Functions
195 * There is an associated initialization function for each type of matrix
197 * The initialization function sets the values of the internal structure fields.
198 * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
199 * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
202 * Use of the initialization function is optional. However, if initialization function is used
203 * then the instance structure cannot be placed into a const data section.
204 * To place the instance structure in a const data
205 * section, manually initialize the data structure. For example:
207 * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
208 * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
209 * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
211 * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
212 * specifies the number of columns, and <code>pData</code> points to the
216 * By default all of the matrix functions perform size checking on the input and
217 * output matrices. For example, the matrix addition function verifies that the
218 * two input matrices and the output matrix all have the same number of rows and
219 * columns. If the size check fails the functions return:
221 * ARM_MATH_SIZE_MISMATCH
223 * Otherwise the functions return
227 * There is some overhead associated with this matrix size checking.
228 * The matrix size checking is enabled via the \#define
230 * ARM_MATH_MATRIX_CHECK
232 * within the library project settings. By default this macro is defined
233 * and size checking is enabled. By changing the project settings and
234 * undefining this macro size checking is eliminated and the functions
235 * run a bit faster. With size checking disabled the functions always
236 * return <code>ARM_MATH_SUCCESS</code>.
240 * @defgroup groupTransforms Transform Functions
244 * @defgroup groupController Controller Functions
248 * @defgroup groupStats Statistics Functions
251 * @defgroup groupSupport Support Functions
255 * @defgroup groupInterpolation Interpolation Functions
256 * These functions perform 1- and 2-dimensional interpolation of data.
257 * Linear interpolation is used for 1-dimensional data and
258 * bilinear interpolation is used for 2-dimensional data.
262 * @defgroup groupExamples Examples
267 #define __CMSIS_GENERIC /* disable NVIC and Systick functions */
269 #if defined (ARM_MATH_CM4)
270 #include "core_cm4.h"
271 #elif defined (ARM_MATH_CM3)
272 #include "core_cm3.h"
273 #elif defined (ARM_MATH_CM0)
274 #include "core_cm0.h"
275 #define ARM_MATH_CM0_FAMILY
276 #elif defined (ARM_MATH_CM0PLUS)
277 #include "core_cm0plus.h"
278 #define ARM_MATH_CM0_FAMILY
281 #warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on ARM_MATH_CM4....."
284 #undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
294 * @brief Macros required for reciprocal calculation in Normalized LMS
297 #define DELTA_Q31 (0x100)
298 #define DELTA_Q15 0x5
299 #define INDEX_MASK 0x0000003F
301 #define PI 3.14159265358979f
305 * @brief Macros required for SINE and COSINE Fast math approximations
308 #define TABLE_SIZE 256
309 #define TABLE_SPACING_Q31 0x800000
310 #define TABLE_SPACING_Q15 0x80
313 * @brief Macros required for SINE and COSINE Controller functions
315 /* 1.31(q31) Fixed value of 2/360 */
316 /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
317 #define INPUT_SPACING 0xB60B61
320 * @brief Macro for Unaligned Support
322 #ifndef UNALIGNED_SUPPORT_DISABLE
325 #if defined (__GNUC__)
326 #define ALIGN4 __attribute__((aligned(4)))
328 #define ALIGN4 __align(4)
330 #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
333 * @brief Error status returned by some functions in the library.
338 ARM_MATH_SUCCESS
= 0, /**< No error */
339 ARM_MATH_ARGUMENT_ERROR
= -1, /**< One or more arguments are incorrect */
340 ARM_MATH_LENGTH_ERROR
= -2, /**< Length of data buffer is incorrect */
341 ARM_MATH_SIZE_MISMATCH
= -3, /**< Size of matrices is not compatible with the operation. */
342 ARM_MATH_NANINF
= -4, /**< Not-a-number (NaN) or infinity is generated */
343 ARM_MATH_SINGULAR
= -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
344 ARM_MATH_TEST_FAILURE
= -6 /**< Test Failed */
348 * @brief 8-bit fractional data type in 1.7 format.
353 * @brief 16-bit fractional data type in 1.15 format.
355 typedef int16_t q15_t
;
358 * @brief 32-bit fractional data type in 1.31 format.
360 typedef int32_t q31_t
;
363 * @brief 64-bit fractional data type in 1.63 format.
365 typedef int64_t q63_t
;
368 * @brief 32-bit floating-point type definition.
370 typedef float float32_t
;
373 * @brief 64-bit floating-point type definition.
375 typedef double float64_t
;
378 * @brief definition to read/write two 16 bit values.
381 #define __SIMD32_TYPE int32_t __packed
382 #define CMSIS_UNUSED __attribute__((unused))
383 #elif defined __ICCARM__
385 #define __SIMD32_TYPE int32_t __packed
386 #elif defined __GNUC__
387 #define __SIMD32_TYPE int32_t
388 #define CMSIS_UNUSED __attribute__((unused))
390 #error Unknown compiler
393 #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
394 #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
396 #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
398 #define __SIMD64(addr) (*(int64_t **) & (addr))
400 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
402 * @brief definition to pack two 16 bit values.
404 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
405 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
406 #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
407 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
413 * @brief definition to pack four 8 bit values.
415 #ifndef ARM_MATH_BIG_ENDIAN
417 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
418 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
419 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
420 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
423 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
424 (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
425 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
426 (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
432 * @brief Clips Q63 to Q31 values.
434 static __INLINE q31_t
clip_q63_to_q31(
437 return ((q31_t
) (x
>> 32) != ((q31_t
) x
>> 31)) ?
438 ((0x7FFFFFFF ^ ((q31_t
) (x
>> 63)))) : (q31_t
) x
;
442 * @brief Clips Q63 to Q15 values.
444 static __INLINE q15_t
clip_q63_to_q15(
447 return ((q31_t
) (x
>> 32) != ((q31_t
) x
>> 31)) ?
448 ((0x7FFF ^ ((q15_t
) (x
>> 63)))) : (q15_t
) (x
>> 15);
452 * @brief Clips Q31 to Q7 values.
454 static __INLINE q7_t
clip_q31_to_q7(
457 return ((q31_t
) (x
>> 24) != ((q31_t
) x
>> 23)) ?
458 ((0x7F ^ ((q7_t
) (x
>> 31)))) : (q7_t
) x
;
462 * @brief Clips Q31 to Q15 values.
464 static __INLINE q15_t
clip_q31_to_q15(
467 return ((q31_t
) (x
>> 16) != ((q31_t
) x
>> 15)) ?
468 ((0x7FFF ^ ((q15_t
) (x
>> 31)))) : (q15_t
) x
;
472 * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
475 static __INLINE q63_t
mult32x64(
479 return ((((q63_t
) (x
& 0x00000000FFFFFFFF) * y
) >> 32) +
480 (((q63_t
) (x
>> 32) * y
)));
484 #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
486 #elif defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) || defined (__TASKING__) )
488 static __INLINE
uint32_t __CLZ(
492 static __INLINE
uint32_t __CLZ(
496 uint32_t mask
= 0x80000000;
498 while((data
& mask
) == 0)
511 * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
514 static __INLINE
uint32_t arm_recip_q31(
520 uint32_t out
, tempVal
;
526 signBits
= __CLZ(in
) - 1;
530 signBits
= __CLZ(-in
) - 1;
533 /* Convert input sample to 1.31 format */
536 /* calculation of index for initial approximated Val */
537 index
= (uint32_t) (in
>> 24u);
538 index
= (index
& INDEX_MASK
);
540 /* 1.31 with exp 1 */
541 out
= pRecipTable
[index
];
543 /* calculation of reciprocal value */
544 /* running approximation for two iterations */
545 for (i
= 0u; i
< 2u; i
++)
547 tempVal
= (q31_t
) (((q63_t
) in
* out
) >> 31u);
548 tempVal
= 0x7FFFFFFF - tempVal
;
549 /* 1.31 with exp 1 */
550 //out = (q31_t) (((q63_t) out * tempVal) >> 30u);
551 out
= (q31_t
) clip_q63_to_q31(((q63_t
) out
* tempVal
) >> 30u);
557 /* return num of signbits of out = 1/in value */
558 return (signBits
+ 1u);
563 * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
565 static __INLINE
uint32_t arm_recip_q15(
571 uint32_t out
= 0, tempVal
= 0;
572 uint32_t index
= 0, i
= 0;
573 uint32_t signBits
= 0;
577 signBits
= __CLZ(in
) - 17;
581 signBits
= __CLZ(-in
) - 17;
584 /* Convert input sample to 1.15 format */
587 /* calculation of index for initial approximated Val */
589 index
= (index
& INDEX_MASK
);
591 /* 1.15 with exp 1 */
592 out
= pRecipTable
[index
];
594 /* calculation of reciprocal value */
595 /* running approximation for two iterations */
596 for (i
= 0; i
< 2; i
++)
598 tempVal
= (q15_t
) (((q31_t
) in
* out
) >> 15);
599 tempVal
= 0x7FFF - tempVal
;
600 /* 1.15 with exp 1 */
601 out
= (q15_t
) (((q31_t
) out
* tempVal
) >> 14);
607 /* return num of signbits of out = 1/in value */
608 return (signBits
+ 1);
614 * @brief C custom defined intrinisic function for only M0 processors
616 #if defined(ARM_MATH_CM0_FAMILY)
618 static __INLINE q31_t
__SSAT(
622 int32_t posMax
, negMin
;
626 for (i
= 0; i
< (y
- 1); i
++)
633 posMax
= (posMax
- 1);
654 #endif /* end of ARM_MATH_CM0_FAMILY */
659 * @brief C custom defined intrinsic function for M3 and M0 processors
661 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
664 * @brief C custom defined QADD8 for M3 and M0 processors
666 static __INLINE q31_t
__QADD8(
677 r
= __SSAT((q31_t
) (r
+ s
), 8);
678 s
= __SSAT(((q31_t
) (((x
<< 16) >> 24) + ((y
<< 16) >> 24))), 8);
679 t
= __SSAT(((q31_t
) (((x
<< 8) >> 24) + ((y
<< 8) >> 24))), 8);
680 u
= __SSAT(((q31_t
) ((x
>> 24) + (y
>> 24))), 8);
683 (((q31_t
) u
<< 24) & 0xFF000000) | (((q31_t
) t
<< 16) & 0x00FF0000) |
684 (((q31_t
) s
<< 8) & 0x0000FF00) | (r
& 0x000000FF);
691 * @brief C custom defined QSUB8 for M3 and M0 processors
693 static __INLINE q31_t
__QSUB8(
704 r
= __SSAT((r
- s
), 8);
705 s
= __SSAT(((q31_t
) (((x
<< 16) >> 24) - ((y
<< 16) >> 24))), 8) << 8;
706 t
= __SSAT(((q31_t
) (((x
<< 8) >> 24) - ((y
<< 8) >> 24))), 8) << 16;
707 u
= __SSAT(((q31_t
) ((x
>> 24) - (y
>> 24))), 8) << 24;
710 (u
& 0xFF000000) | (t
& 0x00FF0000) | (s
& 0x0000FF00) | (r
&
717 * @brief C custom defined QADD16 for M3 and M0 processors
721 * @brief C custom defined QADD16 for M3 and M0 processors
723 static __INLINE q31_t
__QADD16(
734 r
= __SSAT(r
+ s
, 16);
735 s
= __SSAT(((q31_t
) ((x
>> 16) + (y
>> 16))), 16) << 16;
737 sum
= (s
& 0xFFFF0000) | (r
& 0x0000FFFF);
744 * @brief C custom defined SHADD16 for M3 and M0 processors
746 static __INLINE q31_t
__SHADD16(
757 r
= ((r
>> 1) + (s
>> 1));
758 s
= ((q31_t
) ((x
>> 17) + (y
>> 17))) << 16;
760 sum
= (s
& 0xFFFF0000) | (r
& 0x0000FFFF);
767 * @brief C custom defined QSUB16 for M3 and M0 processors
769 static __INLINE q31_t
__QSUB16(
780 r
= __SSAT(r
- s
, 16);
781 s
= __SSAT(((q31_t
) ((x
>> 16) - (y
>> 16))), 16) << 16;
783 sum
= (s
& 0xFFFF0000) | (r
& 0x0000FFFF);
789 * @brief C custom defined SHSUB16 for M3 and M0 processors
791 static __INLINE q31_t
__SHSUB16(
802 r
= ((r
>> 1) - (s
>> 1));
803 s
= (((x
>> 17) - (y
>> 17)) << 16);
805 diff
= (s
& 0xFFFF0000) | (r
& 0x0000FFFF);
811 * @brief C custom defined QASX for M3 and M0 processors
813 static __INLINE q31_t
__QASX(
822 clip_q31_to_q15((q31_t
) ((short) (x
>> 16) + (short) y
))) << 16) +
823 clip_q31_to_q15((q31_t
) ((short) x
- (short) (y
>> 16)));
829 * @brief C custom defined SHASX for M3 and M0 processors
831 static __INLINE q31_t
__SHASX(
842 r
= ((r
>> 1) - (y
>> 17));
843 s
= (((x
>> 17) + (s
>> 1)) << 16);
845 sum
= (s
& 0xFFFF0000) | (r
& 0x0000FFFF);
852 * @brief C custom defined QSAX for M3 and M0 processors
854 static __INLINE q31_t
__QSAX(
863 clip_q31_to_q15((q31_t
) ((short) (x
>> 16) - (short) y
))) << 16) +
864 clip_q31_to_q15((q31_t
) ((short) x
+ (short) (y
>> 16)));
870 * @brief C custom defined SHSAX for M3 and M0 processors
872 static __INLINE q31_t
__SHSAX(
883 r
= ((r
>> 1) + (y
>> 17));
884 s
= (((x
>> 17) - (s
>> 1)) << 16);
886 sum
= (s
& 0xFFFF0000) | (r
& 0x0000FFFF);
892 * @brief C custom defined SMUSDX for M3 and M0 processors
894 static __INLINE q31_t
__SMUSDX(
899 return ((q31_t
) (((short) x
* (short) (y
>> 16)) -
900 ((short) (x
>> 16) * (short) y
)));
904 * @brief C custom defined SMUADX for M3 and M0 processors
906 static __INLINE q31_t
__SMUADX(
911 return ((q31_t
) (((short) x
* (short) (y
>> 16)) +
912 ((short) (x
>> 16) * (short) y
)));
916 * @brief C custom defined QADD for M3 and M0 processors
918 static __INLINE q31_t
__QADD(
922 return clip_q63_to_q31((q63_t
) x
+ y
);
926 * @brief C custom defined QSUB for M3 and M0 processors
928 static __INLINE q31_t
__QSUB(
932 return clip_q63_to_q31((q63_t
) x
- y
);
936 * @brief C custom defined SMLAD for M3 and M0 processors
938 static __INLINE q31_t
__SMLAD(
944 return (sum
+ ((short) (x
>> 16) * (short) (y
>> 16)) +
945 ((short) x
* (short) y
));
949 * @brief C custom defined SMLADX for M3 and M0 processors
951 static __INLINE q31_t
__SMLADX(
957 return (sum
+ ((short) (x
>> 16) * (short) (y
)) +
958 ((short) x
* (short) (y
>> 16)));
962 * @brief C custom defined SMLSDX for M3 and M0 processors
964 static __INLINE q31_t
__SMLSDX(
970 return (sum
- ((short) (x
>> 16) * (short) (y
)) +
971 ((short) x
* (short) (y
>> 16)));
975 * @brief C custom defined SMLALD for M3 and M0 processors
977 static __INLINE q63_t
__SMLALD(
983 return (sum
+ ((short) (x
>> 16) * (short) (y
>> 16)) +
984 ((short) x
* (short) y
));
988 * @brief C custom defined SMLALDX for M3 and M0 processors
990 static __INLINE q63_t
__SMLALDX(
996 return (sum
+ ((short) (x
>> 16) * (short) y
)) +
997 ((short) x
* (short) (y
>> 16));
1001 * @brief C custom defined SMUAD for M3 and M0 processors
1003 static __INLINE q31_t
__SMUAD(
1008 return (((x
>> 16) * (y
>> 16)) +
1009 (((x
<< 16) >> 16) * ((y
<< 16) >> 16)));
1013 * @brief C custom defined SMUSD for M3 and M0 processors
1015 static __INLINE q31_t
__SMUSD(
1020 return (-((x
>> 16) * (y
>> 16)) +
1021 (((x
<< 16) >> 16) * ((y
<< 16) >> 16)));
1026 * @brief C custom defined SXTB16 for M3 and M0 processors
1028 static __INLINE q31_t
__SXTB16(
1032 return ((((x
<< 24) >> 24) & 0x0000FFFF) |
1033 (((x
<< 8) >> 8) & 0xFFFF0000));
1037 #endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
1041 * @brief Instance structure for the Q7 FIR filter.
1045 uint16_t numTaps
; /**< number of filter coefficients in the filter. */
1046 q7_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1047 q7_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
1048 } arm_fir_instance_q7
;
1051 * @brief Instance structure for the Q15 FIR filter.
1055 uint16_t numTaps
; /**< number of filter coefficients in the filter. */
1056 q15_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1057 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
1058 } arm_fir_instance_q15
;
1061 * @brief Instance structure for the Q31 FIR filter.
1065 uint16_t numTaps
; /**< number of filter coefficients in the filter. */
1066 q31_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1067 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
1068 } arm_fir_instance_q31
;
1071 * @brief Instance structure for the floating-point FIR filter.
1075 uint16_t numTaps
; /**< number of filter coefficients in the filter. */
1076 float32_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1077 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
1078 } arm_fir_instance_f32
;
1082 * @brief Processing function for the Q7 FIR filter.
1083 * @param[in] *S points to an instance of the Q7 FIR filter structure.
1084 * @param[in] *pSrc points to the block of input data.
1085 * @param[out] *pDst points to the block of output data.
1086 * @param[in] blockSize number of samples to process.
1090 const arm_fir_instance_q7
* S
,
1093 uint32_t blockSize
);
1097 * @brief Initialization function for the Q7 FIR filter.
1098 * @param[in,out] *S points to an instance of the Q7 FIR structure.
1099 * @param[in] numTaps Number of filter coefficients in the filter.
1100 * @param[in] *pCoeffs points to the filter coefficients.
1101 * @param[in] *pState points to the state buffer.
1102 * @param[in] blockSize number of samples that are processed.
1105 void arm_fir_init_q7(
1106 arm_fir_instance_q7
* S
,
1110 uint32_t blockSize
);
1114 * @brief Processing function for the Q15 FIR filter.
1115 * @param[in] *S points to an instance of the Q15 FIR structure.
1116 * @param[in] *pSrc points to the block of input data.
1117 * @param[out] *pDst points to the block of output data.
1118 * @param[in] blockSize number of samples to process.
1122 const arm_fir_instance_q15
* S
,
1125 uint32_t blockSize
);
1128 * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
1129 * @param[in] *S points to an instance of the Q15 FIR filter structure.
1130 * @param[in] *pSrc points to the block of input data.
1131 * @param[out] *pDst points to the block of output data.
1132 * @param[in] blockSize number of samples to process.
1135 void arm_fir_fast_q15(
1136 const arm_fir_instance_q15
* S
,
1139 uint32_t blockSize
);
1142 * @brief Initialization function for the Q15 FIR filter.
1143 * @param[in,out] *S points to an instance of the Q15 FIR filter structure.
1144 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
1145 * @param[in] *pCoeffs points to the filter coefficients.
1146 * @param[in] *pState points to the state buffer.
1147 * @param[in] blockSize number of samples that are processed at a time.
1148 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
1149 * <code>numTaps</code> is not a supported value.
1152 arm_status
arm_fir_init_q15(
1153 arm_fir_instance_q15
* S
,
1157 uint32_t blockSize
);
1160 * @brief Processing function for the Q31 FIR filter.
1161 * @param[in] *S points to an instance of the Q31 FIR filter structure.
1162 * @param[in] *pSrc points to the block of input data.
1163 * @param[out] *pDst points to the block of output data.
1164 * @param[in] blockSize number of samples to process.
1168 const arm_fir_instance_q31
* S
,
1171 uint32_t blockSize
);
1174 * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
1175 * @param[in] *S points to an instance of the Q31 FIR structure.
1176 * @param[in] *pSrc points to the block of input data.
1177 * @param[out] *pDst points to the block of output data.
1178 * @param[in] blockSize number of samples to process.
1181 void arm_fir_fast_q31(
1182 const arm_fir_instance_q31
* S
,
1185 uint32_t blockSize
);
1188 * @brief Initialization function for the Q31 FIR filter.
1189 * @param[in,out] *S points to an instance of the Q31 FIR structure.
1190 * @param[in] numTaps Number of filter coefficients in the filter.
1191 * @param[in] *pCoeffs points to the filter coefficients.
1192 * @param[in] *pState points to the state buffer.
1193 * @param[in] blockSize number of samples that are processed at a time.
1196 void arm_fir_init_q31(
1197 arm_fir_instance_q31
* S
,
1201 uint32_t blockSize
);
1204 * @brief Processing function for the floating-point FIR filter.
1205 * @param[in] *S points to an instance of the floating-point FIR structure.
1206 * @param[in] *pSrc points to the block of input data.
1207 * @param[out] *pDst points to the block of output data.
1208 * @param[in] blockSize number of samples to process.
1212 const arm_fir_instance_f32
* S
,
1215 uint32_t blockSize
);
1218 * @brief Initialization function for the floating-point FIR filter.
1219 * @param[in,out] *S points to an instance of the floating-point FIR filter structure.
1220 * @param[in] numTaps Number of filter coefficients in the filter.
1221 * @param[in] *pCoeffs points to the filter coefficients.
1222 * @param[in] *pState points to the state buffer.
1223 * @param[in] blockSize number of samples that are processed at a time.
1226 void arm_fir_init_f32(
1227 arm_fir_instance_f32
* S
,
1229 float32_t
* pCoeffs
,
1231 uint32_t blockSize
);
1235 * @brief Instance structure for the Q15 Biquad cascade filter.
1239 int8_t numStages
; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1240 q15_t
*pState
; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1241 q15_t
*pCoeffs
; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1242 int8_t postShift
; /**< Additional shift, in bits, applied to each output sample. */
1244 } arm_biquad_casd_df1_inst_q15
;
1248 * @brief Instance structure for the Q31 Biquad cascade filter.
1252 uint32_t numStages
; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1253 q31_t
*pState
; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1254 q31_t
*pCoeffs
; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1255 uint8_t postShift
; /**< Additional shift, in bits, applied to each output sample. */
1257 } arm_biquad_casd_df1_inst_q31
;
1260 * @brief Instance structure for the floating-point Biquad cascade filter.
1264 uint32_t numStages
; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1265 float32_t
*pState
; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1266 float32_t
*pCoeffs
; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1269 } arm_biquad_casd_df1_inst_f32
;
1274 * @brief Processing function for the Q15 Biquad cascade filter.
1275 * @param[in] *S points to an instance of the Q15 Biquad cascade structure.
1276 * @param[in] *pSrc points to the block of input data.
1277 * @param[out] *pDst points to the block of output data.
1278 * @param[in] blockSize number of samples to process.
1282 void arm_biquad_cascade_df1_q15(
1283 const arm_biquad_casd_df1_inst_q15
* S
,
1286 uint32_t blockSize
);
1289 * @brief Initialization function for the Q15 Biquad cascade filter.
1290 * @param[in,out] *S points to an instance of the Q15 Biquad cascade structure.
1291 * @param[in] numStages number of 2nd order stages in the filter.
1292 * @param[in] *pCoeffs points to the filter coefficients.
1293 * @param[in] *pState points to the state buffer.
1294 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1298 void arm_biquad_cascade_df1_init_q15(
1299 arm_biquad_casd_df1_inst_q15
* S
,
1307 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1308 * @param[in] *S points to an instance of the Q15 Biquad cascade structure.
1309 * @param[in] *pSrc points to the block of input data.
1310 * @param[out] *pDst points to the block of output data.
1311 * @param[in] blockSize number of samples to process.
1315 void arm_biquad_cascade_df1_fast_q15(
1316 const arm_biquad_casd_df1_inst_q15
* S
,
1319 uint32_t blockSize
);
1323 * @brief Processing function for the Q31 Biquad cascade filter
1324 * @param[in] *S points to an instance of the Q31 Biquad cascade structure.
1325 * @param[in] *pSrc points to the block of input data.
1326 * @param[out] *pDst points to the block of output data.
1327 * @param[in] blockSize number of samples to process.
1331 void arm_biquad_cascade_df1_q31(
1332 const arm_biquad_casd_df1_inst_q31
* S
,
1335 uint32_t blockSize
);
1338 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1339 * @param[in] *S points to an instance of the Q31 Biquad cascade structure.
1340 * @param[in] *pSrc points to the block of input data.
1341 * @param[out] *pDst points to the block of output data.
1342 * @param[in] blockSize number of samples to process.
1346 void arm_biquad_cascade_df1_fast_q31(
1347 const arm_biquad_casd_df1_inst_q31
* S
,
1350 uint32_t blockSize
);
1353 * @brief Initialization function for the Q31 Biquad cascade filter.
1354 * @param[in,out] *S points to an instance of the Q31 Biquad cascade structure.
1355 * @param[in] numStages number of 2nd order stages in the filter.
1356 * @param[in] *pCoeffs points to the filter coefficients.
1357 * @param[in] *pState points to the state buffer.
1358 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1362 void arm_biquad_cascade_df1_init_q31(
1363 arm_biquad_casd_df1_inst_q31
* S
,
1370 * @brief Processing function for the floating-point Biquad cascade filter.
1371 * @param[in] *S points to an instance of the floating-point Biquad cascade structure.
1372 * @param[in] *pSrc points to the block of input data.
1373 * @param[out] *pDst points to the block of output data.
1374 * @param[in] blockSize number of samples to process.
1378 void arm_biquad_cascade_df1_f32(
1379 const arm_biquad_casd_df1_inst_f32
* S
,
1382 uint32_t blockSize
);
1385 * @brief Initialization function for the floating-point Biquad cascade filter.
1386 * @param[in,out] *S points to an instance of the floating-point Biquad cascade structure.
1387 * @param[in] numStages number of 2nd order stages in the filter.
1388 * @param[in] *pCoeffs points to the filter coefficients.
1389 * @param[in] *pState points to the state buffer.
1393 void arm_biquad_cascade_df1_init_f32(
1394 arm_biquad_casd_df1_inst_f32
* S
,
1396 float32_t
* pCoeffs
,
1397 float32_t
* pState
);
1401 * @brief Instance structure for the floating-point matrix structure.
1406 uint16_t numRows
; /**< number of rows of the matrix. */
1407 uint16_t numCols
; /**< number of columns of the matrix. */
1408 float32_t
*pData
; /**< points to the data of the matrix. */
1409 } arm_matrix_instance_f32
;
1412 * @brief Instance structure for the Q15 matrix structure.
1417 uint16_t numRows
; /**< number of rows of the matrix. */
1418 uint16_t numCols
; /**< number of columns of the matrix. */
1419 q15_t
*pData
; /**< points to the data of the matrix. */
1421 } arm_matrix_instance_q15
;
1424 * @brief Instance structure for the Q31 matrix structure.
1429 uint16_t numRows
; /**< number of rows of the matrix. */
1430 uint16_t numCols
; /**< number of columns of the matrix. */
1431 q31_t
*pData
; /**< points to the data of the matrix. */
1433 } arm_matrix_instance_q31
;
1438 * @brief Floating-point matrix addition.
1439 * @param[in] *pSrcA points to the first input matrix structure
1440 * @param[in] *pSrcB points to the second input matrix structure
1441 * @param[out] *pDst points to output matrix structure
1442 * @return The function returns either
1443 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1446 arm_status
arm_mat_add_f32(
1447 const arm_matrix_instance_f32
* pSrcA
,
1448 const arm_matrix_instance_f32
* pSrcB
,
1449 arm_matrix_instance_f32
* pDst
);
1452 * @brief Q15 matrix addition.
1453 * @param[in] *pSrcA points to the first input matrix structure
1454 * @param[in] *pSrcB points to the second input matrix structure
1455 * @param[out] *pDst points to output matrix structure
1456 * @return The function returns either
1457 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1460 arm_status
arm_mat_add_q15(
1461 const arm_matrix_instance_q15
* pSrcA
,
1462 const arm_matrix_instance_q15
* pSrcB
,
1463 arm_matrix_instance_q15
* pDst
);
1466 * @brief Q31 matrix addition.
1467 * @param[in] *pSrcA points to the first input matrix structure
1468 * @param[in] *pSrcB points to the second input matrix structure
1469 * @param[out] *pDst points to output matrix structure
1470 * @return The function returns either
1471 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1474 arm_status
arm_mat_add_q31(
1475 const arm_matrix_instance_q31
* pSrcA
,
1476 const arm_matrix_instance_q31
* pSrcB
,
1477 arm_matrix_instance_q31
* pDst
);
1481 * @brief Floating-point matrix transpose.
1482 * @param[in] *pSrc points to the input matrix
1483 * @param[out] *pDst points to the output matrix
1484 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1485 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1488 arm_status
arm_mat_trans_f32(
1489 const arm_matrix_instance_f32
* pSrc
,
1490 arm_matrix_instance_f32
* pDst
);
1494 * @brief Q15 matrix transpose.
1495 * @param[in] *pSrc points to the input matrix
1496 * @param[out] *pDst points to the output matrix
1497 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1498 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1501 arm_status
arm_mat_trans_q15(
1502 const arm_matrix_instance_q15
* pSrc
,
1503 arm_matrix_instance_q15
* pDst
);
1506 * @brief Q31 matrix transpose.
1507 * @param[in] *pSrc points to the input matrix
1508 * @param[out] *pDst points to the output matrix
1509 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1510 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1513 arm_status
arm_mat_trans_q31(
1514 const arm_matrix_instance_q31
* pSrc
,
1515 arm_matrix_instance_q31
* pDst
);
1519 * @brief Floating-point matrix multiplication
1520 * @param[in] *pSrcA points to the first input matrix structure
1521 * @param[in] *pSrcB points to the second input matrix structure
1522 * @param[out] *pDst points to output matrix structure
1523 * @return The function returns either
1524 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1527 arm_status
arm_mat_mult_f32(
1528 const arm_matrix_instance_f32
* pSrcA
,
1529 const arm_matrix_instance_f32
* pSrcB
,
1530 arm_matrix_instance_f32
* pDst
);
1533 * @brief Q15 matrix multiplication
1534 * @param[in] *pSrcA points to the first input matrix structure
1535 * @param[in] *pSrcB points to the second input matrix structure
1536 * @param[out] *pDst points to output matrix structure
1537 * @param[in] *pState points to the array for storing intermediate results
1538 * @return The function returns either
1539 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1542 arm_status
arm_mat_mult_q15(
1543 const arm_matrix_instance_q15
* pSrcA
,
1544 const arm_matrix_instance_q15
* pSrcB
,
1545 arm_matrix_instance_q15
* pDst
,
1549 * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1550 * @param[in] *pSrcA points to the first input matrix structure
1551 * @param[in] *pSrcB points to the second input matrix structure
1552 * @param[out] *pDst points to output matrix structure
1553 * @param[in] *pState points to the array for storing intermediate results
1554 * @return The function returns either
1555 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1558 arm_status
arm_mat_mult_fast_q15(
1559 const arm_matrix_instance_q15
* pSrcA
,
1560 const arm_matrix_instance_q15
* pSrcB
,
1561 arm_matrix_instance_q15
* pDst
,
1565 * @brief Q31 matrix multiplication
1566 * @param[in] *pSrcA points to the first input matrix structure
1567 * @param[in] *pSrcB points to the second input matrix structure
1568 * @param[out] *pDst points to output matrix structure
1569 * @return The function returns either
1570 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1573 arm_status
arm_mat_mult_q31(
1574 const arm_matrix_instance_q31
* pSrcA
,
1575 const arm_matrix_instance_q31
* pSrcB
,
1576 arm_matrix_instance_q31
* pDst
);
1579 * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1580 * @param[in] *pSrcA points to the first input matrix structure
1581 * @param[in] *pSrcB points to the second input matrix structure
1582 * @param[out] *pDst points to output matrix structure
1583 * @return The function returns either
1584 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1587 arm_status
arm_mat_mult_fast_q31(
1588 const arm_matrix_instance_q31
* pSrcA
,
1589 const arm_matrix_instance_q31
* pSrcB
,
1590 arm_matrix_instance_q31
* pDst
);
1594 * @brief Floating-point matrix subtraction
1595 * @param[in] *pSrcA points to the first input matrix structure
1596 * @param[in] *pSrcB points to the second input matrix structure
1597 * @param[out] *pDst points to output matrix structure
1598 * @return The function returns either
1599 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1602 arm_status
arm_mat_sub_f32(
1603 const arm_matrix_instance_f32
* pSrcA
,
1604 const arm_matrix_instance_f32
* pSrcB
,
1605 arm_matrix_instance_f32
* pDst
);
1608 * @brief Q15 matrix subtraction
1609 * @param[in] *pSrcA points to the first input matrix structure
1610 * @param[in] *pSrcB points to the second input matrix structure
1611 * @param[out] *pDst points to output matrix structure
1612 * @return The function returns either
1613 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1616 arm_status
arm_mat_sub_q15(
1617 const arm_matrix_instance_q15
* pSrcA
,
1618 const arm_matrix_instance_q15
* pSrcB
,
1619 arm_matrix_instance_q15
* pDst
);
1622 * @brief Q31 matrix subtraction
1623 * @param[in] *pSrcA points to the first input matrix structure
1624 * @param[in] *pSrcB points to the second input matrix structure
1625 * @param[out] *pDst points to output matrix structure
1626 * @return The function returns either
1627 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1630 arm_status
arm_mat_sub_q31(
1631 const arm_matrix_instance_q31
* pSrcA
,
1632 const arm_matrix_instance_q31
* pSrcB
,
1633 arm_matrix_instance_q31
* pDst
);
1636 * @brief Floating-point matrix scaling.
1637 * @param[in] *pSrc points to the input matrix
1638 * @param[in] scale scale factor
1639 * @param[out] *pDst points to the output matrix
1640 * @return The function returns either
1641 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1644 arm_status
arm_mat_scale_f32(
1645 const arm_matrix_instance_f32
* pSrc
,
1647 arm_matrix_instance_f32
* pDst
);
1650 * @brief Q15 matrix scaling.
1651 * @param[in] *pSrc points to input matrix
1652 * @param[in] scaleFract fractional portion of the scale factor
1653 * @param[in] shift number of bits to shift the result by
1654 * @param[out] *pDst points to output matrix
1655 * @return The function returns either
1656 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1659 arm_status
arm_mat_scale_q15(
1660 const arm_matrix_instance_q15
* pSrc
,
1663 arm_matrix_instance_q15
* pDst
);
1666 * @brief Q31 matrix scaling.
1667 * @param[in] *pSrc points to input matrix
1668 * @param[in] scaleFract fractional portion of the scale factor
1669 * @param[in] shift number of bits to shift the result by
1670 * @param[out] *pDst points to output matrix structure
1671 * @return The function returns either
1672 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1675 arm_status
arm_mat_scale_q31(
1676 const arm_matrix_instance_q31
* pSrc
,
1679 arm_matrix_instance_q31
* pDst
);
1683 * @brief Q31 matrix initialization.
1684 * @param[in,out] *S points to an instance of the floating-point matrix structure.
1685 * @param[in] nRows number of rows in the matrix.
1686 * @param[in] nColumns number of columns in the matrix.
1687 * @param[in] *pData points to the matrix data array.
1691 void arm_mat_init_q31(
1692 arm_matrix_instance_q31
* S
,
1698 * @brief Q15 matrix initialization.
1699 * @param[in,out] *S points to an instance of the floating-point matrix structure.
1700 * @param[in] nRows number of rows in the matrix.
1701 * @param[in] nColumns number of columns in the matrix.
1702 * @param[in] *pData points to the matrix data array.
1706 void arm_mat_init_q15(
1707 arm_matrix_instance_q15
* S
,
1713 * @brief Floating-point matrix initialization.
1714 * @param[in,out] *S points to an instance of the floating-point matrix structure.
1715 * @param[in] nRows number of rows in the matrix.
1716 * @param[in] nColumns number of columns in the matrix.
1717 * @param[in] *pData points to the matrix data array.
1721 void arm_mat_init_f32(
1722 arm_matrix_instance_f32
* S
,
1730 * @brief Instance structure for the Q15 PID Control.
1734 q15_t A0
; /**< The derived gain, A0 = Kp + Ki + Kd . */
1735 #ifdef ARM_MATH_CM0_FAMILY
1739 q31_t A1
; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
1741 q15_t state
[3]; /**< The state array of length 3. */
1742 q15_t Kp
; /**< The proportional gain. */
1743 q15_t Ki
; /**< The integral gain. */
1744 q15_t Kd
; /**< The derivative gain. */
1745 } arm_pid_instance_q15
;
1748 * @brief Instance structure for the Q31 PID Control.
1752 q31_t A0
; /**< The derived gain, A0 = Kp + Ki + Kd . */
1753 q31_t A1
; /**< The derived gain, A1 = -Kp - 2Kd. */
1754 q31_t A2
; /**< The derived gain, A2 = Kd . */
1755 q31_t state
[3]; /**< The state array of length 3. */
1756 q31_t Kp
; /**< The proportional gain. */
1757 q31_t Ki
; /**< The integral gain. */
1758 q31_t Kd
; /**< The derivative gain. */
1760 } arm_pid_instance_q31
;
1763 * @brief Instance structure for the floating-point PID Control.
1767 float32_t A0
; /**< The derived gain, A0 = Kp + Ki + Kd . */
1768 float32_t A1
; /**< The derived gain, A1 = -Kp - 2Kd. */
1769 float32_t A2
; /**< The derived gain, A2 = Kd . */
1770 float32_t state
[3]; /**< The state array of length 3. */
1771 float32_t Kp
; /**< The proportional gain. */
1772 float32_t Ki
; /**< The integral gain. */
1773 float32_t Kd
; /**< The derivative gain. */
1774 } arm_pid_instance_f32
;
1779 * @brief Initialization function for the floating-point PID Control.
1780 * @param[in,out] *S points to an instance of the PID structure.
1781 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1784 void arm_pid_init_f32(
1785 arm_pid_instance_f32
* S
,
1786 int32_t resetStateFlag
);
1789 * @brief Reset function for the floating-point PID Control.
1790 * @param[in,out] *S is an instance of the floating-point PID Control structure
1793 void arm_pid_reset_f32(
1794 arm_pid_instance_f32
* S
);
1798 * @brief Initialization function for the Q31 PID Control.
1799 * @param[in,out] *S points to an instance of the Q15 PID structure.
1800 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1803 void arm_pid_init_q31(
1804 arm_pid_instance_q31
* S
,
1805 int32_t resetStateFlag
);
1809 * @brief Reset function for the Q31 PID Control.
1810 * @param[in,out] *S points to an instance of the Q31 PID Control structure
1814 void arm_pid_reset_q31(
1815 arm_pid_instance_q31
* S
);
1818 * @brief Initialization function for the Q15 PID Control.
1819 * @param[in,out] *S points to an instance of the Q15 PID structure.
1820 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1823 void arm_pid_init_q15(
1824 arm_pid_instance_q15
* S
,
1825 int32_t resetStateFlag
);
1828 * @brief Reset function for the Q15 PID Control.
1829 * @param[in,out] *S points to an instance of the q15 PID Control structure
1832 void arm_pid_reset_q15(
1833 arm_pid_instance_q15
* S
);
1837 * @brief Instance structure for the floating-point Linear Interpolate function.
1841 uint32_t nValues
; /**< nValues */
1842 float32_t x1
; /**< x1 */
1843 float32_t xSpacing
; /**< xSpacing */
1844 float32_t
*pYData
; /**< pointer to the table of Y values */
1845 } arm_linear_interp_instance_f32
;
1848 * @brief Instance structure for the floating-point bilinear interpolation function.
1853 uint16_t numRows
; /**< number of rows in the data table. */
1854 uint16_t numCols
; /**< number of columns in the data table. */
1855 float32_t
*pData
; /**< points to the data table. */
1856 } arm_bilinear_interp_instance_f32
;
1859 * @brief Instance structure for the Q31 bilinear interpolation function.
1864 uint16_t numRows
; /**< number of rows in the data table. */
1865 uint16_t numCols
; /**< number of columns in the data table. */
1866 q31_t
*pData
; /**< points to the data table. */
1867 } arm_bilinear_interp_instance_q31
;
1870 * @brief Instance structure for the Q15 bilinear interpolation function.
1875 uint16_t numRows
; /**< number of rows in the data table. */
1876 uint16_t numCols
; /**< number of columns in the data table. */
1877 q15_t
*pData
; /**< points to the data table. */
1878 } arm_bilinear_interp_instance_q15
;
1881 * @brief Instance structure for the Q15 bilinear interpolation function.
1886 uint16_t numRows
; /**< number of rows in the data table. */
1887 uint16_t numCols
; /**< number of columns in the data table. */
1888 q7_t
*pData
; /**< points to the data table. */
1889 } arm_bilinear_interp_instance_q7
;
1893 * @brief Q7 vector multiplication.
1894 * @param[in] *pSrcA points to the first input vector
1895 * @param[in] *pSrcB points to the second input vector
1896 * @param[out] *pDst points to the output vector
1897 * @param[in] blockSize number of samples in each vector
1905 uint32_t blockSize
);
1908 * @brief Q15 vector multiplication.
1909 * @param[in] *pSrcA points to the first input vector
1910 * @param[in] *pSrcB points to the second input vector
1911 * @param[out] *pDst points to the output vector
1912 * @param[in] blockSize number of samples in each vector
1920 uint32_t blockSize
);
1923 * @brief Q31 vector multiplication.
1924 * @param[in] *pSrcA points to the first input vector
1925 * @param[in] *pSrcB points to the second input vector
1926 * @param[out] *pDst points to the output vector
1927 * @param[in] blockSize number of samples in each vector
1935 uint32_t blockSize
);
1938 * @brief Floating-point vector multiplication.
1939 * @param[in] *pSrcA points to the first input vector
1940 * @param[in] *pSrcB points to the second input vector
1941 * @param[out] *pDst points to the output vector
1942 * @param[in] blockSize number of samples in each vector
1950 uint32_t blockSize
);
1958 * @brief Instance structure for the Q15 CFFT/CIFFT function.
1963 uint16_t fftLen
; /**< length of the FFT. */
1964 uint8_t ifftFlag
; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
1965 uint8_t bitReverseFlag
; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
1966 q15_t
*pTwiddle
; /**< points to the Sin twiddle factor table. */
1967 uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
1968 uint16_t twidCoefModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
1969 uint16_t bitRevFactor
; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
1970 } arm_cfft_radix2_instance_q15
;
1972 arm_status
arm_cfft_radix2_init_q15(
1973 arm_cfft_radix2_instance_q15
* S
,
1976 uint8_t bitReverseFlag
);
1978 void arm_cfft_radix2_q15(
1979 const arm_cfft_radix2_instance_q15
* S
,
1985 * @brief Instance structure for the Q15 CFFT/CIFFT function.
1990 uint16_t fftLen
; /**< length of the FFT. */
1991 uint8_t ifftFlag
; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
1992 uint8_t bitReverseFlag
; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
1993 q15_t
*pTwiddle
; /**< points to the twiddle factor table. */
1994 uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
1995 uint16_t twidCoefModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
1996 uint16_t bitRevFactor
; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
1997 } arm_cfft_radix4_instance_q15
;
1999 arm_status
arm_cfft_radix4_init_q15(
2000 arm_cfft_radix4_instance_q15
* S
,
2003 uint8_t bitReverseFlag
);
2005 void arm_cfft_radix4_q15(
2006 const arm_cfft_radix4_instance_q15
* S
,
2010 * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
2015 uint16_t fftLen
; /**< length of the FFT. */
2016 uint8_t ifftFlag
; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2017 uint8_t bitReverseFlag
; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2018 q31_t
*pTwiddle
; /**< points to the Twiddle factor table. */
2019 uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
2020 uint16_t twidCoefModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2021 uint16_t bitRevFactor
; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2022 } arm_cfft_radix2_instance_q31
;
2024 arm_status
arm_cfft_radix2_init_q31(
2025 arm_cfft_radix2_instance_q31
* S
,
2028 uint8_t bitReverseFlag
);
2030 void arm_cfft_radix2_q31(
2031 const arm_cfft_radix2_instance_q31
* S
,
2035 * @brief Instance structure for the Q31 CFFT/CIFFT function.
2040 uint16_t fftLen
; /**< length of the FFT. */
2041 uint8_t ifftFlag
; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2042 uint8_t bitReverseFlag
; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2043 q31_t
*pTwiddle
; /**< points to the twiddle factor table. */
2044 uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
2045 uint16_t twidCoefModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2046 uint16_t bitRevFactor
; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2047 } arm_cfft_radix4_instance_q31
;
2050 void arm_cfft_radix4_q31(
2051 const arm_cfft_radix4_instance_q31
* S
,
2054 arm_status
arm_cfft_radix4_init_q31(
2055 arm_cfft_radix4_instance_q31
* S
,
2058 uint8_t bitReverseFlag
);
2061 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2066 uint16_t fftLen
; /**< length of the FFT. */
2067 uint8_t ifftFlag
; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2068 uint8_t bitReverseFlag
; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2069 float32_t
*pTwiddle
; /**< points to the Twiddle factor table. */
2070 uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
2071 uint16_t twidCoefModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2072 uint16_t bitRevFactor
; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2073 float32_t onebyfftLen
; /**< value of 1/fftLen. */
2074 } arm_cfft_radix2_instance_f32
;
2077 arm_status
arm_cfft_radix2_init_f32(
2078 arm_cfft_radix2_instance_f32
* S
,
2081 uint8_t bitReverseFlag
);
2084 void arm_cfft_radix2_f32(
2085 const arm_cfft_radix2_instance_f32
* S
,
2089 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2094 uint16_t fftLen
; /**< length of the FFT. */
2095 uint8_t ifftFlag
; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2096 uint8_t bitReverseFlag
; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2097 float32_t
*pTwiddle
; /**< points to the Twiddle factor table. */
2098 uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
2099 uint16_t twidCoefModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2100 uint16_t bitRevFactor
; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2101 float32_t onebyfftLen
; /**< value of 1/fftLen. */
2102 } arm_cfft_radix4_instance_f32
;
2105 arm_status
arm_cfft_radix4_init_f32(
2106 arm_cfft_radix4_instance_f32
* S
,
2109 uint8_t bitReverseFlag
);
2112 void arm_cfft_radix4_f32(
2113 const arm_cfft_radix4_instance_f32
* S
,
2117 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2122 uint16_t fftLen
; /**< length of the FFT. */
2123 const float32_t
*pTwiddle
; /**< points to the Twiddle factor table. */
2124 const uint16_t *pBitRevTable
; /**< points to the bit reversal table. */
2125 uint16_t bitRevLength
; /**< bit reversal table length. */
2126 } arm_cfft_instance_f32
;
2129 const arm_cfft_instance_f32
* S
,
2132 uint8_t bitReverseFlag
);
2135 * @brief Instance structure for the Q15 RFFT/RIFFT function.
2140 uint32_t fftLenReal
; /**< length of the real FFT. */
2141 uint32_t fftLenBy2
; /**< length of the complex 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 arm_cfft_radix4_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 arm_cfft_radix4_instance_q15
* S_CFFT
,
2153 uint32_t fftLenReal
,
2155 uint32_t bitReverseFlag
);
2158 const arm_rfft_instance_q15
* S
,
2163 * @brief Instance structure for the Q31 RFFT/RIFFT function.
2168 uint32_t fftLenReal
; /**< length of the real FFT. */
2169 uint32_t fftLenBy2
; /**< length of the complex FFT. */
2170 uint8_t ifftFlagR
; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2171 uint8_t bitReverseFlagR
; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2172 uint32_t twidCoefRModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2173 q31_t
*pTwiddleAReal
; /**< points to the real twiddle factor table. */
2174 q31_t
*pTwiddleBReal
; /**< points to the imag twiddle factor table. */
2175 arm_cfft_radix4_instance_q31
*pCfft
; /**< points to the complex FFT instance. */
2176 } arm_rfft_instance_q31
;
2178 arm_status
arm_rfft_init_q31(
2179 arm_rfft_instance_q31
* S
,
2180 arm_cfft_radix4_instance_q31
* S_CFFT
,
2181 uint32_t fftLenReal
,
2183 uint32_t bitReverseFlag
);
2186 const arm_rfft_instance_q31
* S
,
2191 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2196 uint32_t fftLenReal
; /**< length of the real FFT. */
2197 uint16_t fftLenBy2
; /**< length of the complex FFT. */
2198 uint8_t ifftFlagR
; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2199 uint8_t bitReverseFlagR
; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2200 uint32_t twidCoefRModifier
; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2201 float32_t
*pTwiddleAReal
; /**< points to the real twiddle factor table. */
2202 float32_t
*pTwiddleBReal
; /**< points to the imag twiddle factor table. */
2203 arm_cfft_radix4_instance_f32
*pCfft
; /**< points to the complex FFT instance. */
2204 } arm_rfft_instance_f32
;
2206 arm_status
arm_rfft_init_f32(
2207 arm_rfft_instance_f32
* S
,
2208 arm_cfft_radix4_instance_f32
* S_CFFT
,
2209 uint32_t fftLenReal
,
2211 uint32_t bitReverseFlag
);
2214 const arm_rfft_instance_f32
* S
,
2219 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2224 arm_cfft_instance_f32 Sint
; /**< Internal CFFT structure. */
2225 uint16_t fftLenRFFT
; /**< length of the real sequence */
2226 float32_t
* pTwiddleRFFT
; /**< Twiddle factors real stage */
2227 } arm_rfft_fast_instance_f32
;
2229 arm_status
arm_rfft_fast_init_f32 (
2230 arm_rfft_fast_instance_f32
* S
,
2233 void arm_rfft_fast_f32(
2234 arm_rfft_fast_instance_f32
* S
,
2235 float32_t
* p
, float32_t
* pOut
,
2239 * @brief Instance structure for the floating-point DCT4/IDCT4 function.
2244 uint16_t N
; /**< length of the DCT4. */
2245 uint16_t Nby2
; /**< half of the length of the DCT4. */
2246 float32_t normalize
; /**< normalizing factor. */
2247 float32_t
*pTwiddle
; /**< points to the twiddle factor table. */
2248 float32_t
*pCosFactor
; /**< points to the cosFactor table. */
2249 arm_rfft_instance_f32
*pRfft
; /**< points to the real FFT instance. */
2250 arm_cfft_radix4_instance_f32
*pCfft
; /**< points to the complex FFT instance. */
2251 } arm_dct4_instance_f32
;
2254 * @brief Initialization function for the floating-point DCT4/IDCT4.
2255 * @param[in,out] *S points to an instance of floating-point DCT4/IDCT4 structure.
2256 * @param[in] *S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
2257 * @param[in] *S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
2258 * @param[in] N length of the DCT4.
2259 * @param[in] Nby2 half of the length of the DCT4.
2260 * @param[in] normalize normalizing factor.
2261 * @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.
2264 arm_status
arm_dct4_init_f32(
2265 arm_dct4_instance_f32
* S
,
2266 arm_rfft_instance_f32
* S_RFFT
,
2267 arm_cfft_radix4_instance_f32
* S_CFFT
,
2270 float32_t normalize
);
2273 * @brief Processing function for the floating-point DCT4/IDCT4.
2274 * @param[in] *S points to an instance of the floating-point DCT4/IDCT4 structure.
2275 * @param[in] *pState points to state buffer.
2276 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
2281 const arm_dct4_instance_f32
* S
,
2283 float32_t
* pInlineBuffer
);
2286 * @brief Instance structure for the Q31 DCT4/IDCT4 function.
2291 uint16_t N
; /**< length of the DCT4. */
2292 uint16_t Nby2
; /**< half of the length of the DCT4. */
2293 q31_t normalize
; /**< normalizing factor. */
2294 q31_t
*pTwiddle
; /**< points to the twiddle factor table. */
2295 q31_t
*pCosFactor
; /**< points to the cosFactor table. */
2296 arm_rfft_instance_q31
*pRfft
; /**< points to the real FFT instance. */
2297 arm_cfft_radix4_instance_q31
*pCfft
; /**< points to the complex FFT instance. */
2298 } arm_dct4_instance_q31
;
2301 * @brief Initialization function for the Q31 DCT4/IDCT4.
2302 * @param[in,out] *S points to an instance of Q31 DCT4/IDCT4 structure.
2303 * @param[in] *S_RFFT points to an instance of Q31 RFFT/RIFFT structure
2304 * @param[in] *S_CFFT points to an instance of Q31 CFFT/CIFFT structure
2305 * @param[in] N length of the DCT4.
2306 * @param[in] Nby2 half of the length of the DCT4.
2307 * @param[in] normalize normalizing factor.
2308 * @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.
2311 arm_status
arm_dct4_init_q31(
2312 arm_dct4_instance_q31
* S
,
2313 arm_rfft_instance_q31
* S_RFFT
,
2314 arm_cfft_radix4_instance_q31
* S_CFFT
,
2320 * @brief Processing function for the Q31 DCT4/IDCT4.
2321 * @param[in] *S points to an instance of the Q31 DCT4 structure.
2322 * @param[in] *pState points to state buffer.
2323 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
2328 const arm_dct4_instance_q31
* S
,
2330 q31_t
* pInlineBuffer
);
2333 * @brief Instance structure for the Q15 DCT4/IDCT4 function.
2338 uint16_t N
; /**< length of the DCT4. */
2339 uint16_t Nby2
; /**< half of the length of the DCT4. */
2340 q15_t normalize
; /**< normalizing factor. */
2341 q15_t
*pTwiddle
; /**< points to the twiddle factor table. */
2342 q15_t
*pCosFactor
; /**< points to the cosFactor table. */
2343 arm_rfft_instance_q15
*pRfft
; /**< points to the real FFT instance. */
2344 arm_cfft_radix4_instance_q15
*pCfft
; /**< points to the complex FFT instance. */
2345 } arm_dct4_instance_q15
;
2348 * @brief Initialization function for the Q15 DCT4/IDCT4.
2349 * @param[in,out] *S points to an instance of Q15 DCT4/IDCT4 structure.
2350 * @param[in] *S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
2351 * @param[in] *S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
2352 * @param[in] N length of the DCT4.
2353 * @param[in] Nby2 half of the length of the DCT4.
2354 * @param[in] normalize normalizing factor.
2355 * @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.
2358 arm_status
arm_dct4_init_q15(
2359 arm_dct4_instance_q15
* S
,
2360 arm_rfft_instance_q15
* S_RFFT
,
2361 arm_cfft_radix4_instance_q15
* S_CFFT
,
2367 * @brief Processing function for the Q15 DCT4/IDCT4.
2368 * @param[in] *S points to an instance of the Q15 DCT4 structure.
2369 * @param[in] *pState points to state buffer.
2370 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
2375 const arm_dct4_instance_q15
* S
,
2377 q15_t
* pInlineBuffer
);
2380 * @brief Floating-point vector addition.
2381 * @param[in] *pSrcA points to the first input vector
2382 * @param[in] *pSrcB points to the second input vector
2383 * @param[out] *pDst points to the output vector
2384 * @param[in] blockSize number of samples in each vector
2392 uint32_t blockSize
);
2395 * @brief Q7 vector addition.
2396 * @param[in] *pSrcA points to the first input vector
2397 * @param[in] *pSrcB points to the second input vector
2398 * @param[out] *pDst points to the output vector
2399 * @param[in] blockSize number of samples in each vector
2407 uint32_t blockSize
);
2410 * @brief Q15 vector addition.
2411 * @param[in] *pSrcA points to the first input vector
2412 * @param[in] *pSrcB points to the second input vector
2413 * @param[out] *pDst points to the output vector
2414 * @param[in] blockSize number of samples in each vector
2422 uint32_t blockSize
);
2425 * @brief Q31 vector addition.
2426 * @param[in] *pSrcA points to the first input vector
2427 * @param[in] *pSrcB points to the second input vector
2428 * @param[out] *pDst points to the output vector
2429 * @param[in] blockSize number of samples in each vector
2437 uint32_t blockSize
);
2440 * @brief Floating-point vector subtraction.
2441 * @param[in] *pSrcA points to the first input vector
2442 * @param[in] *pSrcB points to the second input vector
2443 * @param[out] *pDst points to the output vector
2444 * @param[in] blockSize number of samples in each vector
2452 uint32_t blockSize
);
2455 * @brief Q7 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
2467 uint32_t blockSize
);
2470 * @brief Q15 vector subtraction.
2471 * @param[in] *pSrcA points to the first input vector
2472 * @param[in] *pSrcB points to the second input vector
2473 * @param[out] *pDst points to the output vector
2474 * @param[in] blockSize number of samples in each vector
2482 uint32_t blockSize
);
2485 * @brief Q31 vector subtraction.
2486 * @param[in] *pSrcA points to the first input vector
2487 * @param[in] *pSrcB points to the second input vector
2488 * @param[out] *pDst points to the output vector
2489 * @param[in] blockSize number of samples in each vector
2497 uint32_t blockSize
);
2500 * @brief Multiplies a floating-point vector by a scalar.
2501 * @param[in] *pSrc points to the input vector
2502 * @param[in] scale scale factor to be applied
2503 * @param[out] *pDst points to the output vector
2504 * @param[in] blockSize number of samples in the vector
2512 uint32_t blockSize
);
2515 * @brief Multiplies a Q7 vector by a scalar.
2516 * @param[in] *pSrc points to the input vector
2517 * @param[in] scaleFract fractional portion of the scale value
2518 * @param[in] shift number of bits to shift the result by
2519 * @param[out] *pDst points to the output vector
2520 * @param[in] blockSize number of samples in the vector
2529 uint32_t blockSize
);
2532 * @brief Multiplies a Q15 vector by a scalar.
2533 * @param[in] *pSrc points to the input vector
2534 * @param[in] scaleFract fractional portion of the scale value
2535 * @param[in] shift number of bits to shift the result by
2536 * @param[out] *pDst points to the output vector
2537 * @param[in] blockSize number of samples in the vector
2546 uint32_t blockSize
);
2549 * @brief Multiplies a Q31 vector by a scalar.
2550 * @param[in] *pSrc points to the input vector
2551 * @param[in] scaleFract fractional portion of the scale value
2552 * @param[in] shift number of bits to shift the result by
2553 * @param[out] *pDst points to the output vector
2554 * @param[in] blockSize number of samples in the vector
2563 uint32_t blockSize
);
2566 * @brief Q7 vector absolute value.
2567 * @param[in] *pSrc points to the input buffer
2568 * @param[out] *pDst points to the output buffer
2569 * @param[in] blockSize number of samples in each vector
2576 uint32_t blockSize
);
2579 * @brief Floating-point vector absolute value.
2580 * @param[in] *pSrc points to the input buffer
2581 * @param[out] *pDst points to the output buffer
2582 * @param[in] blockSize number of samples in each vector
2589 uint32_t blockSize
);
2592 * @brief Q15 vector absolute value.
2593 * @param[in] *pSrc points to the input buffer
2594 * @param[out] *pDst points to the output buffer
2595 * @param[in] blockSize number of samples in each vector
2602 uint32_t blockSize
);
2605 * @brief Q31 vector absolute value.
2606 * @param[in] *pSrc points to the input buffer
2607 * @param[out] *pDst points to the output buffer
2608 * @param[in] blockSize number of samples in each vector
2615 uint32_t blockSize
);
2618 * @brief Dot product of floating-point vectors.
2619 * @param[in] *pSrcA points to the first input vector
2620 * @param[in] *pSrcB points to the second input vector
2621 * @param[in] blockSize number of samples in each vector
2622 * @param[out] *result output result returned here
2626 void arm_dot_prod_f32(
2630 float32_t
* result
);
2633 * @brief Dot product of Q7 vectors.
2634 * @param[in] *pSrcA points to the first input vector
2635 * @param[in] *pSrcB points to the second input vector
2636 * @param[in] blockSize number of samples in each vector
2637 * @param[out] *result output result returned here
2641 void arm_dot_prod_q7(
2648 * @brief Dot product of Q15 vectors.
2649 * @param[in] *pSrcA points to the first input vector
2650 * @param[in] *pSrcB points to the second input vector
2651 * @param[in] blockSize number of samples in each vector
2652 * @param[out] *result output result returned here
2656 void arm_dot_prod_q15(
2663 * @brief Dot product of Q31 vectors.
2664 * @param[in] *pSrcA points to the first input vector
2665 * @param[in] *pSrcB points to the second input vector
2666 * @param[in] blockSize number of samples in each vector
2667 * @param[out] *result output result returned here
2671 void arm_dot_prod_q31(
2678 * @brief Shifts the elements of a Q7 vector a specified number of bits.
2679 * @param[in] *pSrc points to the input vector
2680 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2681 * @param[out] *pDst points to the output vector
2682 * @param[in] blockSize number of samples in the vector
2690 uint32_t blockSize
);
2693 * @brief Shifts the elements of a Q15 vector a specified number of bits.
2694 * @param[in] *pSrc points to the input vector
2695 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2696 * @param[out] *pDst points to the output vector
2697 * @param[in] blockSize number of samples in the vector
2705 uint32_t blockSize
);
2708 * @brief Shifts the elements of a Q31 vector a specified number of bits.
2709 * @param[in] *pSrc points to the input vector
2710 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2711 * @param[out] *pDst points to the output vector
2712 * @param[in] blockSize number of samples in the vector
2720 uint32_t blockSize
);
2723 * @brief Adds a constant offset to a floating-point vector.
2724 * @param[in] *pSrc points to the input vector
2725 * @param[in] offset is the offset to be added
2726 * @param[out] *pDst points to the output vector
2727 * @param[in] blockSize number of samples in the vector
2731 void arm_offset_f32(
2735 uint32_t blockSize
);
2738 * @brief Adds a constant offset to a Q7 vector.
2739 * @param[in] *pSrc points to the input vector
2740 * @param[in] offset is the offset to be added
2741 * @param[out] *pDst points to the output vector
2742 * @param[in] blockSize number of samples in the vector
2750 uint32_t blockSize
);
2753 * @brief Adds a constant offset to a Q15 vector.
2754 * @param[in] *pSrc points to the input vector
2755 * @param[in] offset is the offset to be added
2756 * @param[out] *pDst points to the output vector
2757 * @param[in] blockSize number of samples in the vector
2761 void arm_offset_q15(
2765 uint32_t blockSize
);
2768 * @brief Adds a constant offset to a Q31 vector.
2769 * @param[in] *pSrc points to the input vector
2770 * @param[in] offset is the offset to be added
2771 * @param[out] *pDst points to the output vector
2772 * @param[in] blockSize number of samples in the vector
2776 void arm_offset_q31(
2780 uint32_t blockSize
);
2783 * @brief Negates the elements of a floating-point 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
2790 void arm_negate_f32(
2793 uint32_t blockSize
);
2796 * @brief Negates the elements of a Q7 vector.
2797 * @param[in] *pSrc points to the input vector
2798 * @param[out] *pDst points to the output vector
2799 * @param[in] blockSize number of samples in the vector
2806 uint32_t blockSize
);
2809 * @brief Negates the elements of a Q15 vector.
2810 * @param[in] *pSrc points to the input vector
2811 * @param[out] *pDst points to the output vector
2812 * @param[in] blockSize number of samples in the vector
2816 void arm_negate_q15(
2819 uint32_t blockSize
);
2822 * @brief Negates the elements of a Q31 vector.
2823 * @param[in] *pSrc points to the input vector
2824 * @param[out] *pDst points to the output vector
2825 * @param[in] blockSize number of samples in the vector
2829 void arm_negate_q31(
2832 uint32_t blockSize
);
2834 * @brief Copies the elements of a floating-point vector.
2835 * @param[in] *pSrc input pointer
2836 * @param[out] *pDst output pointer
2837 * @param[in] blockSize number of samples to process
2843 uint32_t blockSize
);
2846 * @brief Copies the elements of a Q7 vector.
2847 * @param[in] *pSrc input pointer
2848 * @param[out] *pDst output pointer
2849 * @param[in] blockSize number of samples to process
2855 uint32_t blockSize
);
2858 * @brief Copies the elements of a Q15 vector.
2859 * @param[in] *pSrc input pointer
2860 * @param[out] *pDst output pointer
2861 * @param[in] blockSize number of samples to process
2867 uint32_t blockSize
);
2870 * @brief Copies the elements of a Q31 vector.
2871 * @param[in] *pSrc input pointer
2872 * @param[out] *pDst output pointer
2873 * @param[in] blockSize number of samples to process
2879 uint32_t blockSize
);
2881 * @brief Fills a constant value into a floating-point vector.
2882 * @param[in] value input value to be filled
2883 * @param[out] *pDst output pointer
2884 * @param[in] blockSize number of samples to process
2890 uint32_t blockSize
);
2893 * @brief Fills a constant value into a Q7 vector.
2894 * @param[in] value input value to be filled
2895 * @param[out] *pDst output pointer
2896 * @param[in] blockSize number of samples to process
2902 uint32_t blockSize
);
2905 * @brief Fills a constant value into a Q15 vector.
2906 * @param[in] value input value to be filled
2907 * @param[out] *pDst output pointer
2908 * @param[in] blockSize number of samples to process
2914 uint32_t blockSize
);
2917 * @brief Fills a constant value into a Q31 vector.
2918 * @param[in] value input value to be filled
2919 * @param[out] *pDst output pointer
2920 * @param[in] blockSize number of samples to process
2926 uint32_t blockSize
);
2929 * @brief Convolution of floating-point sequences.
2930 * @param[in] *pSrcA points to the first input sequence.
2931 * @param[in] srcALen length of the first input sequence.
2932 * @param[in] *pSrcB points to the second input sequence.
2933 * @param[in] srcBLen length of the second input sequence.
2934 * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
2947 * @brief Convolution of Q15 sequences.
2948 * @param[in] *pSrcA points to the first input sequence.
2949 * @param[in] srcALen length of the first input sequence.
2950 * @param[in] *pSrcB points to the second input sequence.
2951 * @param[in] srcBLen length of the second input sequence.
2952 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
2953 * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
2954 * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
2959 void arm_conv_opt_q15(
2970 * @brief Convolution of Q15 sequences.
2971 * @param[in] *pSrcA points to the first input sequence.
2972 * @param[in] srcALen length of the first input sequence.
2973 * @param[in] *pSrcB points to the second input sequence.
2974 * @param[in] srcBLen length of the second input sequence.
2975 * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
2987 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
2988 * @param[in] *pSrcA points to the first input sequence.
2989 * @param[in] srcALen length of the first input sequence.
2990 * @param[in] *pSrcB points to the second input sequence.
2991 * @param[in] srcBLen length of the second input sequence.
2992 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
2996 void arm_conv_fast_q15(
3004 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3005 * @param[in] *pSrcA points to the first input sequence.
3006 * @param[in] srcALen length of the first input sequence.
3007 * @param[in] *pSrcB points to the second input sequence.
3008 * @param[in] srcBLen length of the second input sequence.
3009 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
3010 * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3011 * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3015 void arm_conv_fast_opt_q15(
3027 * @brief Convolution of Q31 sequences.
3028 * @param[in] *pSrcA points to the first input sequence.
3029 * @param[in] srcALen length of the first input sequence.
3030 * @param[in] *pSrcB points to the second input sequence.
3031 * @param[in] srcBLen length of the second input sequence.
3032 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
3044 * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3045 * @param[in] *pSrcA points to the first input sequence.
3046 * @param[in] srcALen length of the first input sequence.
3047 * @param[in] *pSrcB points to the second input sequence.
3048 * @param[in] srcBLen length of the second input sequence.
3049 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
3053 void arm_conv_fast_q31(
3062 * @brief Convolution of Q7 sequences.
3063 * @param[in] *pSrcA points to the first input sequence.
3064 * @param[in] srcALen length of the first input sequence.
3065 * @param[in] *pSrcB points to the second input sequence.
3066 * @param[in] srcBLen length of the second input sequence.
3067 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
3068 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3069 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3073 void arm_conv_opt_q7(
3085 * @brief Convolution of Q7 sequences.
3086 * @param[in] *pSrcA points to the first input sequence.
3087 * @param[in] srcALen length of the first input sequence.
3088 * @param[in] *pSrcB points to the second input sequence.
3089 * @param[in] srcBLen length of the second input sequence.
3090 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
3103 * @brief Partial convolution of floating-point sequences.
3104 * @param[in] *pSrcA points to the first input sequence.
3105 * @param[in] srcALen length of the first input sequence.
3106 * @param[in] *pSrcB points to the second input sequence.
3107 * @param[in] srcBLen length of the second input sequence.
3108 * @param[out] *pDst points to the block of output data
3109 * @param[in] firstIndex is the first output sample to start with.
3110 * @param[in] numPoints is the number of output points to be computed.
3111 * @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].
3114 arm_status
arm_conv_partial_f32(
3120 uint32_t firstIndex
,
3121 uint32_t numPoints
);
3124 * @brief Partial convolution of Q15 sequences.
3125 * @param[in] *pSrcA points to the first input sequence.
3126 * @param[in] srcALen length of the first input sequence.
3127 * @param[in] *pSrcB points to the second input sequence.
3128 * @param[in] srcBLen length of the second input sequence.
3129 * @param[out] *pDst points to the block of output data
3130 * @param[in] firstIndex is the first output sample to start with.
3131 * @param[in] numPoints is the number of output points to be computed.
3132 * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3133 * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3134 * @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].
3137 arm_status
arm_conv_partial_opt_q15(
3143 uint32_t firstIndex
,
3150 * @brief Partial convolution of Q15 sequences.
3151 * @param[in] *pSrcA points to the first input sequence.
3152 * @param[in] srcALen length of the first input sequence.
3153 * @param[in] *pSrcB points to the second input sequence.
3154 * @param[in] srcBLen length of the second input sequence.
3155 * @param[out] *pDst points to the block of output data
3156 * @param[in] firstIndex is the first output sample to start with.
3157 * @param[in] numPoints is the number of output points to be computed.
3158 * @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].
3161 arm_status
arm_conv_partial_q15(
3167 uint32_t firstIndex
,
3168 uint32_t numPoints
);
3171 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3172 * @param[in] *pSrcA points to the first input sequence.
3173 * @param[in] srcALen length of the first input sequence.
3174 * @param[in] *pSrcB points to the second input sequence.
3175 * @param[in] srcBLen length of the second input sequence.
3176 * @param[out] *pDst points to the block of output data
3177 * @param[in] firstIndex is the first output sample to start with.
3178 * @param[in] numPoints is the number of output points to be computed.
3179 * @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].
3182 arm_status
arm_conv_partial_fast_q15(
3188 uint32_t firstIndex
,
3189 uint32_t numPoints
);
3193 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3194 * @param[in] *pSrcA points to the first input sequence.
3195 * @param[in] srcALen length of the first input sequence.
3196 * @param[in] *pSrcB points to the second input sequence.
3197 * @param[in] srcBLen length of the second input sequence.
3198 * @param[out] *pDst points to the block of output data
3199 * @param[in] firstIndex is the first output sample to start with.
3200 * @param[in] numPoints is the number of output points to be computed.
3201 * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3202 * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3203 * @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].
3206 arm_status
arm_conv_partial_fast_opt_q15(
3212 uint32_t firstIndex
,
3219 * @brief Partial convolution of Q31 sequences.
3220 * @param[in] *pSrcA points to the first input sequence.
3221 * @param[in] srcALen length of the first input sequence.
3222 * @param[in] *pSrcB points to the second input sequence.
3223 * @param[in] srcBLen length of the second input sequence.
3224 * @param[out] *pDst points to the block of output data
3225 * @param[in] firstIndex is the first output sample to start with.
3226 * @param[in] numPoints is the number of output points to be computed.
3227 * @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].
3230 arm_status
arm_conv_partial_q31(
3236 uint32_t firstIndex
,
3237 uint32_t numPoints
);
3241 * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3242 * @param[in] *pSrcA points to the first input sequence.
3243 * @param[in] srcALen length of the first input sequence.
3244 * @param[in] *pSrcB points to the second input sequence.
3245 * @param[in] srcBLen length of the second input sequence.
3246 * @param[out] *pDst points to the block of output data
3247 * @param[in] firstIndex is the first output sample to start with.
3248 * @param[in] numPoints is the number of output points to be computed.
3249 * @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].
3252 arm_status
arm_conv_partial_fast_q31(
3258 uint32_t firstIndex
,
3259 uint32_t numPoints
);
3263 * @brief Partial convolution of Q7 sequences
3264 * @param[in] *pSrcA points to the first input sequence.
3265 * @param[in] srcALen length of the first input sequence.
3266 * @param[in] *pSrcB points to the second input sequence.
3267 * @param[in] srcBLen length of the second input sequence.
3268 * @param[out] *pDst points to the block of output data
3269 * @param[in] firstIndex is the first output sample to start with.
3270 * @param[in] numPoints is the number of output points to be computed.
3271 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3272 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3273 * @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].
3276 arm_status
arm_conv_partial_opt_q7(
3282 uint32_t firstIndex
,
3289 * @brief Partial convolution of Q7 sequences.
3290 * @param[in] *pSrcA points to the first input sequence.
3291 * @param[in] srcALen length of the first input sequence.
3292 * @param[in] *pSrcB points to the second input sequence.
3293 * @param[in] srcBLen length of the second input sequence.
3294 * @param[out] *pDst points to the block of output data
3295 * @param[in] firstIndex is the first output sample to start with.
3296 * @param[in] numPoints is the number of output points to be computed.
3297 * @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].
3300 arm_status
arm_conv_partial_q7(
3306 uint32_t firstIndex
,
3307 uint32_t numPoints
);
3312 * @brief Instance structure for the Q15 FIR decimator.
3317 uint8_t M
; /**< decimation factor. */
3318 uint16_t numTaps
; /**< number of coefficients in the filter. */
3319 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
3320 q15_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3321 } arm_fir_decimate_instance_q15
;
3324 * @brief Instance structure for the Q31 FIR decimator.
3329 uint8_t M
; /**< decimation factor. */
3330 uint16_t numTaps
; /**< number of coefficients in the filter. */
3331 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
3332 q31_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3334 } arm_fir_decimate_instance_q31
;
3337 * @brief Instance structure for the floating-point FIR decimator.
3342 uint8_t M
; /**< decimation factor. */
3343 uint16_t numTaps
; /**< number of coefficients in the filter. */
3344 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
3345 float32_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3347 } arm_fir_decimate_instance_f32
;
3352 * @brief Processing function for the floating-point FIR decimator.
3353 * @param[in] *S points to an instance of the floating-point FIR decimator structure.
3354 * @param[in] *pSrc points to the block of input data.
3355 * @param[out] *pDst points to the block of output data
3356 * @param[in] blockSize number of input samples to process per call.
3360 void arm_fir_decimate_f32(
3361 const arm_fir_decimate_instance_f32
* S
,
3364 uint32_t blockSize
);
3368 * @brief Initialization function for the floating-point FIR decimator.
3369 * @param[in,out] *S points to an instance of the floating-point FIR decimator structure.
3370 * @param[in] numTaps number of coefficients in the filter.
3371 * @param[in] M decimation factor.
3372 * @param[in] *pCoeffs points to the filter coefficients.
3373 * @param[in] *pState points to the state buffer.
3374 * @param[in] blockSize number of input samples to process per call.
3375 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3376 * <code>blockSize</code> is not a multiple of <code>M</code>.
3379 arm_status
arm_fir_decimate_init_f32(
3380 arm_fir_decimate_instance_f32
* S
,
3383 float32_t
* pCoeffs
,
3385 uint32_t blockSize
);
3388 * @brief Processing function for the Q15 FIR decimator.
3389 * @param[in] *S points to an instance of the Q15 FIR decimator structure.
3390 * @param[in] *pSrc points to the block of input data.
3391 * @param[out] *pDst points to the block of output data
3392 * @param[in] blockSize number of input samples to process per call.
3396 void arm_fir_decimate_q15(
3397 const arm_fir_decimate_instance_q15
* S
,
3400 uint32_t blockSize
);
3403 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3404 * @param[in] *S points to an instance of the Q15 FIR decimator structure.
3405 * @param[in] *pSrc points to the block of input data.
3406 * @param[out] *pDst points to the block of output data
3407 * @param[in] blockSize number of input samples to process per call.
3411 void arm_fir_decimate_fast_q15(
3412 const arm_fir_decimate_instance_q15
* S
,
3415 uint32_t blockSize
);
3420 * @brief Initialization function for the Q15 FIR decimator.
3421 * @param[in,out] *S points to an instance of the Q15 FIR decimator structure.
3422 * @param[in] numTaps number of coefficients in the filter.
3423 * @param[in] M decimation factor.
3424 * @param[in] *pCoeffs points to the filter coefficients.
3425 * @param[in] *pState points to the state buffer.
3426 * @param[in] blockSize number of input samples to process per call.
3427 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3428 * <code>blockSize</code> is not a multiple of <code>M</code>.
3431 arm_status
arm_fir_decimate_init_q15(
3432 arm_fir_decimate_instance_q15
* S
,
3437 uint32_t blockSize
);
3440 * @brief Processing function for the Q31 FIR decimator.
3441 * @param[in] *S points to an instance of the Q31 FIR decimator structure.
3442 * @param[in] *pSrc points to the block of input data.
3443 * @param[out] *pDst points to the block of output data
3444 * @param[in] blockSize number of input samples to process per call.
3448 void arm_fir_decimate_q31(
3449 const arm_fir_decimate_instance_q31
* S
,
3452 uint32_t blockSize
);
3455 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3456 * @param[in] *S points to an instance of the Q31 FIR decimator structure.
3457 * @param[in] *pSrc points to the block of input data.
3458 * @param[out] *pDst points to the block of output data
3459 * @param[in] blockSize number of input samples to process per call.
3463 void arm_fir_decimate_fast_q31(
3464 arm_fir_decimate_instance_q31
* S
,
3467 uint32_t blockSize
);
3471 * @brief Initialization function for the Q31 FIR decimator.
3472 * @param[in,out] *S points to an instance of the Q31 FIR decimator structure.
3473 * @param[in] numTaps number of coefficients in the filter.
3474 * @param[in] M decimation factor.
3475 * @param[in] *pCoeffs points to the filter coefficients.
3476 * @param[in] *pState points to the state buffer.
3477 * @param[in] blockSize number of input samples to process per call.
3478 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3479 * <code>blockSize</code> is not a multiple of <code>M</code>.
3482 arm_status
arm_fir_decimate_init_q31(
3483 arm_fir_decimate_instance_q31
* S
,
3488 uint32_t blockSize
);
3493 * @brief Instance structure for the Q15 FIR interpolator.
3498 uint8_t L
; /**< upsample factor. */
3499 uint16_t phaseLength
; /**< length of each polyphase filter component. */
3500 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length L*phaseLength. */
3501 q15_t
*pState
; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3502 } arm_fir_interpolate_instance_q15
;
3505 * @brief Instance structure for the Q31 FIR interpolator.
3510 uint8_t L
; /**< upsample factor. */
3511 uint16_t phaseLength
; /**< length of each polyphase filter component. */
3512 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length L*phaseLength. */
3513 q31_t
*pState
; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3514 } arm_fir_interpolate_instance_q31
;
3517 * @brief Instance structure for the floating-point FIR interpolator.
3522 uint8_t L
; /**< upsample factor. */
3523 uint16_t phaseLength
; /**< length of each polyphase filter component. */
3524 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length L*phaseLength. */
3525 float32_t
*pState
; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
3526 } arm_fir_interpolate_instance_f32
;
3530 * @brief Processing function for the Q15 FIR interpolator.
3531 * @param[in] *S points to an instance of the Q15 FIR interpolator structure.
3532 * @param[in] *pSrc points to the block of input data.
3533 * @param[out] *pDst points to the block of output data.
3534 * @param[in] blockSize number of input samples to process per call.
3538 void arm_fir_interpolate_q15(
3539 const arm_fir_interpolate_instance_q15
* S
,
3542 uint32_t blockSize
);
3546 * @brief Initialization function for the Q15 FIR interpolator.
3547 * @param[in,out] *S points to an instance of the Q15 FIR interpolator structure.
3548 * @param[in] L upsample factor.
3549 * @param[in] numTaps number of filter coefficients in the filter.
3550 * @param[in] *pCoeffs points to the filter coefficient buffer.
3551 * @param[in] *pState points to the state buffer.
3552 * @param[in] blockSize number of input samples to process per call.
3553 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3554 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3557 arm_status
arm_fir_interpolate_init_q15(
3558 arm_fir_interpolate_instance_q15
* S
,
3563 uint32_t blockSize
);
3566 * @brief Processing function for the Q31 FIR interpolator.
3567 * @param[in] *S points to an instance of the Q15 FIR interpolator structure.
3568 * @param[in] *pSrc points to the block of input data.
3569 * @param[out] *pDst points to the block of output data.
3570 * @param[in] blockSize number of input samples to process per call.
3574 void arm_fir_interpolate_q31(
3575 const arm_fir_interpolate_instance_q31
* S
,
3578 uint32_t blockSize
);
3581 * @brief Initialization function for the Q31 FIR interpolator.
3582 * @param[in,out] *S points to an instance of the Q31 FIR interpolator structure.
3583 * @param[in] L upsample factor.
3584 * @param[in] numTaps number of filter coefficients in the filter.
3585 * @param[in] *pCoeffs points to the filter coefficient buffer.
3586 * @param[in] *pState points to the state buffer.
3587 * @param[in] blockSize number of input samples to process per call.
3588 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3589 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3592 arm_status
arm_fir_interpolate_init_q31(
3593 arm_fir_interpolate_instance_q31
* S
,
3598 uint32_t blockSize
);
3602 * @brief Processing function for the floating-point FIR interpolator.
3603 * @param[in] *S points to an instance of the floating-point FIR interpolator structure.
3604 * @param[in] *pSrc points to the block of input data.
3605 * @param[out] *pDst points to the block of output data.
3606 * @param[in] blockSize number of input samples to process per call.
3610 void arm_fir_interpolate_f32(
3611 const arm_fir_interpolate_instance_f32
* S
,
3614 uint32_t blockSize
);
3617 * @brief Initialization function for the floating-point FIR interpolator.
3618 * @param[in,out] *S points to an instance of the floating-point FIR interpolator structure.
3619 * @param[in] L upsample factor.
3620 * @param[in] numTaps number of filter coefficients in the filter.
3621 * @param[in] *pCoeffs points to the filter coefficient buffer.
3622 * @param[in] *pState points to the state buffer.
3623 * @param[in] blockSize number of input samples to process per call.
3624 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3625 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3628 arm_status
arm_fir_interpolate_init_f32(
3629 arm_fir_interpolate_instance_f32
* S
,
3632 float32_t
* pCoeffs
,
3634 uint32_t blockSize
);
3637 * @brief Instance structure for the high precision Q31 Biquad cascade filter.
3642 uint8_t numStages
; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3643 q63_t
*pState
; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3644 q31_t
*pCoeffs
; /**< points to the array of coefficients. The array is of length 5*numStages. */
3645 uint8_t postShift
; /**< additional shift, in bits, applied to each output sample. */
3647 } arm_biquad_cas_df1_32x64_ins_q31
;
3651 * @param[in] *S points to an instance of the high precision Q31 Biquad cascade filter structure.
3652 * @param[in] *pSrc points to the block of input data.
3653 * @param[out] *pDst points to the block of output data
3654 * @param[in] blockSize number of samples to process.
3658 void arm_biquad_cas_df1_32x64_q31(
3659 const arm_biquad_cas_df1_32x64_ins_q31
* S
,
3662 uint32_t blockSize
);
3666 * @param[in,out] *S points to an instance of the high precision Q31 Biquad cascade filter structure.
3667 * @param[in] numStages number of 2nd order stages in the filter.
3668 * @param[in] *pCoeffs points to the filter coefficients.
3669 * @param[in] *pState points to the state buffer.
3670 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
3674 void arm_biquad_cas_df1_32x64_init_q31(
3675 arm_biquad_cas_df1_32x64_ins_q31
* S
,
3684 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3689 uint8_t numStages
; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3690 float32_t
*pState
; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3691 float32_t
*pCoeffs
; /**< points to the array of coefficients. The array is of length 5*numStages. */
3692 } arm_biquad_cascade_df2T_instance_f32
;
3696 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3697 * @param[in] *S points to an instance of the filter data structure.
3698 * @param[in] *pSrc points to the block of input data.
3699 * @param[out] *pDst points to the block of output data
3700 * @param[in] blockSize number of samples to process.
3704 void arm_biquad_cascade_df2T_f32(
3705 const arm_biquad_cascade_df2T_instance_f32
* S
,
3708 uint32_t blockSize
);
3712 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3713 * @param[in,out] *S points to an instance of the filter data structure.
3714 * @param[in] numStages number of 2nd order stages in the filter.
3715 * @param[in] *pCoeffs points to the filter coefficients.
3716 * @param[in] *pState points to the state buffer.
3720 void arm_biquad_cascade_df2T_init_f32(
3721 arm_biquad_cascade_df2T_instance_f32
* S
,
3723 float32_t
* pCoeffs
,
3724 float32_t
* pState
);
3729 * @brief Instance structure for the Q15 FIR lattice filter.
3734 uint16_t numStages
; /**< number of filter stages. */
3735 q15_t
*pState
; /**< points to the state variable array. The array is of length numStages. */
3736 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numStages. */
3737 } arm_fir_lattice_instance_q15
;
3740 * @brief Instance structure for the Q31 FIR lattice filter.
3745 uint16_t numStages
; /**< number of filter stages. */
3746 q31_t
*pState
; /**< points to the state variable array. The array is of length numStages. */
3747 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numStages. */
3748 } arm_fir_lattice_instance_q31
;
3751 * @brief Instance structure for the floating-point FIR lattice filter.
3756 uint16_t numStages
; /**< number of filter stages. */
3757 float32_t
*pState
; /**< points to the state variable array. The array is of length numStages. */
3758 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numStages. */
3759 } arm_fir_lattice_instance_f32
;
3762 * @brief Initialization function for the Q15 FIR lattice filter.
3763 * @param[in] *S points to an instance of the Q15 FIR lattice structure.
3764 * @param[in] numStages number of filter stages.
3765 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
3766 * @param[in] *pState points to the state buffer. The array is of length numStages.
3770 void arm_fir_lattice_init_q15(
3771 arm_fir_lattice_instance_q15
* S
,
3778 * @brief Processing function for the Q15 FIR lattice filter.
3779 * @param[in] *S points to an instance of the Q15 FIR lattice structure.
3780 * @param[in] *pSrc points to the block of input data.
3781 * @param[out] *pDst points to the block of output data.
3782 * @param[in] blockSize number of samples to process.
3785 void arm_fir_lattice_q15(
3786 const arm_fir_lattice_instance_q15
* S
,
3789 uint32_t blockSize
);
3792 * @brief Initialization function for the Q31 FIR lattice filter.
3793 * @param[in] *S points to an instance of the Q31 FIR lattice structure.
3794 * @param[in] numStages number of filter stages.
3795 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
3796 * @param[in] *pState points to the state buffer. The array is of length numStages.
3800 void arm_fir_lattice_init_q31(
3801 arm_fir_lattice_instance_q31
* S
,
3808 * @brief Processing function for the Q31 FIR lattice filter.
3809 * @param[in] *S points to an instance of the Q31 FIR lattice structure.
3810 * @param[in] *pSrc points to the block of input data.
3811 * @param[out] *pDst points to the block of output data
3812 * @param[in] blockSize number of samples to process.
3816 void arm_fir_lattice_q31(
3817 const arm_fir_lattice_instance_q31
* S
,
3820 uint32_t blockSize
);
3823 * @brief Initialization function for the floating-point FIR lattice filter.
3824 * @param[in] *S points to an instance of the floating-point FIR lattice structure.
3825 * @param[in] numStages number of filter stages.
3826 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
3827 * @param[in] *pState points to the state buffer. The array is of length numStages.
3831 void arm_fir_lattice_init_f32(
3832 arm_fir_lattice_instance_f32
* S
,
3834 float32_t
* pCoeffs
,
3835 float32_t
* pState
);
3838 * @brief Processing function for the floating-point FIR lattice filter.
3839 * @param[in] *S points to an instance of the floating-point FIR lattice structure.
3840 * @param[in] *pSrc points to the block of input data.
3841 * @param[out] *pDst points to the block of output data
3842 * @param[in] blockSize number of samples to process.
3846 void arm_fir_lattice_f32(
3847 const arm_fir_lattice_instance_f32
* S
,
3850 uint32_t blockSize
);
3853 * @brief Instance structure for the Q15 IIR lattice filter.
3857 uint16_t numStages
; /**< number of stages in the filter. */
3858 q15_t
*pState
; /**< points to the state variable array. The array is of length numStages+blockSize. */
3859 q15_t
*pkCoeffs
; /**< points to the reflection coefficient array. The array is of length numStages. */
3860 q15_t
*pvCoeffs
; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3861 } arm_iir_lattice_instance_q15
;
3864 * @brief Instance structure for the Q31 IIR lattice filter.
3868 uint16_t numStages
; /**< number of stages in the filter. */
3869 q31_t
*pState
; /**< points to the state variable array. The array is of length numStages+blockSize. */
3870 q31_t
*pkCoeffs
; /**< points to the reflection coefficient array. The array is of length numStages. */
3871 q31_t
*pvCoeffs
; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3872 } arm_iir_lattice_instance_q31
;
3875 * @brief Instance structure for the floating-point IIR lattice filter.
3879 uint16_t numStages
; /**< number of stages in the filter. */
3880 float32_t
*pState
; /**< points to the state variable array. The array is of length numStages+blockSize. */
3881 float32_t
*pkCoeffs
; /**< points to the reflection coefficient array. The array is of length numStages. */
3882 float32_t
*pvCoeffs
; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3883 } arm_iir_lattice_instance_f32
;
3886 * @brief Processing function for the floating-point IIR lattice filter.
3887 * @param[in] *S points to an instance of the floating-point IIR lattice structure.
3888 * @param[in] *pSrc points to the block of input data.
3889 * @param[out] *pDst points to the block of output data.
3890 * @param[in] blockSize number of samples to process.
3894 void arm_iir_lattice_f32(
3895 const arm_iir_lattice_instance_f32
* S
,
3898 uint32_t blockSize
);
3901 * @brief Initialization function for the floating-point IIR lattice filter.
3902 * @param[in] *S points to an instance of the floating-point IIR lattice structure.
3903 * @param[in] numStages number of stages in the filter.
3904 * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3905 * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3906 * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize-1.
3907 * @param[in] blockSize number of samples to process.
3911 void arm_iir_lattice_init_f32(
3912 arm_iir_lattice_instance_f32
* S
,
3914 float32_t
* pkCoeffs
,
3915 float32_t
* pvCoeffs
,
3917 uint32_t blockSize
);
3921 * @brief Processing function for the Q31 IIR lattice filter.
3922 * @param[in] *S points to an instance of the Q31 IIR lattice structure.
3923 * @param[in] *pSrc points to the block of input data.
3924 * @param[out] *pDst points to the block of output data.
3925 * @param[in] blockSize number of samples to process.
3929 void arm_iir_lattice_q31(
3930 const arm_iir_lattice_instance_q31
* S
,
3933 uint32_t blockSize
);
3937 * @brief Initialization function for the Q31 IIR lattice filter.
3938 * @param[in] *S points to an instance of the Q31 IIR lattice structure.
3939 * @param[in] numStages number of stages in the filter.
3940 * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3941 * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3942 * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize.
3943 * @param[in] blockSize number of samples to process.
3947 void arm_iir_lattice_init_q31(
3948 arm_iir_lattice_instance_q31
* S
,
3953 uint32_t blockSize
);
3957 * @brief Processing function for the Q15 IIR lattice filter.
3958 * @param[in] *S points to an instance of the Q15 IIR lattice structure.
3959 * @param[in] *pSrc points to the block of input data.
3960 * @param[out] *pDst points to the block of output data.
3961 * @param[in] blockSize number of samples to process.
3965 void arm_iir_lattice_q15(
3966 const arm_iir_lattice_instance_q15
* S
,
3969 uint32_t blockSize
);
3973 * @brief Initialization function for the Q15 IIR lattice filter.
3974 * @param[in] *S points to an instance of the fixed-point Q15 IIR lattice structure.
3975 * @param[in] numStages number of stages in the filter.
3976 * @param[in] *pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
3977 * @param[in] *pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
3978 * @param[in] *pState points to state buffer. The array is of length numStages+blockSize.
3979 * @param[in] blockSize number of samples to process per call.
3983 void arm_iir_lattice_init_q15(
3984 arm_iir_lattice_instance_q15
* S
,
3989 uint32_t blockSize
);
3992 * @brief Instance structure for the floating-point LMS filter.
3997 uint16_t numTaps
; /**< number of coefficients in the filter. */
3998 float32_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3999 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
4000 float32_t mu
; /**< step size that controls filter coefficient updates. */
4001 } arm_lms_instance_f32
;
4004 * @brief Processing function for floating-point LMS filter.
4005 * @param[in] *S points to an instance of the floating-point LMS filter structure.
4006 * @param[in] *pSrc points to the block of input data.
4007 * @param[in] *pRef points to the block of reference data.
4008 * @param[out] *pOut points to the block of output data.
4009 * @param[out] *pErr points to the block of error data.
4010 * @param[in] blockSize number of samples to process.
4015 const arm_lms_instance_f32
* S
,
4020 uint32_t blockSize
);
4023 * @brief Initialization function for floating-point LMS filter.
4024 * @param[in] *S points to an instance of the floating-point LMS filter structure.
4025 * @param[in] numTaps number of filter coefficients.
4026 * @param[in] *pCoeffs points to the coefficient buffer.
4027 * @param[in] *pState points to state buffer.
4028 * @param[in] mu step size that controls filter coefficient updates.
4029 * @param[in] blockSize number of samples to process.
4033 void arm_lms_init_f32(
4034 arm_lms_instance_f32
* S
,
4036 float32_t
* pCoeffs
,
4039 uint32_t blockSize
);
4042 * @brief Instance structure for the Q15 LMS filter.
4047 uint16_t numTaps
; /**< number of coefficients in the filter. */
4048 q15_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4049 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
4050 q15_t mu
; /**< step size that controls filter coefficient updates. */
4051 uint32_t postShift
; /**< bit shift applied to coefficients. */
4052 } arm_lms_instance_q15
;
4056 * @brief Initialization function for the Q15 LMS filter.
4057 * @param[in] *S points to an instance of the Q15 LMS filter structure.
4058 * @param[in] numTaps number of filter coefficients.
4059 * @param[in] *pCoeffs points to the coefficient buffer.
4060 * @param[in] *pState points to the state buffer.
4061 * @param[in] mu step size that controls filter coefficient updates.
4062 * @param[in] blockSize number of samples to process.
4063 * @param[in] postShift bit shift applied to coefficients.
4067 void arm_lms_init_q15(
4068 arm_lms_instance_q15
* S
,
4074 uint32_t postShift
);
4077 * @brief Processing function for Q15 LMS filter.
4078 * @param[in] *S points to an instance of the Q15 LMS filter structure.
4079 * @param[in] *pSrc points to the block of input data.
4080 * @param[in] *pRef points to the block of reference data.
4081 * @param[out] *pOut points to the block of output data.
4082 * @param[out] *pErr points to the block of error data.
4083 * @param[in] blockSize number of samples to process.
4088 const arm_lms_instance_q15
* S
,
4093 uint32_t blockSize
);
4097 * @brief Instance structure for the Q31 LMS filter.
4102 uint16_t numTaps
; /**< number of coefficients in the filter. */
4103 q31_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4104 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
4105 q31_t mu
; /**< step size that controls filter coefficient updates. */
4106 uint32_t postShift
; /**< bit shift applied to coefficients. */
4108 } arm_lms_instance_q31
;
4111 * @brief Processing function for Q31 LMS filter.
4112 * @param[in] *S points to an instance of the Q15 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.
4122 const arm_lms_instance_q31
* S
,
4127 uint32_t blockSize
);
4130 * @brief Initialization function for Q31 LMS filter.
4131 * @param[in] *S points to an instance of the Q31 LMS filter structure.
4132 * @param[in] numTaps number of filter coefficients.
4133 * @param[in] *pCoeffs points to coefficient buffer.
4134 * @param[in] *pState points to state buffer.
4135 * @param[in] mu step size that controls filter coefficient updates.
4136 * @param[in] blockSize number of samples to process.
4137 * @param[in] postShift bit shift applied to coefficients.
4141 void arm_lms_init_q31(
4142 arm_lms_instance_q31
* S
,
4148 uint32_t postShift
);
4151 * @brief Instance structure for the floating-point normalized LMS filter.
4156 uint16_t numTaps
; /**< number of coefficients in the filter. */
4157 float32_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4158 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
4159 float32_t mu
; /**< step size that control filter coefficient updates. */
4160 float32_t energy
; /**< saves previous frame energy. */
4161 float32_t x0
; /**< saves previous input sample. */
4162 } arm_lms_norm_instance_f32
;
4165 * @brief Processing function for floating-point normalized LMS filter.
4166 * @param[in] *S points to an instance of the floating-point normalized LMS filter structure.
4167 * @param[in] *pSrc points to the block of input data.
4168 * @param[in] *pRef points to the block of reference data.
4169 * @param[out] *pOut points to the block of output data.
4170 * @param[out] *pErr points to the block of error data.
4171 * @param[in] blockSize number of samples to process.
4175 void arm_lms_norm_f32(
4176 arm_lms_norm_instance_f32
* S
,
4181 uint32_t blockSize
);
4184 * @brief Initialization function for floating-point normalized LMS filter.
4185 * @param[in] *S points to an instance of the floating-point LMS filter structure.
4186 * @param[in] numTaps number of filter coefficients.
4187 * @param[in] *pCoeffs points to coefficient buffer.
4188 * @param[in] *pState points to state buffer.
4189 * @param[in] mu step size that controls filter coefficient updates.
4190 * @param[in] blockSize number of samples to process.
4194 void arm_lms_norm_init_f32(
4195 arm_lms_norm_instance_f32
* S
,
4197 float32_t
* pCoeffs
,
4200 uint32_t blockSize
);
4204 * @brief Instance structure for the Q31 normalized LMS filter.
4208 uint16_t numTaps
; /**< number of coefficients in the filter. */
4209 q31_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4210 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
4211 q31_t mu
; /**< step size that controls filter coefficient updates. */
4212 uint8_t postShift
; /**< bit shift applied to coefficients. */
4213 q31_t
*recipTable
; /**< points to the reciprocal initial value table. */
4214 q31_t energy
; /**< saves previous frame energy. */
4215 q31_t x0
; /**< saves previous input sample. */
4216 } arm_lms_norm_instance_q31
;
4219 * @brief Processing function for Q31 normalized LMS filter.
4220 * @param[in] *S points to an instance of the Q31 normalized LMS filter structure.
4221 * @param[in] *pSrc points to the block of input data.
4222 * @param[in] *pRef points to the block of reference data.
4223 * @param[out] *pOut points to the block of output data.
4224 * @param[out] *pErr points to the block of error data.
4225 * @param[in] blockSize number of samples to process.
4229 void arm_lms_norm_q31(
4230 arm_lms_norm_instance_q31
* S
,
4235 uint32_t blockSize
);
4238 * @brief Initialization function for Q31 normalized LMS filter.
4239 * @param[in] *S points to an instance of the Q31 normalized LMS filter structure.
4240 * @param[in] numTaps number of filter coefficients.
4241 * @param[in] *pCoeffs points to coefficient buffer.
4242 * @param[in] *pState points to state buffer.
4243 * @param[in] mu step size that controls filter coefficient updates.
4244 * @param[in] blockSize number of samples to process.
4245 * @param[in] postShift bit shift applied to coefficients.
4249 void arm_lms_norm_init_q31(
4250 arm_lms_norm_instance_q31
* S
,
4259 * @brief Instance structure for the Q15 normalized LMS filter.
4264 uint16_t numTaps
; /**< Number of coefficients in the filter. */
4265 q15_t
*pState
; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4266 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps. */
4267 q15_t mu
; /**< step size that controls filter coefficient updates. */
4268 uint8_t postShift
; /**< bit shift applied to coefficients. */
4269 q15_t
*recipTable
; /**< Points to the reciprocal initial value table. */
4270 q15_t energy
; /**< saves previous frame energy. */
4271 q15_t x0
; /**< saves previous input sample. */
4272 } arm_lms_norm_instance_q15
;
4275 * @brief Processing function for Q15 normalized LMS filter.
4276 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
4277 * @param[in] *pSrc points to the block of input data.
4278 * @param[in] *pRef points to the block of reference data.
4279 * @param[out] *pOut points to the block of output data.
4280 * @param[out] *pErr points to the block of error data.
4281 * @param[in] blockSize number of samples to process.
4285 void arm_lms_norm_q15(
4286 arm_lms_norm_instance_q15
* S
,
4291 uint32_t blockSize
);
4295 * @brief Initialization function for Q15 normalized LMS filter.
4296 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
4297 * @param[in] numTaps number of filter coefficients.
4298 * @param[in] *pCoeffs points to coefficient buffer.
4299 * @param[in] *pState points to state buffer.
4300 * @param[in] mu step size that controls filter coefficient updates.
4301 * @param[in] blockSize number of samples to process.
4302 * @param[in] postShift bit shift applied to coefficients.
4306 void arm_lms_norm_init_q15(
4307 arm_lms_norm_instance_q15
* S
,
4316 * @brief Correlation of floating-point sequences.
4317 * @param[in] *pSrcA points to the first input sequence.
4318 * @param[in] srcALen length of the first input sequence.
4319 * @param[in] *pSrcB points to the second input sequence.
4320 * @param[in] srcBLen length of the second input sequence.
4321 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4325 void arm_correlate_f32(
4334 * @brief Correlation of Q15 sequences
4335 * @param[in] *pSrcA points to the first input sequence.
4336 * @param[in] srcALen length of the first input sequence.
4337 * @param[in] *pSrcB points to the second input sequence.
4338 * @param[in] srcBLen length of the second input sequence.
4339 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4340 * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4343 void arm_correlate_opt_q15(
4353 * @brief Correlation of Q15 sequences.
4354 * @param[in] *pSrcA points to the first input sequence.
4355 * @param[in] srcALen length of the first input sequence.
4356 * @param[in] *pSrcB points to the second input sequence.
4357 * @param[in] srcBLen length of the second input sequence.
4358 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4362 void arm_correlate_q15(
4370 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4371 * @param[in] *pSrcA points to the first input sequence.
4372 * @param[in] srcALen length of the first input sequence.
4373 * @param[in] *pSrcB points to the second input sequence.
4374 * @param[in] srcBLen length of the second input sequence.
4375 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4379 void arm_correlate_fast_q15(
4389 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4390 * @param[in] *pSrcA points to the first input sequence.
4391 * @param[in] srcALen length of the first input sequence.
4392 * @param[in] *pSrcB points to the second input sequence.
4393 * @param[in] srcBLen length of the second input sequence.
4394 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4395 * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4399 void arm_correlate_fast_opt_q15(
4408 * @brief Correlation of Q31 sequences.
4409 * @param[in] *pSrcA points to the first input sequence.
4410 * @param[in] srcALen length of the first input sequence.
4411 * @param[in] *pSrcB points to the second input sequence.
4412 * @param[in] srcBLen length of the second input sequence.
4413 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4417 void arm_correlate_q31(
4425 * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
4426 * @param[in] *pSrcA points to the first input sequence.
4427 * @param[in] srcALen length of the first input sequence.
4428 * @param[in] *pSrcB points to the second input sequence.
4429 * @param[in] srcBLen length of the second input sequence.
4430 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4434 void arm_correlate_fast_q31(
4444 * @brief Correlation of Q7 sequences.
4445 * @param[in] *pSrcA points to the first input sequence.
4446 * @param[in] srcALen length of the first input sequence.
4447 * @param[in] *pSrcB points to the second input sequence.
4448 * @param[in] srcBLen length of the second input sequence.
4449 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4450 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4451 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
4455 void arm_correlate_opt_q7(
4466 * @brief Correlation of Q7 sequences.
4467 * @param[in] *pSrcA points to the first input sequence.
4468 * @param[in] srcALen length of the first input sequence.
4469 * @param[in] *pSrcB points to the second input sequence.
4470 * @param[in] srcBLen length of the second input sequence.
4471 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4475 void arm_correlate_q7(
4484 * @brief Instance structure for the floating-point sparse FIR filter.
4488 uint16_t numTaps
; /**< number of coefficients in the filter. */
4489 uint16_t stateIndex
; /**< state buffer index. Points to the oldest sample in the state buffer. */
4490 float32_t
*pState
; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4491 float32_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
4492 uint16_t maxDelay
; /**< maximum offset specified by the pTapDelay array. */
4493 int32_t *pTapDelay
; /**< points to the array of delay values. The array is of length numTaps. */
4494 } arm_fir_sparse_instance_f32
;
4497 * @brief Instance structure for the Q31 sparse FIR filter.
4502 uint16_t numTaps
; /**< number of coefficients in the filter. */
4503 uint16_t stateIndex
; /**< state buffer index. Points to the oldest sample in the state buffer. */
4504 q31_t
*pState
; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4505 q31_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
4506 uint16_t maxDelay
; /**< maximum offset specified by the pTapDelay array. */
4507 int32_t *pTapDelay
; /**< points to the array of delay values. The array is of length numTaps. */
4508 } arm_fir_sparse_instance_q31
;
4511 * @brief Instance structure for the Q15 sparse FIR filter.
4516 uint16_t numTaps
; /**< number of coefficients in the filter. */
4517 uint16_t stateIndex
; /**< state buffer index. Points to the oldest sample in the state buffer. */
4518 q15_t
*pState
; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4519 q15_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
4520 uint16_t maxDelay
; /**< maximum offset specified by the pTapDelay array. */
4521 int32_t *pTapDelay
; /**< points to the array of delay values. The array is of length numTaps. */
4522 } arm_fir_sparse_instance_q15
;
4525 * @brief Instance structure for the Q7 sparse FIR filter.
4530 uint16_t numTaps
; /**< number of coefficients in the filter. */
4531 uint16_t stateIndex
; /**< state buffer index. Points to the oldest sample in the state buffer. */
4532 q7_t
*pState
; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4533 q7_t
*pCoeffs
; /**< points to the coefficient array. The array is of length numTaps.*/
4534 uint16_t maxDelay
; /**< maximum offset specified by the pTapDelay array. */
4535 int32_t *pTapDelay
; /**< points to the array of delay values. The array is of length numTaps. */
4536 } arm_fir_sparse_instance_q7
;
4539 * @brief Processing function for the floating-point sparse FIR filter.
4540 * @param[in] *S points to an instance of the floating-point sparse FIR structure.
4541 * @param[in] *pSrc points to the block of input data.
4542 * @param[out] *pDst points to the block of output data
4543 * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
4544 * @param[in] blockSize number of input samples to process per call.
4548 void arm_fir_sparse_f32(
4549 arm_fir_sparse_instance_f32
* S
,
4552 float32_t
* pScratchIn
,
4553 uint32_t blockSize
);
4556 * @brief Initialization function for the floating-point sparse FIR filter.
4557 * @param[in,out] *S points to an instance of the floating-point sparse FIR structure.
4558 * @param[in] numTaps number of nonzero coefficients in the filter.
4559 * @param[in] *pCoeffs points to the array of filter coefficients.
4560 * @param[in] *pState points to the state buffer.
4561 * @param[in] *pTapDelay points to the array of offset times.
4562 * @param[in] maxDelay maximum offset time supported.
4563 * @param[in] blockSize number of samples that will be processed per block.
4567 void arm_fir_sparse_init_f32(
4568 arm_fir_sparse_instance_f32
* S
,
4570 float32_t
* pCoeffs
,
4572 int32_t * pTapDelay
,
4574 uint32_t blockSize
);
4577 * @brief Processing function for the Q31 sparse FIR filter.
4578 * @param[in] *S points to an instance of the Q31 sparse FIR structure.
4579 * @param[in] *pSrc points to the block of input data.
4580 * @param[out] *pDst points to the block of output data
4581 * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
4582 * @param[in] blockSize number of input samples to process per call.
4586 void arm_fir_sparse_q31(
4587 arm_fir_sparse_instance_q31
* S
,
4591 uint32_t blockSize
);
4594 * @brief Initialization function for the Q31 sparse FIR filter.
4595 * @param[in,out] *S points to an instance of the Q31 sparse FIR structure.
4596 * @param[in] numTaps number of nonzero coefficients in the filter.
4597 * @param[in] *pCoeffs points to the array of filter coefficients.
4598 * @param[in] *pState points to the state buffer.
4599 * @param[in] *pTapDelay points to the array of offset times.
4600 * @param[in] maxDelay maximum offset time supported.
4601 * @param[in] blockSize number of samples that will be processed per block.
4605 void arm_fir_sparse_init_q31(
4606 arm_fir_sparse_instance_q31
* S
,
4610 int32_t * pTapDelay
,
4612 uint32_t blockSize
);
4615 * @brief Processing function for the Q15 sparse FIR filter.
4616 * @param[in] *S points to an instance of the Q15 sparse FIR structure.
4617 * @param[in] *pSrc points to the block of input data.
4618 * @param[out] *pDst points to the block of output data
4619 * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
4620 * @param[in] *pScratchOut points to a temporary buffer of size blockSize.
4621 * @param[in] blockSize number of input samples to process per call.
4625 void arm_fir_sparse_q15(
4626 arm_fir_sparse_instance_q15
* S
,
4630 q31_t
* pScratchOut
,
4631 uint32_t blockSize
);
4635 * @brief Initialization function for the Q15 sparse FIR filter.
4636 * @param[in,out] *S points to an instance of the Q15 sparse FIR structure.
4637 * @param[in] numTaps number of nonzero coefficients in the filter.
4638 * @param[in] *pCoeffs points to the array of filter coefficients.
4639 * @param[in] *pState points to the state buffer.
4640 * @param[in] *pTapDelay points to the array of offset times.
4641 * @param[in] maxDelay maximum offset time supported.
4642 * @param[in] blockSize number of samples that will be processed per block.
4646 void arm_fir_sparse_init_q15(
4647 arm_fir_sparse_instance_q15
* S
,
4651 int32_t * pTapDelay
,
4653 uint32_t blockSize
);
4656 * @brief Processing function for the Q7 sparse FIR filter.
4657 * @param[in] *S points to an instance of the Q7 sparse FIR structure.
4658 * @param[in] *pSrc points to the block of input data.
4659 * @param[out] *pDst points to the block of output data
4660 * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
4661 * @param[in] *pScratchOut points to a temporary buffer of size blockSize.
4662 * @param[in] blockSize number of input samples to process per call.
4666 void arm_fir_sparse_q7(
4667 arm_fir_sparse_instance_q7
* S
,
4671 q31_t
* pScratchOut
,
4672 uint32_t blockSize
);
4675 * @brief Initialization function for the Q7 sparse FIR filter.
4676 * @param[in,out] *S points to an instance of the Q7 sparse FIR structure.
4677 * @param[in] numTaps number of nonzero coefficients in the filter.
4678 * @param[in] *pCoeffs points to the array of filter coefficients.
4679 * @param[in] *pState points to the state buffer.
4680 * @param[in] *pTapDelay points to the array of offset times.
4681 * @param[in] maxDelay maximum offset time supported.
4682 * @param[in] blockSize number of samples that will be processed per block.
4686 void arm_fir_sparse_init_q7(
4687 arm_fir_sparse_instance_q7
* S
,
4691 int32_t * pTapDelay
,
4693 uint32_t blockSize
);
4697 * @brief Floating-point sin_cos function.
4698 * @param[in] theta input value in degrees
4699 * @param[out] *pSinVal points to the processed sine output.
4700 * @param[out] *pCosVal points to the processed cos output.
4704 void arm_sin_cos_f32(
4706 float32_t
* pSinVal
,
4707 float32_t
* pCcosVal
);
4710 * @brief Q31 sin_cos function.
4711 * @param[in] theta scaled input value in degrees
4712 * @param[out] *pSinVal points to the processed sine output.
4713 * @param[out] *pCosVal points to the processed cosine output.
4717 void arm_sin_cos_q31(
4724 * @brief Floating-point complex conjugate.
4725 * @param[in] *pSrc points to the input vector
4726 * @param[out] *pDst points to the output vector
4727 * @param[in] numSamples number of complex samples in each vector
4731 void arm_cmplx_conj_f32(
4734 uint32_t numSamples
);
4737 * @brief Q31 complex conjugate.
4738 * @param[in] *pSrc points to the input vector
4739 * @param[out] *pDst points to the output vector
4740 * @param[in] numSamples number of complex samples in each vector
4744 void arm_cmplx_conj_q31(
4747 uint32_t numSamples
);
4750 * @brief Q15 complex conjugate.
4751 * @param[in] *pSrc points to the input vector
4752 * @param[out] *pDst points to the output vector
4753 * @param[in] numSamples number of complex samples in each vector
4757 void arm_cmplx_conj_q15(
4760 uint32_t numSamples
);
4765 * @brief Floating-point complex magnitude squared
4766 * @param[in] *pSrc points to the complex input vector
4767 * @param[out] *pDst points to the real output vector
4768 * @param[in] numSamples number of complex samples in the input vector
4772 void arm_cmplx_mag_squared_f32(
4775 uint32_t numSamples
);
4778 * @brief Q31 complex magnitude squared
4779 * @param[in] *pSrc points to the complex input vector
4780 * @param[out] *pDst points to the real output vector
4781 * @param[in] numSamples number of complex samples in the input vector
4785 void arm_cmplx_mag_squared_q31(
4788 uint32_t numSamples
);
4791 * @brief Q15 complex magnitude squared
4792 * @param[in] *pSrc points to the complex input vector
4793 * @param[out] *pDst points to the real output vector
4794 * @param[in] numSamples number of complex samples in the input vector
4798 void arm_cmplx_mag_squared_q15(
4801 uint32_t numSamples
);
4805 * @ingroup groupController
4809 * @defgroup PID PID Motor Control
4811 * A Proportional Integral Derivative (PID) controller is a generic feedback control
4812 * loop mechanism widely used in industrial control systems.
4813 * A PID controller is the most commonly used type of feedback controller.
4815 * This set of functions implements (PID) controllers
4816 * for Q15, Q31, and floating-point data types. The functions operate on a single sample
4817 * of data and each call to the function returns a single processed value.
4818 * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
4819 * is the input sample value. The functions return the output value.
4823 * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
4825 * A1 = (-Kp ) - (2 * Kd )
4829 * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
4832 * \image html PID.gif "Proportional Integral Derivative Controller"
4835 * The PID controller calculates an "error" value as the difference between
4836 * the measured output and the reference input.
4837 * The controller attempts to minimize the error by adjusting the process control inputs.
4838 * The proportional value determines the reaction to the current error,
4839 * the integral value determines the reaction based on the sum of recent errors,
4840 * and the derivative value determines the reaction based on the rate at which the error has been changing.
4842 * \par Instance Structure
4843 * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
4844 * A separate instance structure must be defined for each PID Controller.
4845 * There are separate instance structure declarations for each of the 3 supported data types.
4847 * \par Reset Functions
4848 * There is also an associated reset function for each data type which clears the state array.
4850 * \par Initialization Functions
4851 * There is also an associated initialization function for each data type.
4852 * The initialization function performs the following operations:
4853 * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
4854 * - Zeros out the values in the state buffer.
4857 * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
4859 * \par Fixed-Point Behavior
4860 * Care must be taken when using the fixed-point versions of the PID Controller functions.
4861 * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
4862 * Refer to the function specific documentation below for usage guidelines.
4871 * @brief Process function for the floating-point PID Control.
4872 * @param[in,out] *S is an instance of the floating-point PID Control structure
4873 * @param[in] in input sample to process
4874 * @return out processed output sample.
4878 static __INLINE float32_t
arm_pid_f32(
4879 arm_pid_instance_f32
* S
,
4884 /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
4885 out
= (S
->A0
* in
) +
4886 (S
->A1
* S
->state
[0]) + (S
->A2
* S
->state
[1]) + (S
->state
[2]);
4889 S
->state
[1] = S
->state
[0];
4893 /* return to application */
4899 * @brief Process function for the Q31 PID Control.
4900 * @param[in,out] *S points to an instance of the Q31 PID Control structure
4901 * @param[in] in input sample to process
4902 * @return out processed output sample.
4904 * <b>Scaling and Overflow Behavior:</b>
4906 * The function is implemented using an internal 64-bit accumulator.
4907 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
4908 * Thus, if the accumulator result overflows it wraps around rather than clip.
4909 * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
4910 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
4913 static __INLINE q31_t
arm_pid_q31(
4914 arm_pid_instance_q31
* S
,
4920 /* acc = A0 * x[n] */
4921 acc
= (q63_t
) S
->A0
* in
;
4923 /* acc += A1 * x[n-1] */
4924 acc
+= (q63_t
) S
->A1
* S
->state
[0];
4926 /* acc += A2 * x[n-2] */
4927 acc
+= (q63_t
) S
->A2
* S
->state
[1];
4929 /* convert output to 1.31 format to add y[n-1] */
4930 out
= (q31_t
) (acc
>> 31u);
4936 S
->state
[1] = S
->state
[0];
4940 /* return to application */
4946 * @brief Process function for the Q15 PID Control.
4947 * @param[in,out] *S points to an instance of the Q15 PID Control structure
4948 * @param[in] in input sample to process
4949 * @return out processed output sample.
4951 * <b>Scaling and Overflow Behavior:</b>
4953 * The function is implemented using a 64-bit internal accumulator.
4954 * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
4955 * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
4956 * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
4957 * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
4958 * Lastly, the accumulator is saturated to yield a result in 1.15 format.
4961 static __INLINE q15_t
arm_pid_q15(
4962 arm_pid_instance_q15
* S
,
4968 #ifndef ARM_MATH_CM0_FAMILY
4969 __SIMD32_TYPE
*vstate
;
4971 /* Implementation of PID controller */
4973 /* acc = A0 * x[n] */
4974 acc
= (q31_t
) __SMUAD(S
->A0
, in
);
4976 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4977 vstate
= __SIMD32_CONST(S
->state
);
4978 acc
= __SMLALD(S
->A1
, (q31_t
) *vstate
, acc
);
4981 /* acc = A0 * x[n] */
4982 acc
= ((q31_t
) S
->A0
) * in
;
4984 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4985 acc
+= (q31_t
) S
->A1
* S
->state
[0];
4986 acc
+= (q31_t
) S
->A2
* S
->state
[1];
4991 acc
+= (q31_t
) S
->state
[2] << 15;
4993 /* saturate the output */
4994 out
= (q15_t
) (__SSAT((acc
>> 15), 16));
4997 S
->state
[1] = S
->state
[0];
5001 /* return to application */
5007 * @} end of PID group
5012 * @brief Floating-point matrix inverse.
5013 * @param[in] *src points to the instance of the input floating-point matrix structure.
5014 * @param[out] *dst points to the instance of the output floating-point matrix structure.
5015 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
5016 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
5019 arm_status
arm_mat_inverse_f32(
5020 const arm_matrix_instance_f32
* src
,
5021 arm_matrix_instance_f32
* dst
);
5026 * @ingroup groupController
5031 * @defgroup clarke Vector Clarke Transform
5032 * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
5033 * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
5034 * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
5035 * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
5036 * \image html clarke.gif Stator current space vector and its components in (a,b).
5037 * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
5038 * can be calculated using only <code>Ia</code> and <code>Ib</code>.
5040 * The function operates on a single sample of data and each call to the function returns the processed output.
5041 * The library provides separate functions for Q31 and floating-point data types.
5043 * \image html clarkeFormula.gif
5044 * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
5045 * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
5046 * \par Fixed-Point Behavior
5047 * Care must be taken when using the Q31 version of the Clarke transform.
5048 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5049 * Refer to the function specific documentation below for usage guidelines.
5053 * @addtogroup clarke
5059 * @brief Floating-point Clarke transform
5060 * @param[in] Ia input three-phase coordinate <code>a</code>
5061 * @param[in] Ib input three-phase coordinate <code>b</code>
5062 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
5063 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
5067 static __INLINE
void arm_clarke_f32(
5070 float32_t
* pIalpha
,
5073 /* Calculate pIalpha using the equation, pIalpha = Ia */
5076 /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
5078 ((float32_t
) 0.57735026919 * Ia
+ (float32_t
) 1.15470053838 * Ib
);
5083 * @brief Clarke transform for Q31 version
5084 * @param[in] Ia input three-phase coordinate <code>a</code>
5085 * @param[in] Ib input three-phase coordinate <code>b</code>
5086 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
5087 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
5090 * <b>Scaling and Overflow Behavior:</b>
5092 * The function is implemented using an internal 32-bit accumulator.
5093 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5094 * There is saturation on the addition, hence there is no risk of overflow.
5097 static __INLINE
void arm_clarke_q31(
5103 q31_t product1
, product2
; /* Temporary variables used to store intermediate results */
5105 /* Calculating pIalpha from Ia by equation pIalpha = Ia */
5108 /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
5109 product1
= (q31_t
) (((q63_t
) Ia
* 0x24F34E8B) >> 30);
5111 /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
5112 product2
= (q31_t
) (((q63_t
) Ib
* 0x49E69D16) >> 30);
5114 /* pIbeta is calculated by adding the intermediate products */
5115 *pIbeta
= __QADD(product1
, product2
);
5119 * @} end of clarke group
5123 * @brief Converts the elements of the Q7 vector to Q31 vector.
5124 * @param[in] *pSrc input pointer
5125 * @param[out] *pDst output pointer
5126 * @param[in] blockSize number of samples to process
5132 uint32_t blockSize
);
5138 * @ingroup groupController
5142 * @defgroup inv_clarke Vector Inverse Clarke Transform
5143 * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
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.
5148 * \image html clarkeInvFormula.gif
5149 * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
5150 * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
5151 * \par Fixed-Point Behavior
5152 * Care must be taken when using the Q31 version of the Clarke transform.
5153 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5154 * Refer to the function specific documentation below for usage guidelines.
5158 * @addtogroup inv_clarke
5163 * @brief Floating-point Inverse Clarke transform
5164 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5165 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5166 * @param[out] *pIa points to output three-phase coordinate <code>a</code>
5167 * @param[out] *pIb points to output three-phase coordinate <code>b</code>
5172 static __INLINE
void arm_inv_clarke_f32(
5178 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5181 /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
5182 *pIb
= -0.5 * Ialpha
+ (float32_t
) 0.8660254039 *Ibeta
;
5187 * @brief Inverse Clarke transform for Q31 version
5188 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5189 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5190 * @param[out] *pIa points to output three-phase coordinate <code>a</code>
5191 * @param[out] *pIb points to output three-phase coordinate <code>b</code>
5194 * <b>Scaling and Overflow Behavior:</b>
5196 * The function is implemented using an internal 32-bit accumulator.
5197 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5198 * There is saturation on the subtraction, hence there is no risk of overflow.
5201 static __INLINE
void arm_inv_clarke_q31(
5207 q31_t product1
, product2
; /* Temporary variables used to store intermediate results */
5209 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5212 /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
5213 product1
= (q31_t
) (((q63_t
) (Ialpha
) * (0x40000000)) >> 31);
5215 /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
5216 product2
= (q31_t
) (((q63_t
) (Ibeta
) * (0x6ED9EBA1)) >> 31);
5218 /* pIb is calculated by subtracting the products */
5219 *pIb
= __QSUB(product2
, product1
);
5224 * @} end of inv_clarke group
5228 * @brief Converts the elements of the Q7 vector to Q15 vector.
5229 * @param[in] *pSrc input pointer
5230 * @param[out] *pDst output pointer
5231 * @param[in] blockSize number of samples to process
5237 uint32_t blockSize
);
5242 * @ingroup groupController
5246 * @defgroup park Vector Park Transform
5248 * Forward Park transform converts the input two-coordinate vector to flux and torque components.
5249 * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
5250 * from the stationary to the moving reference frame and control the spatial relationship between
5251 * the stator vector current and rotor flux vector.
5252 * If we consider the d axis aligned with the rotor flux, the diagram below shows the
5253 * current vector and the relationship from the two reference frames:
5254 * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
5256 * The function operates on a single sample of data and each call to the function returns the processed output.
5257 * The library provides separate functions for Q31 and floating-point data types.
5259 * \image html parkFormula.gif
5260 * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
5261 * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5262 * cosine and sine values of theta (rotor flux position).
5263 * \par Fixed-Point Behavior
5264 * Care must be taken when using the Q31 version of the Park transform.
5265 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5266 * Refer to the function specific documentation below for usage guidelines.
5275 * @brief Floating-point Park transform
5276 * @param[in] Ialpha input two-phase vector coordinate alpha
5277 * @param[in] Ibeta input two-phase vector coordinate beta
5278 * @param[out] *pId points to output rotor reference frame d
5279 * @param[out] *pIq points to output rotor reference frame q
5280 * @param[in] sinVal sine value of rotation angle theta
5281 * @param[in] cosVal cosine value of rotation angle theta
5284 * The function implements the forward Park transform.
5288 static __INLINE
void arm_park_f32(
5296 /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
5297 *pId
= Ialpha
* cosVal
+ Ibeta
* sinVal
;
5299 /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
5300 *pIq
= -Ialpha
* sinVal
+ Ibeta
* cosVal
;
5305 * @brief Park transform for Q31 version
5306 * @param[in] Ialpha input two-phase vector coordinate alpha
5307 * @param[in] Ibeta input two-phase vector coordinate beta
5308 * @param[out] *pId points to output rotor reference frame d
5309 * @param[out] *pIq points to output rotor reference frame q
5310 * @param[in] sinVal sine value of rotation angle theta
5311 * @param[in] cosVal cosine value of rotation angle theta
5314 * <b>Scaling and Overflow Behavior:</b>
5316 * The function is implemented using an internal 32-bit accumulator.
5317 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5318 * There is saturation on the addition and subtraction, hence there is no risk of overflow.
5322 static __INLINE
void arm_park_q31(
5330 q31_t product1
, product2
; /* Temporary variables used to store intermediate results */
5331 q31_t product3
, product4
; /* Temporary variables used to store intermediate results */
5333 /* Intermediate product is calculated by (Ialpha * cosVal) */
5334 product1
= (q31_t
) (((q63_t
) (Ialpha
) * (cosVal
)) >> 31);
5336 /* Intermediate product is calculated by (Ibeta * sinVal) */
5337 product2
= (q31_t
) (((q63_t
) (Ibeta
) * (sinVal
)) >> 31);
5340 /* Intermediate product is calculated by (Ialpha * sinVal) */
5341 product3
= (q31_t
) (((q63_t
) (Ialpha
) * (sinVal
)) >> 31);
5343 /* Intermediate product is calculated by (Ibeta * cosVal) */
5344 product4
= (q31_t
) (((q63_t
) (Ibeta
) * (cosVal
)) >> 31);
5346 /* Calculate pId by adding the two intermediate products 1 and 2 */
5347 *pId
= __QADD(product1
, product2
);
5349 /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
5350 *pIq
= __QSUB(product4
, product3
);
5354 * @} end of park group
5358 * @brief Converts the elements of the Q7 vector to floating-point vector.
5359 * @param[in] *pSrc is input pointer
5360 * @param[out] *pDst is output pointer
5361 * @param[in] blockSize is the number of samples to process
5364 void arm_q7_to_float(
5367 uint32_t blockSize
);
5371 * @ingroup groupController
5375 * @defgroup inv_park Vector Inverse Park transform
5376 * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
5378 * The function operates on a single sample of data and each call to the function returns the processed output.
5379 * The library provides separate functions for Q31 and floating-point data types.
5381 * \image html parkInvFormula.gif
5382 * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
5383 * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5384 * cosine and sine values of theta (rotor flux position).
5385 * \par Fixed-Point Behavior
5386 * Care must be taken when using the Q31 version of the Park transform.
5387 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5388 * Refer to the function specific documentation below for usage guidelines.
5392 * @addtogroup inv_park
5397 * @brief Floating-point Inverse Park transform
5398 * @param[in] Id input coordinate of rotor reference frame d
5399 * @param[in] Iq input coordinate of rotor reference frame q
5400 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
5401 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
5402 * @param[in] sinVal sine value of rotation angle theta
5403 * @param[in] cosVal cosine value of rotation angle theta
5407 static __INLINE
void arm_inv_park_f32(
5410 float32_t
* pIalpha
,
5415 /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
5416 *pIalpha
= Id
* cosVal
- Iq
* sinVal
;
5418 /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
5419 *pIbeta
= Id
* sinVal
+ Iq
* cosVal
;
5425 * @brief Inverse Park transform for Q31 version
5426 * @param[in] Id input coordinate of rotor reference frame d
5427 * @param[in] Iq input coordinate of rotor reference frame q
5428 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
5429 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
5430 * @param[in] sinVal sine value of rotation angle theta
5431 * @param[in] cosVal cosine value of rotation angle theta
5434 * <b>Scaling and Overflow Behavior:</b>
5436 * The function is implemented using an internal 32-bit accumulator.
5437 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5438 * There is saturation on the addition, hence there is no risk of overflow.
5442 static __INLINE
void arm_inv_park_q31(
5450 q31_t product1
, product2
; /* Temporary variables used to store intermediate results */
5451 q31_t product3
, product4
; /* Temporary variables used to store intermediate results */
5453 /* Intermediate product is calculated by (Id * cosVal) */
5454 product1
= (q31_t
) (((q63_t
) (Id
) * (cosVal
)) >> 31);
5456 /* Intermediate product is calculated by (Iq * sinVal) */
5457 product2
= (q31_t
) (((q63_t
) (Iq
) * (sinVal
)) >> 31);
5460 /* Intermediate product is calculated by (Id * sinVal) */
5461 product3
= (q31_t
) (((q63_t
) (Id
) * (sinVal
)) >> 31);
5463 /* Intermediate product is calculated by (Iq * cosVal) */
5464 product4
= (q31_t
) (((q63_t
) (Iq
) * (cosVal
)) >> 31);
5466 /* Calculate pIalpha by using the two intermediate products 1 and 2 */
5467 *pIalpha
= __QSUB(product1
, product2
);
5469 /* Calculate pIbeta by using the two intermediate products 3 and 4 */
5470 *pIbeta
= __QADD(product4
, product3
);
5475 * @} end of Inverse park group
5480 * @brief Converts the elements of the Q31 vector to floating-point vector.
5481 * @param[in] *pSrc is input pointer
5482 * @param[out] *pDst is output pointer
5483 * @param[in] blockSize is the number of samples to process
5486 void arm_q31_to_float(
5489 uint32_t blockSize
);
5492 * @ingroup groupInterpolation
5496 * @defgroup LinearInterpolate Linear Interpolation
5498 * Linear interpolation is a method of curve fitting using linear polynomials.
5499 * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
5502 * \image html LinearInterp.gif "Linear interpolation"
5505 * A Linear Interpolate function calculates an output value(y), for the input(x)
5506 * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
5510 * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
5511 * where x0, x1 are nearest values of input x
5512 * y0, y1 are nearest values to output y
5516 * This set of functions implements Linear interpolation process
5517 * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
5518 * sample of data and each call to the function returns a single processed value.
5519 * <code>S</code> points to an instance of the Linear Interpolate function data structure.
5520 * <code>x</code> is the input sample value. The functions returns the output value.
5523 * if x is outside of the table boundary, Linear interpolation returns first value of the table
5524 * if x is below input range and returns last value of table if x is above range.
5528 * @addtogroup LinearInterpolate
5533 * @brief Process function for the floating-point Linear Interpolation Function.
5534 * @param[in,out] *S is an instance of the floating-point Linear Interpolation structure
5535 * @param[in] x input sample to process
5536 * @return y processed output sample.
5540 static __INLINE float32_t
arm_linear_interp_f32(
5541 arm_linear_interp_instance_f32
* S
,
5546 float32_t x0
, x1
; /* Nearest input values */
5547 float32_t y0
, y1
; /* Nearest output values */
5548 float32_t xSpacing
= S
->xSpacing
; /* spacing between input values */
5549 int32_t i
; /* Index variable */
5550 float32_t
*pYData
= S
->pYData
; /* pointer to output table */
5552 /* Calculation of index */
5553 i
= (int32_t) ((x
- S
->x1
) / xSpacing
);
5557 /* Iniatilize output for below specified range as least output value of table */
5560 else if((uint32_t)i
>= S
->nValues
)
5562 /* Iniatilize output for above specified range as last output value of table */
5563 y
= pYData
[S
->nValues
- 1];
5567 /* Calculation of nearest input values */
5568 x0
= S
->x1
+ i
* xSpacing
;
5569 x1
= S
->x1
+ (i
+ 1) * xSpacing
;
5571 /* Read of nearest output values */
5575 /* Calculation of output */
5576 y
= y0
+ (x
- x0
) * ((y1
- y0
) / (x1
- x0
));
5580 /* returns output value */
5586 * @brief Process function for the Q31 Linear Interpolation Function.
5587 * @param[in] *pYData pointer to Q31 Linear Interpolation table
5588 * @param[in] x input sample to process
5589 * @param[in] nValues number of table values
5590 * @return y processed output sample.
5593 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5594 * This function can support maximum of table size 2^12.
5599 static __INLINE q31_t
arm_linear_interp_q31(
5604 q31_t y
; /* output */
5605 q31_t y0
, y1
; /* Nearest output values */
5606 q31_t fract
; /* fractional part */
5607 int32_t index
; /* Index to read nearest output values */
5609 /* Input is in 12.20 format */
5610 /* 12 bits for the table index */
5611 /* Index value calculation */
5612 index
= ((x
& 0xFFF00000) >> 20);
5614 if(index
>= (int32_t)(nValues
- 1))
5616 return (pYData
[nValues
- 1]);
5625 /* 20 bits for the fractional part */
5626 /* shift left by 11 to keep fract in 1.31 format */
5627 fract
= (x
& 0x000FFFFF) << 11;
5629 /* Read two nearest output values from the index in 1.31(q31) format */
5631 y1
= pYData
[index
+ 1u];
5633 /* Calculation of y0 * (1-fract) and y is in 2.30 format */
5634 y
= ((q31_t
) ((q63_t
) y0
* (0x7FFFFFFF - fract
) >> 32));
5636 /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
5637 y
+= ((q31_t
) (((q63_t
) y1
* fract
) >> 32));
5639 /* Convert y to 1.31 format */
5648 * @brief Process function for the Q15 Linear Interpolation Function.
5649 * @param[in] *pYData pointer to Q15 Linear Interpolation table
5650 * @param[in] x input sample to process
5651 * @param[in] nValues number of table values
5652 * @return y processed output sample.
5655 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5656 * This function can support maximum of table size 2^12.
5661 static __INLINE q15_t
arm_linear_interp_q15(
5666 q63_t y
; /* output */
5667 q15_t y0
, y1
; /* Nearest output values */
5668 q31_t fract
; /* fractional part */
5669 int32_t index
; /* Index to read nearest output values */
5671 /* Input is in 12.20 format */
5672 /* 12 bits for the table index */
5673 /* Index value calculation */
5674 index
= ((x
& 0xFFF00000) >> 20u);
5676 if(index
>= (int32_t)(nValues
- 1))
5678 return (pYData
[nValues
- 1]);
5686 /* 20 bits for the fractional part */
5687 /* fract is in 12.20 format */
5688 fract
= (x
& 0x000FFFFF);
5690 /* Read two nearest output values from the index */
5692 y1
= pYData
[index
+ 1u];
5694 /* Calculation of y0 * (1-fract) and y is in 13.35 format */
5695 y
= ((q63_t
) y0
* (0xFFFFF - fract
));
5697 /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
5698 y
+= ((q63_t
) y1
* (fract
));
5700 /* convert y to 1.15 format */
5709 * @brief Process function for the Q7 Linear Interpolation Function.
5710 * @param[in] *pYData pointer to Q7 Linear Interpolation table
5711 * @param[in] x input sample to process
5712 * @param[in] nValues number of table values
5713 * @return y processed output sample.
5716 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5717 * This function can support maximum of table size 2^12.
5721 static __INLINE q7_t
arm_linear_interp_q7(
5726 q31_t y
; /* output */
5727 q7_t y0
, y1
; /* Nearest output values */
5728 q31_t fract
; /* fractional part */
5729 uint32_t index
; /* Index to read nearest output values */
5731 /* Input is in 12.20 format */
5732 /* 12 bits for the table index */
5733 /* Index value calculation */
5738 index
= (x
>> 20) & 0xfff;
5741 if(index
>= (nValues
- 1))
5743 return (pYData
[nValues
- 1]);
5748 /* 20 bits for the fractional part */
5749 /* fract is in 12.20 format */
5750 fract
= (x
& 0x000FFFFF);
5752 /* Read two nearest output values from the index and are in 1.7(q7) format */
5754 y1
= pYData
[index
+ 1u];
5756 /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
5757 y
= ((y0
* (0xFFFFF - fract
)));
5759 /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
5762 /* convert y to 1.7(q7) format */
5769 * @} end of LinearInterpolate group
5773 * @brief Fast approximation to the trigonometric sine function for floating-point data.
5774 * @param[in] x input value in radians.
5778 float32_t
arm_sin_f32(
5782 * @brief Fast approximation to the trigonometric sine function for Q31 data.
5783 * @param[in] x Scaled input value in radians.
5791 * @brief Fast approximation to the trigonometric sine function for Q15 data.
5792 * @param[in] x Scaled input value in radians.
5800 * @brief Fast approximation to the trigonometric cosine function for floating-point data.
5801 * @param[in] x input value in radians.
5805 float32_t
arm_cos_f32(
5809 * @brief Fast approximation to the trigonometric cosine function for Q31 data.
5810 * @param[in] x Scaled input value in radians.
5818 * @brief Fast approximation to the trigonometric cosine function for Q15 data.
5819 * @param[in] x Scaled input value in radians.
5828 * @ingroup groupFastMath
5833 * @defgroup SQRT Square Root
5835 * Computes the square root of a number.
5836 * There are separate functions for Q15, Q31, and floating-point data types.
5837 * The square root function is computed using the Newton-Raphson algorithm.
5838 * This is an iterative algorithm of the form:
5840 * x1 = x0 - f(x0)/f'(x0)
5842 * where <code>x1</code> is the current estimate,
5843 * <code>x0</code> is the previous estimate, and
5844 * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
5845 * For the square root function, the algorithm reduces to:
5847 * x0 = in/2 [initial guess]
5848 * x1 = 1/2 * ( x0 + in / x0) [each iteration]
5859 * @brief Floating-point square root function.
5860 * @param[in] in input value.
5861 * @param[out] *pOut square root of input value.
5862 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5863 * <code>in</code> is negative value and returns zero output for negative values.
5866 static __INLINE arm_status
arm_sqrt_f32(
5874 #if (__FPU_USED == 1) && defined ( __CC_ARM )
5875 *pOut
= __sqrtf(in
);
5880 return (ARM_MATH_SUCCESS
);
5885 return (ARM_MATH_ARGUMENT_ERROR
);
5892 * @brief Q31 square root function.
5893 * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
5894 * @param[out] *pOut square root of input value.
5895 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5896 * <code>in</code> is negative value and returns zero output for negative values.
5898 arm_status
arm_sqrt_q31(
5903 * @brief Q15 square root function.
5904 * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
5905 * @param[out] *pOut square root of input value.
5906 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5907 * <code>in</code> is negative value and returns zero output for negative values.
5909 arm_status
arm_sqrt_q15(
5914 * @} end of SQRT group
5923 * @brief floating-point Circular write function.
5926 static __INLINE
void arm_circularWrite_f32(
5927 int32_t * circBuffer
,
5929 uint16_t * writeOffset
,
5931 const int32_t * src
,
5938 /* Copy the value of Index pointer that points
5939 * to the current location where the input samples to be copied */
5940 wOffset
= *writeOffset
;
5942 /* Loop over the blockSize */
5947 /* copy the input sample to the circular buffer */
5948 circBuffer
[wOffset
] = *src
;
5950 /* Update the input pointer */
5953 /* Circularly update wOffset. Watch out for positive and negative value */
5954 wOffset
+= bufferInc
;
5958 /* Decrement the loop counter */
5962 /* Update the index pointer */
5963 *writeOffset
= wOffset
;
5969 * @brief floating-point Circular Read function.
5971 static __INLINE
void arm_circularRead_f32(
5972 int32_t * circBuffer
,
5974 int32_t * readOffset
,
5983 int32_t rOffset
, dst_end
;
5985 /* Copy the value of Index pointer that points
5986 * to the current location from where the input samples to be read */
5987 rOffset
= *readOffset
;
5988 dst_end
= (int32_t) (dst_base
+ dst_length
);
5990 /* Loop over the blockSize */
5995 /* copy the sample from the circular buffer to the destination buffer */
5996 *dst
= circBuffer
[rOffset
];
5998 /* Update the input pointer */
6001 if(dst
== (int32_t *) dst_end
)
6006 /* Circularly update rOffset. Watch out for positive and negative value */
6007 rOffset
+= bufferInc
;
6014 /* Decrement the loop counter */
6018 /* Update the index pointer */
6019 *readOffset
= rOffset
;
6023 * @brief Q15 Circular write function.
6026 static __INLINE
void arm_circularWrite_q15(
6029 uint16_t * writeOffset
,
6038 /* Copy the value of Index pointer that points
6039 * to the current location where the input samples to be copied */
6040 wOffset
= *writeOffset
;
6042 /* Loop over the blockSize */
6047 /* copy the input sample to the circular buffer */
6048 circBuffer
[wOffset
] = *src
;
6050 /* Update the input pointer */
6053 /* Circularly update wOffset. Watch out for positive and negative value */
6054 wOffset
+= bufferInc
;
6058 /* Decrement the loop counter */
6062 /* Update the index pointer */
6063 *writeOffset
= wOffset
;
6069 * @brief Q15 Circular Read function.
6071 static __INLINE
void arm_circularRead_q15(
6074 int32_t * readOffset
,
6083 int32_t rOffset
, dst_end
;
6085 /* Copy the value of Index pointer that points
6086 * to the current location from where the input samples to be read */
6087 rOffset
= *readOffset
;
6089 dst_end
= (int32_t) (dst_base
+ dst_length
);
6091 /* Loop over the blockSize */
6096 /* copy the sample from the circular buffer to the destination buffer */
6097 *dst
= circBuffer
[rOffset
];
6099 /* Update the input pointer */
6102 if(dst
== (q15_t
*) dst_end
)
6107 /* Circularly update wOffset. Watch out for positive and negative value */
6108 rOffset
+= bufferInc
;
6115 /* Decrement the loop counter */
6119 /* Update the index pointer */
6120 *readOffset
= rOffset
;
6125 * @brief Q7 Circular write function.
6128 static __INLINE
void arm_circularWrite_q7(
6131 uint16_t * writeOffset
,
6140 /* Copy the value of Index pointer that points
6141 * to the current location where the input samples to be copied */
6142 wOffset
= *writeOffset
;
6144 /* Loop over the blockSize */
6149 /* copy the input sample to the circular buffer */
6150 circBuffer
[wOffset
] = *src
;
6152 /* Update the input pointer */
6155 /* Circularly update wOffset. Watch out for positive and negative value */
6156 wOffset
+= bufferInc
;
6160 /* Decrement the loop counter */
6164 /* Update the index pointer */
6165 *writeOffset
= wOffset
;
6171 * @brief Q7 Circular Read function.
6173 static __INLINE
void arm_circularRead_q7(
6176 int32_t * readOffset
,
6185 int32_t rOffset
, dst_end
;
6187 /* Copy the value of Index pointer that points
6188 * to the current location from where the input samples to be read */
6189 rOffset
= *readOffset
;
6191 dst_end
= (int32_t) (dst_base
+ dst_length
);
6193 /* Loop over the blockSize */
6198 /* copy the sample from the circular buffer to the destination buffer */
6199 *dst
= circBuffer
[rOffset
];
6201 /* Update the input pointer */
6204 if(dst
== (q7_t
*) dst_end
)
6209 /* Circularly update rOffset. Watch out for positive and negative value */
6210 rOffset
+= bufferInc
;
6217 /* Decrement the loop counter */
6221 /* Update the index pointer */
6222 *readOffset
= rOffset
;
6227 * @brief Sum of the squares of the elements of a Q31 vector.
6228 * @param[in] *pSrc is input pointer
6229 * @param[in] blockSize is the number of samples to process
6230 * @param[out] *pResult is output value.
6240 * @brief Sum of the squares of the elements of a floating-point 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.
6250 float32_t
* pResult
);
6253 * @brief Sum of the squares of the elements of a Q15 vector.
6254 * @param[in] *pSrc is input pointer
6255 * @param[in] blockSize is the number of samples to process
6256 * @param[out] *pResult is output value.
6266 * @brief Sum of the squares of the elements of a Q7 vector.
6267 * @param[in] *pSrc is input pointer
6268 * @param[in] blockSize is the number of samples to process
6269 * @param[out] *pResult is output value.
6279 * @brief Mean value of a Q7 vector.
6280 * @param[in] *pSrc is input pointer
6281 * @param[in] blockSize is the number of samples to process
6282 * @param[out] *pResult is output value.
6292 * @brief Mean value of a Q15 vector.
6293 * @param[in] *pSrc is input pointer
6294 * @param[in] blockSize is the number of samples to process
6295 * @param[out] *pResult is output value.
6304 * @brief Mean value of a Q31 vector.
6305 * @param[in] *pSrc is input pointer
6306 * @param[in] blockSize is the number of samples to process
6307 * @param[out] *pResult is output value.
6316 * @brief Mean value of a floating-point vector.
6317 * @param[in] *pSrc is input pointer
6318 * @param[in] blockSize is the number of samples to process
6319 * @param[out] *pResult is output value.
6325 float32_t
* pResult
);
6328 * @brief Variance of the elements of a floating-point vector.
6329 * @param[in] *pSrc is input pointer
6330 * @param[in] blockSize is the number of samples to process
6331 * @param[out] *pResult is output value.
6338 float32_t
* pResult
);
6341 * @brief Variance of the elements of a Q31 vector.
6342 * @param[in] *pSrc is input pointer
6343 * @param[in] blockSize is the number of samples to process
6344 * @param[out] *pResult is output value.
6354 * @brief Variance of the elements of a Q15 vector.
6355 * @param[in] *pSrc is input pointer
6356 * @param[in] blockSize is the number of samples to process
6357 * @param[out] *pResult is output value.
6367 * @brief Root Mean Square of the elements of a floating-point vector.
6368 * @param[in] *pSrc is input pointer
6369 * @param[in] blockSize is the number of samples to process
6370 * @param[out] *pResult is output value.
6377 float32_t
* pResult
);
6380 * @brief Root Mean Square of the elements of a Q31 vector.
6381 * @param[in] *pSrc is input pointer
6382 * @param[in] blockSize is the number of samples to process
6383 * @param[out] *pResult is output value.
6393 * @brief Root Mean Square of the elements of a Q15 vector.
6394 * @param[in] *pSrc is input pointer
6395 * @param[in] blockSize is the number of samples to process
6396 * @param[out] *pResult is output value.
6406 * @brief Standard deviation of the elements of a floating-point vector.
6407 * @param[in] *pSrc is input pointer
6408 * @param[in] blockSize is the number of samples to process
6409 * @param[out] *pResult is output value.
6416 float32_t
* pResult
);
6419 * @brief Standard deviation of the elements of a Q31 vector.
6420 * @param[in] *pSrc is input pointer
6421 * @param[in] blockSize is the number of samples to process
6422 * @param[out] *pResult is output value.
6432 * @brief Standard deviation of the elements of a Q15 vector.
6433 * @param[in] *pSrc is input pointer
6434 * @param[in] blockSize is the number of samples to process
6435 * @param[out] *pResult is output value.
6445 * @brief Floating-point complex magnitude
6446 * @param[in] *pSrc points to the complex input vector
6447 * @param[out] *pDst points to the real output vector
6448 * @param[in] numSamples number of complex samples in the input vector
6452 void arm_cmplx_mag_f32(
6455 uint32_t numSamples
);
6458 * @brief Q31 complex magnitude
6459 * @param[in] *pSrc points to the complex input vector
6460 * @param[out] *pDst points to the real output vector
6461 * @param[in] numSamples number of complex samples in the input vector
6465 void arm_cmplx_mag_q31(
6468 uint32_t numSamples
);
6471 * @brief Q15 complex magnitude
6472 * @param[in] *pSrc points to the complex input vector
6473 * @param[out] *pDst points to the real output vector
6474 * @param[in] numSamples number of complex samples in the input vector
6478 void arm_cmplx_mag_q15(
6481 uint32_t numSamples
);
6484 * @brief Q15 complex dot product
6485 * @param[in] *pSrcA points to the first input vector
6486 * @param[in] *pSrcB points to the second input vector
6487 * @param[in] numSamples number of complex samples in each vector
6488 * @param[out] *realResult real part of the result returned here
6489 * @param[out] *imagResult imaginary part of the result returned here
6493 void arm_cmplx_dot_prod_q15(
6496 uint32_t numSamples
,
6498 q31_t
* imagResult
);
6501 * @brief Q31 complex dot product
6502 * @param[in] *pSrcA points to the first input vector
6503 * @param[in] *pSrcB points to the second input vector
6504 * @param[in] numSamples number of complex samples in each vector
6505 * @param[out] *realResult real part of the result returned here
6506 * @param[out] *imagResult imaginary part of the result returned here
6510 void arm_cmplx_dot_prod_q31(
6513 uint32_t numSamples
,
6515 q63_t
* imagResult
);
6518 * @brief Floating-point complex dot product
6519 * @param[in] *pSrcA points to the first input vector
6520 * @param[in] *pSrcB points to the second input vector
6521 * @param[in] numSamples number of complex samples in each vector
6522 * @param[out] *realResult real part of the result returned here
6523 * @param[out] *imagResult imaginary part of the result returned here
6527 void arm_cmplx_dot_prod_f32(
6530 uint32_t numSamples
,
6531 float32_t
* realResult
,
6532 float32_t
* imagResult
);
6535 * @brief Q15 complex-by-real multiplication
6536 * @param[in] *pSrcCmplx points to the complex input vector
6537 * @param[in] *pSrcReal points to the real input vector
6538 * @param[out] *pCmplxDst points to the complex output vector
6539 * @param[in] numSamples number of samples in each vector
6543 void arm_cmplx_mult_real_q15(
6547 uint32_t numSamples
);
6550 * @brief Q31 complex-by-real multiplication
6551 * @param[in] *pSrcCmplx points to the complex input vector
6552 * @param[in] *pSrcReal points to the real input vector
6553 * @param[out] *pCmplxDst points to the complex output vector
6554 * @param[in] numSamples number of samples in each vector
6558 void arm_cmplx_mult_real_q31(
6562 uint32_t numSamples
);
6565 * @brief Floating-point complex-by-real multiplication
6566 * @param[in] *pSrcCmplx points to the complex input vector
6567 * @param[in] *pSrcReal points to the real input vector
6568 * @param[out] *pCmplxDst points to the complex output vector
6569 * @param[in] numSamples number of samples in each vector
6573 void arm_cmplx_mult_real_f32(
6574 float32_t
* pSrcCmplx
,
6575 float32_t
* pSrcReal
,
6576 float32_t
* pCmplxDst
,
6577 uint32_t numSamples
);
6580 * @brief Minimum value of a Q7 vector.
6581 * @param[in] *pSrc is input pointer
6582 * @param[in] blockSize is the number of samples to process
6583 * @param[out] *result is output pointer
6584 * @param[in] index is the array index of the minimum value in the input buffer.
6595 * @brief Minimum value of a Q15 vector.
6596 * @param[in] *pSrc is input pointer
6597 * @param[in] blockSize is the number of samples to process
6598 * @param[out] *pResult is output pointer
6599 * @param[in] *pIndex is the array index of the minimum value in the input buffer.
6610 * @brief Minimum value of a Q31 vector.
6611 * @param[in] *pSrc is input pointer
6612 * @param[in] blockSize is the number of samples to process
6613 * @param[out] *pResult is output pointer
6614 * @param[out] *pIndex is the array index of the minimum value in the input buffer.
6624 * @brief Minimum value of a floating-point vector.
6625 * @param[in] *pSrc is input pointer
6626 * @param[in] blockSize is the number of samples to process
6627 * @param[out] *pResult is output pointer
6628 * @param[out] *pIndex is the array index of the minimum value in the input buffer.
6635 float32_t
* pResult
,
6639 * @brief Maximum value of a Q7 vector.
6640 * @param[in] *pSrc points to the input buffer
6641 * @param[in] blockSize length of the input vector
6642 * @param[out] *pResult maximum value returned here
6643 * @param[out] *pIndex index of maximum value returned here
6654 * @brief Maximum value of a Q15 vector.
6655 * @param[in] *pSrc points to the input buffer
6656 * @param[in] blockSize length of the input vector
6657 * @param[out] *pResult maximum value returned here
6658 * @param[out] *pIndex index of maximum value returned here
6669 * @brief Maximum value of a Q31 vector.
6670 * @param[in] *pSrc points to the input buffer
6671 * @param[in] blockSize length of the input vector
6672 * @param[out] *pResult maximum value returned here
6673 * @param[out] *pIndex index of maximum value returned here
6684 * @brief Maximum value of a floating-point vector.
6685 * @param[in] *pSrc points to the input buffer
6686 * @param[in] blockSize length of the input vector
6687 * @param[out] *pResult maximum value returned here
6688 * @param[out] *pIndex index of maximum value returned here
6695 float32_t
* pResult
,
6699 * @brief Q15 complex-by-complex multiplication
6700 * @param[in] *pSrcA points to the first input vector
6701 * @param[in] *pSrcB points to the second input vector
6702 * @param[out] *pDst points to the output vector
6703 * @param[in] numSamples number of complex samples in each vector
6707 void arm_cmplx_mult_cmplx_q15(
6711 uint32_t numSamples
);
6714 * @brief Q31 complex-by-complex multiplication
6715 * @param[in] *pSrcA points to the first input vector
6716 * @param[in] *pSrcB points to the second input vector
6717 * @param[out] *pDst points to the output vector
6718 * @param[in] numSamples number of complex samples in each vector
6722 void arm_cmplx_mult_cmplx_q31(
6726 uint32_t numSamples
);
6729 * @brief Floating-point complex-by-complex multiplication
6730 * @param[in] *pSrcA points to the first input vector
6731 * @param[in] *pSrcB points to the second input vector
6732 * @param[out] *pDst points to the output vector
6733 * @param[in] numSamples number of complex samples in each vector
6737 void arm_cmplx_mult_cmplx_f32(
6741 uint32_t numSamples
);
6744 * @brief Converts the elements of the floating-point vector to Q31 vector.
6745 * @param[in] *pSrc points to the floating-point input vector
6746 * @param[out] *pDst points to the Q31 output vector
6747 * @param[in] blockSize length of the input vector
6750 void arm_float_to_q31(
6753 uint32_t blockSize
);
6756 * @brief Converts the elements of the floating-point vector to Q15 vector.
6757 * @param[in] *pSrc points to the floating-point input vector
6758 * @param[out] *pDst points to the Q15 output vector
6759 * @param[in] blockSize length of the input vector
6762 void arm_float_to_q15(
6765 uint32_t blockSize
);
6768 * @brief Converts the elements of the floating-point vector to Q7 vector.
6769 * @param[in] *pSrc points to the floating-point input vector
6770 * @param[out] *pDst points to the Q7 output vector
6771 * @param[in] blockSize length of the input vector
6774 void arm_float_to_q7(
6777 uint32_t blockSize
);
6781 * @brief Converts the elements of the Q31 vector to Q15 vector.
6782 * @param[in] *pSrc is input pointer
6783 * @param[out] *pDst is output pointer
6784 * @param[in] blockSize is the number of samples to process
6787 void arm_q31_to_q15(
6790 uint32_t blockSize
);
6793 * @brief Converts the elements of the Q31 vector to Q7 vector.
6794 * @param[in] *pSrc is input pointer
6795 * @param[out] *pDst is output pointer
6796 * @param[in] blockSize is the number of samples to process
6802 uint32_t blockSize
);
6805 * @brief Converts the elements of the Q15 vector to floating-point vector.
6806 * @param[in] *pSrc is input pointer
6807 * @param[out] *pDst is output pointer
6808 * @param[in] blockSize is the number of samples to process
6811 void arm_q15_to_float(
6814 uint32_t blockSize
);
6818 * @brief Converts the elements of the Q15 vector to Q31 vector.
6819 * @param[in] *pSrc is input pointer
6820 * @param[out] *pDst is output pointer
6821 * @param[in] blockSize is the number of samples to process
6824 void arm_q15_to_q31(
6827 uint32_t blockSize
);
6831 * @brief Converts the elements of the Q15 vector to Q7 vector.
6832 * @param[in] *pSrc is input pointer
6833 * @param[out] *pDst is output pointer
6834 * @param[in] blockSize is the number of samples to process
6840 uint32_t blockSize
);
6844 * @ingroup groupInterpolation
6848 * @defgroup BilinearInterpolate Bilinear Interpolation
6850 * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
6851 * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
6852 * determines values between the grid points.
6853 * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
6854 * Bilinear interpolation is often used in image processing to rescale images.
6855 * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
6859 * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
6860 * For floating-point, the instance structure is defined as:
6867 * } arm_bilinear_interp_instance_f32;
6871 * where <code>numRows</code> specifies the number of rows in the table;
6872 * <code>numCols</code> specifies the number of columns in the table;
6873 * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
6874 * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
6875 * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
6878 * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
6884 * The interpolated output point is computed as:
6886 * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
6887 * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
6888 * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
6889 * + f(XF+1, YF+1) * (x-XF)*(y-YF)
6891 * Note that the coordinates (x, y) contain integer and fractional components.
6892 * The integer components specify which portion of the table to use while the
6893 * fractional components control the interpolation processor.
6896 * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
6900 * @addtogroup BilinearInterpolate
6906 * @brief Floating-point bilinear interpolation.
6907 * @param[in,out] *S points to an instance of the interpolation structure.
6908 * @param[in] X interpolation coordinate.
6909 * @param[in] Y interpolation coordinate.
6910 * @return out interpolated value.
6914 static __INLINE float32_t
arm_bilinear_interp_f32(
6915 const arm_bilinear_interp_instance_f32
* S
,
6920 float32_t f00
, f01
, f10
, f11
;
6921 float32_t
*pData
= S
->pData
;
6922 int32_t xIndex
, yIndex
, index
;
6923 float32_t xdiff
, ydiff
;
6924 float32_t b1
, b2
, b3
, b4
;
6926 xIndex
= (int32_t) X
;
6927 yIndex
= (int32_t) Y
;
6929 /* Care taken for table outside boundary */
6930 /* Returns zero output when values are outside table boundary */
6931 if(xIndex
< 0 || xIndex
> (S
->numRows
- 1) || yIndex
< 0
6932 || yIndex
> (S
->numCols
- 1))
6937 /* Calculation of index for two nearest points in X-direction */
6938 index
= (xIndex
- 1) + (yIndex
- 1) * S
->numCols
;
6941 /* Read two nearest points in X-direction */
6943 f01
= pData
[index
+ 1];
6945 /* Calculation of index for two nearest points in Y-direction */
6946 index
= (xIndex
- 1) + (yIndex
) * S
->numCols
;
6949 /* Read two nearest points in Y-direction */
6951 f11
= pData
[index
+ 1];
6953 /* Calculation of intermediate values */
6957 b4
= f00
- f01
- f10
+ f11
;
6959 /* Calculation of fractional part in X */
6962 /* Calculation of fractional part in Y */
6965 /* Calculation of bi-linear interpolated output */
6966 out
= b1
+ b2
* xdiff
+ b3
* ydiff
+ b4
* xdiff
* ydiff
;
6968 /* return to application */
6975 * @brief Q31 bilinear interpolation.
6976 * @param[in,out] *S points to an instance of the interpolation structure.
6977 * @param[in] X interpolation coordinate in 12.20 format.
6978 * @param[in] Y interpolation coordinate in 12.20 format.
6979 * @return out interpolated value.
6982 static __INLINE q31_t
arm_bilinear_interp_q31(
6983 arm_bilinear_interp_instance_q31
* S
,
6987 q31_t out
; /* Temporary output */
6988 q31_t acc
= 0; /* output */
6989 q31_t xfract
, yfract
; /* X, Y fractional parts */
6990 q31_t x1
, x2
, y1
, y2
; /* Nearest output values */
6991 int32_t rI
, cI
; /* Row and column indices */
6992 q31_t
*pYData
= S
->pData
; /* pointer to output table values */
6993 uint32_t nCols
= S
->numCols
; /* num of rows */
6996 /* Input is in 12.20 format */
6997 /* 12 bits for the table index */
6998 /* Index value calculation */
6999 rI
= ((X
& 0xFFF00000) >> 20u);
7001 /* Input is in 12.20 format */
7002 /* 12 bits for the table index */
7003 /* Index value calculation */
7004 cI
= ((Y
& 0xFFF00000) >> 20u);
7006 /* Care taken for table outside boundary */
7007 /* Returns zero output when values are outside table boundary */
7008 if(rI
< 0 || rI
> (S
->numRows
- 1) || cI
< 0 || cI
> (S
->numCols
- 1))
7013 /* 20 bits for the fractional part */
7014 /* shift left xfract by 11 to keep 1.31 format */
7015 xfract
= (X
& 0x000FFFFF) << 11u;
7017 /* Read two nearest output values from the index */
7018 x1
= pYData
[(rI
) + nCols
* (cI
)];
7019 x2
= pYData
[(rI
) + nCols
* (cI
) + 1u];
7021 /* 20 bits for the fractional part */
7022 /* shift left yfract by 11 to keep 1.31 format */
7023 yfract
= (Y
& 0x000FFFFF) << 11u;
7025 /* Read two nearest output values from the index */
7026 y1
= pYData
[(rI
) + nCols
* (cI
+ 1)];
7027 y2
= pYData
[(rI
) + nCols
* (cI
+ 1) + 1u];
7029 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
7030 out
= ((q31_t
) (((q63_t
) x1
* (0x7FFFFFFF - xfract
)) >> 32));
7031 acc
= ((q31_t
) (((q63_t
) out
* (0x7FFFFFFF - yfract
)) >> 32));
7033 /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
7034 out
= ((q31_t
) ((q63_t
) x2
* (0x7FFFFFFF - yfract
) >> 32));
7035 acc
+= ((q31_t
) ((q63_t
) out
* (xfract
) >> 32));
7037 /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
7038 out
= ((q31_t
) ((q63_t
) y1
* (0x7FFFFFFF - xfract
) >> 32));
7039 acc
+= ((q31_t
) ((q63_t
) out
* (yfract
) >> 32));
7041 /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
7042 out
= ((q31_t
) ((q63_t
) y2
* (xfract
) >> 32));
7043 acc
+= ((q31_t
) ((q63_t
) out
* (yfract
) >> 32));
7045 /* Convert acc to 1.31(q31) format */
7051 * @brief Q15 bilinear interpolation.
7052 * @param[in,out] *S points to an instance of the interpolation structure.
7053 * @param[in] X interpolation coordinate in 12.20 format.
7054 * @param[in] Y interpolation coordinate in 12.20 format.
7055 * @return out interpolated value.
7058 static __INLINE q15_t
arm_bilinear_interp_q15(
7059 arm_bilinear_interp_instance_q15
* S
,
7063 q63_t acc
= 0; /* output */
7064 q31_t out
; /* Temporary output */
7065 q15_t x1
, x2
, y1
, y2
; /* Nearest output values */
7066 q31_t xfract
, yfract
; /* X, Y fractional parts */
7067 int32_t rI
, cI
; /* Row and column indices */
7068 q15_t
*pYData
= S
->pData
; /* pointer to output table values */
7069 uint32_t nCols
= S
->numCols
; /* num of rows */
7071 /* Input is in 12.20 format */
7072 /* 12 bits for the table index */
7073 /* Index value calculation */
7074 rI
= ((X
& 0xFFF00000) >> 20);
7076 /* Input is in 12.20 format */
7077 /* 12 bits for the table index */
7078 /* Index value calculation */
7079 cI
= ((Y
& 0xFFF00000) >> 20);
7081 /* Care taken for table outside boundary */
7082 /* Returns zero output when values are outside table boundary */
7083 if(rI
< 0 || rI
> (S
->numRows
- 1) || cI
< 0 || cI
> (S
->numCols
- 1))
7088 /* 20 bits for the fractional part */
7089 /* xfract should be in 12.20 format */
7090 xfract
= (X
& 0x000FFFFF);
7092 /* Read two nearest output values from the index */
7093 x1
= pYData
[(rI
) + nCols
* (cI
)];
7094 x2
= pYData
[(rI
) + nCols
* (cI
) + 1u];
7097 /* 20 bits for the fractional part */
7098 /* yfract should be in 12.20 format */
7099 yfract
= (Y
& 0x000FFFFF);
7101 /* Read two nearest output values from the index */
7102 y1
= pYData
[(rI
) + nCols
* (cI
+ 1)];
7103 y2
= pYData
[(rI
) + nCols
* (cI
+ 1) + 1u];
7105 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
7107 /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
7108 /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
7109 out
= (q31_t
) (((q63_t
) x1
* (0xFFFFF - xfract
)) >> 4u);
7110 acc
= ((q63_t
) out
* (0xFFFFF - yfract
));
7112 /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
7113 out
= (q31_t
) (((q63_t
) x2
* (0xFFFFF - yfract
)) >> 4u);
7114 acc
+= ((q63_t
) out
* (xfract
));
7116 /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
7117 out
= (q31_t
) (((q63_t
) y1
* (0xFFFFF - xfract
)) >> 4u);
7118 acc
+= ((q63_t
) out
* (yfract
));
7120 /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
7121 out
= (q31_t
) (((q63_t
) y2
* (xfract
)) >> 4u);
7122 acc
+= ((q63_t
) out
* (yfract
));
7124 /* acc is in 13.51 format and down shift acc by 36 times */
7125 /* Convert out to 1.15 format */
7131 * @brief Q7 bilinear interpolation.
7132 * @param[in,out] *S points to an instance of the interpolation structure.
7133 * @param[in] X interpolation coordinate in 12.20 format.
7134 * @param[in] Y interpolation coordinate in 12.20 format.
7135 * @return out interpolated value.
7138 static __INLINE q7_t
arm_bilinear_interp_q7(
7139 arm_bilinear_interp_instance_q7
* S
,
7143 q63_t acc
= 0; /* output */
7144 q31_t out
; /* Temporary output */
7145 q31_t xfract
, yfract
; /* X, Y fractional parts */
7146 q7_t x1
, x2
, y1
, y2
; /* Nearest output values */
7147 int32_t rI
, cI
; /* Row and column indices */
7148 q7_t
*pYData
= S
->pData
; /* pointer to output table values */
7149 uint32_t nCols
= S
->numCols
; /* num of rows */
7151 /* Input is in 12.20 format */
7152 /* 12 bits for the table index */
7153 /* Index value calculation */
7154 rI
= ((X
& 0xFFF00000) >> 20);
7156 /* Input is in 12.20 format */
7157 /* 12 bits for the table index */
7158 /* Index value calculation */
7159 cI
= ((Y
& 0xFFF00000) >> 20);
7161 /* Care taken for table outside boundary */
7162 /* Returns zero output when values are outside table boundary */
7163 if(rI
< 0 || rI
> (S
->numRows
- 1) || cI
< 0 || cI
> (S
->numCols
- 1))
7168 /* 20 bits for the fractional part */
7169 /* xfract should be in 12.20 format */
7170 xfract
= (X
& 0x000FFFFF);
7172 /* Read two nearest output values from the index */
7173 x1
= pYData
[(rI
) + nCols
* (cI
)];
7174 x2
= pYData
[(rI
) + nCols
* (cI
) + 1u];
7177 /* 20 bits for the fractional part */
7178 /* yfract should be in 12.20 format */
7179 yfract
= (Y
& 0x000FFFFF);
7181 /* Read two nearest output values from the index */
7182 y1
= pYData
[(rI
) + nCols
* (cI
+ 1)];
7183 y2
= pYData
[(rI
) + nCols
* (cI
+ 1) + 1u];
7185 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
7186 out
= ((x1
* (0xFFFFF - xfract
)));
7187 acc
= (((q63_t
) out
* (0xFFFFF - yfract
)));
7189 /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
7190 out
= ((x2
* (0xFFFFF - yfract
)));
7191 acc
+= (((q63_t
) out
* (xfract
)));
7193 /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
7194 out
= ((y1
* (0xFFFFF - xfract
)));
7195 acc
+= (((q63_t
) out
* (yfract
)));
7197 /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
7198 out
= ((y2
* (yfract
)));
7199 acc
+= (((q63_t
) out
* (xfract
)));
7201 /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
7207 * @} end of BilinearInterpolate group
7211 #if defined ( __CC_ARM ) //Keil
7213 #define multAcc_32x32_keep32_R(a, x, y) \
7214 a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
7217 #define multSub_32x32_keep32_R(a, x, y) \
7218 a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
7221 #define mult_32x32_keep32_R(a, x, y) \
7222 a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
7224 //Enter low optimization region - place directly above function definition
7225 #define LOW_OPTIMIZATION_ENTER \
7229 //Exit low optimization region - place directly after end of function definition
7230 #define LOW_OPTIMIZATION_EXIT \
7233 //Enter low optimization region - place directly above function definition
7234 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7236 //Exit low optimization region - place directly after end of function definition
7237 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7239 #elif defined(__ICCARM__) //IAR
7241 #define multAcc_32x32_keep32_R(a, x, y) \
7242 a += (q31_t) (((q63_t) x * y) >> 32)
7245 #define multSub_32x32_keep32_R(a, x, y) \
7246 a -= (q31_t) (((q63_t) x * y) >> 32)
7249 #define mult_32x32_keep32_R(a, x, y) \
7250 a = (q31_t) (((q63_t) x * y ) >> 32)
7252 //Enter low optimization region - place directly above function definition
7253 #define LOW_OPTIMIZATION_ENTER \
7254 _Pragma ("optimize=low")
7256 //Exit low optimization region - place directly after end of function definition
7257 #define LOW_OPTIMIZATION_EXIT
7259 //Enter low optimization region - place directly above function definition
7260 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
7261 _Pragma ("optimize=low")
7263 //Exit low optimization region - place directly after end of function definition
7264 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7266 #elif defined(__GNUC__)
7268 #define multAcc_32x32_keep32_R(a, x, y) \
7269 a += (q31_t) (((q63_t) x * y) >> 32)
7272 #define multSub_32x32_keep32_R(a, x, y) \
7273 a -= (q31_t) (((q63_t) x * y) >> 32)
7276 #define mult_32x32_keep32_R(a, x, y) \
7277 a = (q31_t) (((q63_t) x * y ) >> 32)
7279 #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") ))
7281 #define LOW_OPTIMIZATION_EXIT
7283 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7285 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7298 #endif /* _ARM_MATH_H */