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