CMSIS DSP Software Library: arm_min_q7.c Source File

- Main Page
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

# arm_min_q7.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------
    00002 * Copyright (C) 2010 ARM Limited. All rights reserved.
    00003 *
    00004 * $Date:        15. July 2011
    00005 * $Revision:    V1.0.10
    00006 *
    00007 * Project:      CMSIS DSP Library
    00008 * Title:        arm_min_q7.c
    00009 *
    00010 * Description:  Minimum value of a Q7 vector.
    00011 *
    00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
    00013 *
    00014 * Version 1.0.10 2011/7/15
    00015 *    Big Endian support added and Merged M0 and M3/M4 Source code.
    00016 *
    00017 * Version 1.0.3 2010/11/29
    00018 *    Re-organized the CMSIS folders and updated documentation.
    00019 *
    00020 * Version 1.0.2 2010/11/11
    00021 *    Documentation updated.
    00022 *
    00023 * Version 1.0.1 2010/10/05
    00024 *    Production release and review comments incorporated.
    00025 *
    00026 * Version 1.0.0 2010/09/20
    00027 *    Production release and review comments incorporated.
    00028 * ---------------------------------------------------------------------------- */
    00029
    00030 #include "arm_math.h"
    00031
    00052 void arm_min_q7(
    00053   q7_t * pSrc,
    00054   uint32_t blockSize,
    00055   q7_t * pResult,
    00056   uint32_t * pIndex)
    00057 {
    00058
    00059 #ifndef ARM_MATH_CM0
    00060
    00061   /* Run the below code for Cortex-M4 and Cortex-M3 */
    00062
    00063   q7_t minVal, minVal1, minVal2, res, x0, x1;    /* Temporary variables to store the output value. */
    00064   uint32_t blkCnt, indx, index1, index2, index3, indxMod;       /* loop counter */
    00065
    00066   /* Initialise the index value to zero. */
    00067   indx = 0u;
    00068
    00069   /* Load first input value that act as reference value for comparision */
    00070   res = *pSrc++;
    00071
    00072   /* Loop over blockSize number of values */
    00073   blkCnt = (blockSize - 1u) >> 2u;
    00074
    00075   while(blkCnt > 0u)
    00076   {
    00077     indxMod = blockSize - (blkCnt * 4u);
    00078
    00079     /* Load two input values for comparision */
    00080     x0 = *pSrc++;
    00081     x1 = *pSrc++;
    00082
    00083     if(x0 > x1)
    00084     {
    00085       /* Update the minimum value and its index */
    00086       minVal1 = x1;
    00087       index1 = indxMod + 1u;
    00088     }
    00089     else
    00090     {
    00091       /* Update the minimum value and its index */
    00092       minVal1 = x0;
    00093       index1 = indxMod;
    00094     }
    00095
    00096     /* Load two input values for comparision */
    00097     x0 = *pSrc++;
    00098     x1 = *pSrc++;
    00099
    00100     if(x0 > x1)
    00101     {
    00102       /* Update the minimum value and its index */
    00103       minVal2 = x1;
    00104       index2 = indxMod + 3u;
    00105     }
    00106     else
    00107     {
    00108       /* Update the minimum value and its index */
    00109       minVal2 = x0;
    00110       index2 = indxMod + 2u;
    00111     }
    00112
    00113     if(minVal1 > minVal2)
    00114     {
    00115       /* Update the minimum value and its index */
    00116       minVal = minVal2;
    00117       index3 = index2;
    00118     }
    00119     else
    00120     {
    00121       /* Update the minimum value and its index */
    00122       minVal = minVal1;
    00123       index3 = index1;
    00124     }
    00125
    00126     if(res > minVal)
    00127     {
    00128       /* Update the minimum value and its index */
    00129       res = minVal;
    00130       indx = index3;
    00131     }
    00132
    00133     /* Decrement the loop counter */
    00134     blkCnt--;
    00135
    00136   }
    00137
    00138   blkCnt = (blockSize - 1u) % 0x04u;
    00139
    00140   while(blkCnt > 0u)
    00141   {
    00142     /* Initialize minVal to the next consecutive values one by one */
    00143     minVal = *pSrc++;
    00144
    00145     /* compare for the minimum value */
    00146     if(res > minVal)
    00147     {
    00148       /* Update the minimum value and its index */
    00149       res = minVal;
    00150       indx = blockSize - blkCnt;
    00151     }
    00152
    00153     /* Decrement the loop counter */
    00154     blkCnt--;
    00155   }
    00156
    00157   /* Store the minimum value and its index into destination pointers */
    00158   *pResult = res;
    00159   *pIndex = indx;
    00160
    00161 #else
    00162
    00163   /* Run the below code for Cortex-M0 */
    00164
    00165   q7_t minVal, out;                              /* Temporary variables to store the output value. */
    00166   uint32_t blkCnt, outIndex;                     /* loop counter */
    00167
    00168   /* Initialise the index value to zero. */
    00169   outIndex = 0u;
    00170
    00171   /* Load first input value that act as reference value for comparision */
    00172   out = *pSrc++;
    00173
    00174   /* Loop over blockSize - 1 number of values */
    00175   blkCnt = (blockSize - 1u);
    00176
    00177   while(blkCnt > 0u)
    00178   {
    00179     /* Initialize minVal to the next consecutive values one by one */
    00180     minVal = *pSrc++;
    00181
    00182     /* compare for the minimum value */
    00183     if(out > minVal)
    00184     {
    00185       /* Update the minimum value and its index */
    00186       out = minVal;
    00187       outIndex = blockSize - blkCnt;
    00188     }
    00189
    00190     /* Decrement the loop counter */
    00191     blkCnt--;
    00192   }
    00193
    00194   /* Store the minimum value and its index into destination pointers */
    00195   *pResult = out;
    00196   *pIndex = outIndex;
    00197
    00198 #endif /* #ifndef ARM_MATH_CM0 */
    00199
    00200 }
    00201

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines