CMSIS DSP Software Library: arm_mat_scale_f32.c Source File

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

- File List
- Globals

# arm_mat_scale_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_mat_scale_f32.c
    00009 *
    00010 * Description:  Multiplies a floating-point matrix by a scalar.
    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 * Version 0.0.5  2010/04/26
    00030 *    incorporated review comments and updated with latest CMSIS layer
    00031 *
    00032 * Version 0.0.3  2010/03/10
    00033 *    Initial version
    00034 * -------------------------------------------------------------------- */
    00035
    00036 #include "arm_math.h"
    00037
    00075 arm_status arm_mat_scale_f32(
    00076   const arm_matrix_instance_f32 * pSrc,
    00077   float32_t scale,
    00078   arm_matrix_instance_f32 * pDst)
    00079 {
    00080   float32_t *pIn = pSrc->pData;                  /* input data matrix pointer */
    00081   float32_t *pOut = pDst->pData;                 /* output data matrix pointer */
    00082   uint32_t numSamples;                           /* total number of elements in the matrix */
    00083   uint32_t blkCnt;                               /* loop counters */
    00084   arm_status status;                             /* status of matrix scaling     */
    00085
    00086 #ifdef ARM_MATH_MATRIX_CHECK
    00087
    00088
    00089   /* Check for matrix mismatch condition */
    00090   if((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols))
    00091   {
    00092     /* Set status as ARM_MATH_SIZE_MISMATCH */
    00093     status = ARM_MATH_SIZE_MISMATCH;
    00094   }
    00095   else
    00096 #endif /*    #ifdef ARM_MATH_MATRIX_CHECK    */
    00097
    00098   {
    00099     /* Total number of samples in the input matrix */
    00100     numSamples = (uint32_t) pSrc->numRows * pSrc->numCols;
    00101
    00102 #ifndef ARM_MATH_CM0
    00103
    00104     /* Run the below code for Cortex-M4 and Cortex-M3 */
    00105
    00106     /* Loop Unrolling */
    00107     blkCnt = numSamples >> 2;
    00108
    00109     /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
    00110      ** a second loop below computes the remaining 1 to 3 samples. */
    00111     while(blkCnt > 0u)
    00112     {
    00113       /* C(m,n) = A(m,n) * scale */
    00114       /* Scaling and results are stored in the destination buffer. */
    00115       *pOut++ = (*pIn++) * scale;
    00116       *pOut++ = (*pIn++) * scale;
    00117       *pOut++ = (*pIn++) * scale;
    00118       *pOut++ = (*pIn++) * scale;
    00119
    00120       /* Decrement the numSamples loop counter */
    00121       blkCnt--;
    00122     }
    00123
    00124     /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
    00125      ** No loop unrolling is used. */
    00126     blkCnt = numSamples % 0x4u;
    00127
    00128 #else
    00129
    00130     /* Run the below code for Cortex-M0 */
    00131
    00132     /* Initialize blkCnt with number of samples */
    00133     blkCnt = numSamples;
    00134
    00135 #endif /* #ifndef ARM_MATH_CM0 */
    00136
    00137     while(blkCnt > 0u)
    00138     {
    00139       /* C(m,n) = A(m,n) * scale */
    00140       /* The results are stored in the destination buffer. */
    00141       *pOut++ = (*pIn++) * scale;
    00142
    00143       /* Decrement the loop counter */
    00144       blkCnt--;
    00145     }
    00146     /* Set status as ARM_MATH_SUCCESS */
    00147     status = ARM_MATH_SUCCESS;
    00148   }
    00149
    00150   /* Return to application */
    00151   return (status);
    00152 }
    00153

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines