CMSIS DSP Software Library: arm_cmplx_dot_prod_f32.c Source File

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

- File List
- Globals

# arm_cmplx_dot_prod_f32.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_cmplx_dot_prod_f32.c
    00009 *
    00010 * Description:  Floating-point complex dot product
    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
    00077 void arm_cmplx_dot_prod_f32(
    00078   float32_t * pSrcA,
    00079   float32_t * pSrcB,
    00080   uint32_t numSamples,
    00081   float32_t * realResult,
    00082   float32_t * imagResult)
    00083 {
    00084   float32_t real_sum = 0.0f, imag_sum = 0.0f;    /* Temporary result storage */
    00085
    00086 #ifndef ARM_MATH_CM0
    00087
    00088   /* Run the below code for Cortex-M4 and Cortex-M3 */
    00089   uint32_t blkCnt;                               /* loop counter */
    00090
    00091   /*loop Unrolling */
    00092   blkCnt = numSamples >> 2u;
    00093
    00094   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
    00095    ** a second loop below computes the remaining 1 to 3 samples. */
    00096   while(blkCnt > 0u)
    00097   {
    00098     /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */
    00099     real_sum += (*pSrcA++) * (*pSrcB++);
    00100     /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */
    00101     imag_sum += (*pSrcA++) * (*pSrcB++);
    00102
    00103     real_sum += (*pSrcA++) * (*pSrcB++);
    00104     imag_sum += (*pSrcA++) * (*pSrcB++);
    00105
    00106     real_sum += (*pSrcA++) * (*pSrcB++);
    00107     imag_sum += (*pSrcA++) * (*pSrcB++);
    00108
    00109     real_sum += (*pSrcA++) * (*pSrcB++);
    00110     imag_sum += (*pSrcA++) * (*pSrcB++);
    00111
    00112     /* Decrement the loop counter */
    00113     blkCnt--;
    00114   }
    00115
    00116   /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
    00117    ** No loop unrolling is used. */
    00118   blkCnt = numSamples % 0x4u;
    00119
    00120   while(blkCnt > 0u)
    00121   {
    00122     /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */
    00123     real_sum += (*pSrcA++) * (*pSrcB++);
    00124     /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */
    00125     imag_sum += (*pSrcA++) * (*pSrcB++);
    00126
    00127
    00128     /* Decrement the loop counter */
    00129     blkCnt--;
    00130   }
    00131
    00132 #else
    00133
    00134   /* Run the below code for Cortex-M0 */
    00135
    00136   while(numSamples > 0u)
    00137   {
    00138     /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */
    00139     real_sum += (*pSrcA++) * (*pSrcB++);
    00140     /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */
    00141     imag_sum += (*pSrcA++) * (*pSrcB++);
    00142
    00143
    00144     /* Decrement the loop counter */
    00145     numSamples--;
    00146   }
    00147
    00148 #endif /* #ifndef ARM_MATH_CM0 */
    00149
    00150   /* Store the real and imaginary results in the destination buffers */
    00151   *realResult = real_sum;
    00152   *imagResult = imag_sum;
    00153 }
    00154

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines