summaryrefslogtreecommitdiff
path: root/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c
diff options
context:
space:
mode:
authorjoshua <joshua@joshuayun.com>2023-12-30 23:54:31 -0500
committerjoshua <joshua@joshuayun.com>2023-12-30 23:54:31 -0500
commit86608c6770cf08c138a2bdab5855072f64be09ef (patch)
tree494a61b3ef37e76f9235a0d10f5c93d97290a35f /Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c
downloadsdr-software-master.tar.gz
initial commitHEADmaster
Diffstat (limited to 'Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c')
-rw-r--r--Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c
new file mode 100644
index 0000000..9364619
--- /dev/null
+++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/MatrixFunctions/mat_cmplx_mult.c
@@ -0,0 +1,118 @@
+#include "ref.h"
+
+arm_status ref_mat_cmplx_mult_f32(
+ const arm_matrix_instance_f32 * pSrcA,
+ const arm_matrix_instance_f32 * pSrcB,
+ arm_matrix_instance_f32 * pDst)
+{
+ uint32_t r,c,i,outR,outC,innerSize;
+ float32_t sumR,sumI;
+ float32_t a0,b0,c0,d0;
+
+ outR = pSrcA->numRows;
+ outC = pSrcB->numCols;
+ innerSize = pSrcA->numCols;
+
+ for(r=0;r<outR;r++)
+ {
+ for(c=0;c<outC;c++)
+ {
+ sumR = 0;
+ sumI = 0;
+
+ for(i=0;i<innerSize;i++)
+ {
+ a0 = pSrcA->pData[2*(r*innerSize + i) + 0];
+ b0 = pSrcA->pData[2*(r*innerSize + i) + 1];
+ c0 = pSrcB->pData[2*(i*outC + c) + 0];
+ d0 = pSrcB->pData[2*(i*outC + c) + 1];
+
+ sumR += a0 * c0 - b0 * d0;
+ sumI += b0 * c0 + a0 * d0;
+ }
+
+ pDst->pData[2*(r*outC + c) + 0] = sumR;
+ pDst->pData[2*(r*outC + c) + 1] = sumI;
+ }
+ }
+
+ return ARM_MATH_SUCCESS;
+}
+
+arm_status ref_mat_cmplx_mult_q31(
+ const arm_matrix_instance_q31 * pSrcA,
+ const arm_matrix_instance_q31 * pSrcB,
+ arm_matrix_instance_q31 * pDst)
+{
+ uint32_t r,c,i,outR,outC,innerSize;
+ q63_t sumR,sumI;
+ q31_t a0,b0,c0,d0;
+
+ outR = pSrcA->numRows;
+ outC = pSrcB->numCols;
+ innerSize = pSrcA->numCols;
+
+ for(r=0;r<outR;r++)
+ {
+ for(c=0;c<outC;c++)
+ {
+ sumR = 0;
+ sumI = 0;
+
+ for(i=0;i<innerSize;i++)
+ {
+ a0 = pSrcA->pData[2*(r*innerSize + i) + 0];
+ b0 = pSrcA->pData[2*(r*innerSize + i) + 1];
+ c0 = pSrcB->pData[2*(i*outC + c) + 0];
+ d0 = pSrcB->pData[2*(i*outC + c) + 1];
+
+ sumR += (q63_t)a0 * c0 - (q63_t)b0 * d0;
+ sumI += (q63_t)b0 * c0 + (q63_t)a0 * d0;
+ }
+
+ pDst->pData[2*(r*outC + c) + 0] = ref_sat_q31(sumR >> 31);
+ pDst->pData[2*(r*outC + c) + 1] = ref_sat_q31(sumI >> 31);
+ }
+ }
+
+ return ARM_MATH_SUCCESS;
+}
+
+arm_status ref_mat_cmplx_mult_q15(
+ const arm_matrix_instance_q15 * pSrcA,
+ const arm_matrix_instance_q15 * pSrcB,
+ arm_matrix_instance_q15 * pDst)
+{
+ uint32_t r,c,i,outR,outC,innerSize;
+ q63_t sumR,sumI;
+ q15_t a0,b0,c0,d0;
+
+ outR = pSrcA->numRows;
+ outC = pSrcB->numCols;
+ innerSize = pSrcA->numCols;
+
+ for(r=0;r<outR;r++)
+ {
+ for(c=0;c<outC;c++)
+ {
+ sumR = 0;
+ sumI = 0;
+
+ for(i=0;i<innerSize;i++)
+ {
+ a0 = pSrcA->pData[2*(r*innerSize + i) + 0];
+ b0 = pSrcA->pData[2*(r*innerSize + i) + 1];
+ c0 = pSrcB->pData[2*(i*outC + c) + 0];
+ d0 = pSrcB->pData[2*(i*outC + c) + 1];
+
+ sumR += (q31_t)a0 * c0 - (q31_t)b0 * d0;
+ sumI += (q31_t)b0 * c0 + (q31_t)a0 * d0;
+ }
+
+ pDst->pData[2*(r*outC + c) + 0] = ref_sat_q15(sumR >> 15);
+ pDst->pData[2*(r*outC + c) + 1] = ref_sat_q15(sumI >> 15);
+ }
+ }
+
+ return ARM_MATH_SUCCESS;
+}