Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | #include "ref.h" |
| 2 | |||
| 3 | arm_status ref_mat_scale_f32( |
||
| 4 | const arm_matrix_instance_f32 * pSrc, |
||
| 5 | float32_t scale, |
||
| 6 | arm_matrix_instance_f32 * pDst) |
||
| 7 | { |
||
| 8 | uint32_t i; |
||
| 9 | uint32_t numSamples; /* total number of elements in the matrix */ |
||
| 10 | |||
| 11 | /* Total number of samples in the input matrix */ |
||
| 12 | numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; |
||
| 13 | |||
| 14 | for(i=0;i<numSamples;i++) |
||
| 15 | { |
||
| 16 | pDst->pData[i] = pSrc->pData[i] * scale; |
||
| 17 | } |
||
| 18 | |||
| 19 | return ARM_MATH_SUCCESS; |
||
| 20 | } |
||
| 21 | |||
| 22 | arm_status ref_mat_scale_q31( |
||
| 23 | const arm_matrix_instance_q31 * pSrc, |
||
| 24 | q31_t scale, |
||
| 25 | int32_t shift, |
||
| 26 | arm_matrix_instance_q31 * pDst) |
||
| 27 | { |
||
| 28 | uint32_t i; |
||
| 29 | uint32_t numSamples; /* total number of elements in the matrix */ |
||
| 30 | int32_t totShift = shift + 1; |
||
| 31 | q31_t tmp; |
||
| 32 | |||
| 33 | /* Total number of samples in the input matrix */ |
||
| 34 | numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; |
||
| 35 | |||
| 36 | for(i=0;i<numSamples;i++) |
||
| 37 | { |
||
| 38 | tmp = ((q63_t)pSrc->pData[i] * scale) >> 32; |
||
| 39 | pDst->pData[i] = ref_sat_q31((q63_t)tmp << totShift ); |
||
| 40 | } |
||
| 41 | |||
| 42 | return ARM_MATH_SUCCESS; |
||
| 43 | } |
||
| 44 | |||
| 45 | arm_status ref_mat_scale_q15( |
||
| 46 | const arm_matrix_instance_q15 * pSrc, |
||
| 47 | q15_t scale, |
||
| 48 | int32_t shift, |
||
| 49 | arm_matrix_instance_q15 * pDst) |
||
| 50 | { |
||
| 51 | uint32_t i; |
||
| 52 | uint32_t numSamples; /* total number of elements in the matrix */ |
||
| 53 | int32_t totShift = 15 - shift; |
||
| 54 | |||
| 55 | /* Total number of samples in the input matrix */ |
||
| 56 | numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; |
||
| 57 | |||
| 58 | for(i=0;i<numSamples;i++) |
||
| 59 | { |
||
| 60 | pDst->pData[i] = ref_sat_q15( ((q31_t)pSrc->pData[i] * scale) >> totShift); |
||
| 61 | } |
||
| 62 | |||
| 63 | return ARM_MATH_SUCCESS; |
||
| 64 | } |