This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C672x复向量点乘求助



各位大虾好!

我想做两个复数的向量点乘的函数,先是找到了库里的函数DSPF_sp_dotp_cplx,其c语言代码如下:

void DSPF_sp_dotp_cplx(const float* x, const float* y, int n,float* restrict re, float* restrict im)

{
float real=0, imag=0;
int i=0;
for(i=0; i<n; i++)
{
real+=(x[2*i]*y[2*i] - x[2*i+1]*y[2*i+1]);
imag+=(x[2*i]*y[2*i+1] + x[2*i+1]*y[2*i]);
}
*re=real;
*im=imag;
}

C语言的源代码运行速度达不到库函数的要求,相差达10倍.

上面函数是点乘后求和的.我想要的是点乘后输出一个复向量,相当于:

void DSPF_sp_dotp_cplx(const float* x, const float* y, int n,float* restrict re, float* restrict im)
{
int i=0;

for(i=0; i<n; i++)

{
re[i]=(x[2*i]*y[2*i] - x[2*i+1]*y[2*i+1]);
im[i]=(x[2*i]*y[2*i+1] + x[2*i+1]*y[2*i]);

//或者实部跟虚部在一起:

//re[2*i]=(x[2*i]*y[2*i] - x[2*i+1]*y[2*i+1]);

//re[2*i+1]=(x[2*i]*y[2*i+1] + x[2*i+1]*y[2*i]);
}
}

请问哪位大虾能提供这样的库函数,有酬谢,加qq952885169详谈.

  • C674x有复数乘的指令,可以通过intrinsic直接调用。

    long long _cmpy (unsigned src1, unsigned src2);       CMPY Performs various complex multiply operations.
    unsigned _cmpyr (unsigned src1, unsigned src2);      CMPYR
    unsigned _cmpyr1 (unsigned src1, unsigned src2 );   CMPYR1