00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 29. November 2010 00005 * $Revision: V1.0.3 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 00013 * 00014 * Version 1.0.3 2010/11/29 00015 * Re-organized the CMSIS folders and updated documentation. 00016 * 00017 * Version 1.0.2 2010/11/11 00018 * Documentation updated. 00019 * 00020 * Version 1.0.1 2010/10/05 00021 * Production release and review comments incorporated. 00022 * 00023 * Version 1.0.0 2010/09/20 00024 * Production release and review comments incorporated. 00025 * 00026 * Version 0.0.5 2010/04/26 00027 * incorporated review comments and updated with latest CMSIS layer 00028 * 00029 * Version 0.0.3 2010/03/10 00030 * Initial version 00031 * -------------------------------------------------------------------- */ 00032 00033 #include "arm_math.h" 00034 00072 arm_status arm_mat_scale_f32( 00073 const arm_matrix_instance_f32 * pSrc, 00074 float32_t scale, 00075 arm_matrix_instance_f32 * pDst) 00076 { 00077 float32_t *pIn = pSrc->pData; /* input data matrix pointer */ 00078 float32_t *pOut = pDst->pData; /* output data matrix pointer */ 00079 uint32_t numSamples; /* total number of elements in the matrix */ 00080 uint32_t blkCnt; /* loop counters */ 00081 arm_status status; /* status of matrix scaling */ 00082 00083 #ifdef ARM_MATH_MATRIX_CHECK 00084 /* Check for matrix mismatch condition */ 00085 if((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols)) 00086 { 00087 /* Set status as ARM_MATH_SIZE_MISMATCH */ 00088 status = ARM_MATH_SIZE_MISMATCH; 00089 } 00090 else 00091 #endif 00092 { 00093 /* Total number of samples in the input matrix */ 00094 numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; 00095 00096 /* Loop Unrolling */ 00097 blkCnt = numSamples >> 2; 00098 00099 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00100 ** a second loop below computes the remaining 1 to 3 samples. */ 00101 while(blkCnt > 0u) 00102 { 00103 /* C(m,n) = A(m,n) * scale */ 00104 /* Scaling and results are stored in the destination buffer. */ 00105 *pOut++ = (*pIn++) * scale; 00106 *pOut++ = (*pIn++) * scale; 00107 *pOut++ = (*pIn++) * scale; 00108 *pOut++ = (*pIn++) * scale; 00109 00110 /* Decrement the numSamples loop counter */ 00111 blkCnt--; 00112 } 00113 00114 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00115 ** No loop unrolling is used. */ 00116 blkCnt = numSamples % 0x4u; 00117 00118 while(blkCnt > 0u) 00119 { 00120 /* C(m,n) = A(m,n) * scale */ 00121 /* The results are stored in the destination buffer. */ 00122 *pOut++ = (*pIn++) * scale; 00123 00124 /* Decrement the loop counter */ 00125 blkCnt--; 00126 } 00127 00128 /* Set status as ARM_MATH_SUCCESS */ 00129 status = ARM_MATH_SUCCESS; 00130 } 00131 00132 /* Return to application */ 00133 return (status); 00134 } 00135