|
楼主 |
发表于 2015-3-30 10:18:07
|
显示全部楼层
18.2 复数乘法 ComplexMultComplex
18.2.1 arm_cmplx_mult_cmplx_f32
公式描述:
for(n=0; n<numSamples; n++) {
pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
}
函数定义如下:
void arm_cmplx_mult_cmplx_f32(
float32_t * pSrcA,
float32_t * pSrcB,
float32_t * pDst,
uint32_t numSamples)
参数定义:
[in] *pSrcA points to the first input vector
[in] *pSrcB points to the second input vector
[out] *pDst points to the output vector
[in] numSamples number of complex samples in each vector
注意事项:
1. 数组pSrcA, pSrcB和pDst中存储的数据格式是(实部,虚部,实部,虚部……………)
18.2.2 arm_ cmplx_mult_cmplx_q31
公式描述:
for(n=0; n<numSamples; n++) {
pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
}
函数定义如下:
void arm_cmplx_mult_cmplx_q31(
q31_t * pSrcA,
q31_t * pSrcB,
q31_t * pDst,
uint32_t numSamples)
参数定义:
[in] *pSrc points to the complex input vector
[out] *pDst points to the real output vector
[in] numSamples number of complex samples in the input vector
注意事项:
1. 数组pSrcA, pSrcB和pDst中存储的数据格式是(实部,虚部,实部,虚部……………)
18.2.3 arm_cmplx_mult_cmplx_q15
公式描述:
for(n=0; n<numSamples; n++) {
pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
}
函数定义如下:
void arm_cmplx_mult_cmplx_q15(
q15_t * pSrcA,
q15_t * pSrcB,
q15_t * pDst,
uint32_t numSamples)
参数定义:
[in] *pSrc points to the complex input vector
[out] *pDst points to the real output vector
[in] numSamples number of complex samples in the input vector
注意事项:
1. 数组pSrcA, pSrcB和pDst中存储的数据格式是(实部,虚部,实部,虚部……………)
18.2.4 实例讲解
实验目的:
1. 学习ComplexMathFunctions中复数乘法的求解
实验内容:
1. 按下按键K2, 串口打印函数DSP_CmplxMult的输出结果
实验现象:
通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下:
程序设计:
- /*
- *********************************************************************************************************
- * 函 数 名: DSP_CmplxMult
- * 功能说明: 复数乘法
- * 形 参:无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- static void DSP_CmplxMult(void)
- {
- uint8_t i;
- float32_t pSrcA[10] = {1.1f, 1.2f, 2.1f, 2.2f, 3.1f, 3.2f, 4.1f, 4.2f, 5.1f, 5.2f};
- float32_t pSrcB[10] = {1.2f, 1.2f, 2.2f, 2.2f, 3.2f, 3.2f, 4.2f, 4.2f, 5.2f, 5.2f};
- float32_t pDst[10];
- q31_t pSrcA1[10] = {1*268435456, 1*268435456, 2*268435456, 2*268435456, 3*268435456, 3*268435456,
- 4*268435456, 4*268435456, 5*268435456, 5*268435456};
- q31_t pSrcB1[10] = {1*268435456, 1*268435456, 2*268435456, 2*268435456, 3*268435456, 3*268435456,
- 4*268435456, 4*268435456, 5*268435456, 5*268435456};
- q31_t pDst1[10];
- q15_t pSrcA2[10] = {5000, 10000, 15000, 20000, 25000, 5000, 10000, 15000, 20000, 25000};
- q15_t pSrcB2[10] = {6000, 11000, 15000, 20000, 25000, 5000, 10000, 15000, 20000, 25000};
- q15_t pDst2[10];
- /***浮点数乘法*******************************************************************************/
- arm_cmplx_mult_cmplx_f32(pSrcA, pSrcB, pDst, 5);
- for(i = 0; i < 5; i++)
- {
- printf("pDst[%d] = %f %fjrn", i, pDst[2*i], pDst[2*i+1]);
- }
- /***定点数乘法Q31*******************************************************************************/
- arm_cmplx_mult_cmplx_q31(pSrcA1, pSrcB1, pDst1, 5);
- for(i = 0; i < 5; i++)
- {
- printf("pDst1[%d] = %d %djrn", i, pDst1[2*i], pDst1[2*i+1]);
- }
- /***定点数乘法Q15*******************************************************************************/
- arm_cmplx_mult_cmplx_q15(pSrcA2, pSrcB2, pDst2, 5);
- for(i = 0; i < 5; i++)
- {
- printf("pDst1[%d] = %d %djrn", i, pDst2[2*i], pDst2[2*i+1]);
- }
- }
复制代码 |
|