useful_functions.c
来自「详细的OFDM设计过程」· C语言 代码 · 共 51 行
C
51 行
// some useful functions
#include "useful_functions.h"
void div_element(const float *x, const float *y, float *z, const int count)
{
int i;
for (i=0; i <= count-2; i+=2)
{
z[i] = (x[i]*y[i]+x[i+1]*y[i+1])*(_rcpsp(y[i]*y[i]+y[i+1]*y[i+1]));
z[i+1] = (x[i+1]*y[i]-x[i]*y[i+1])*(_rcpsp(y[i]*y[i]+y[i+1]*y[i+1]));
//Uncomment these lines and comment the two preceeding
//to increase precision. Execution time will increase.
/*
z[i] = (x[i]*y[i]+x[i+1]*y[i+1])/(y[i]*y[i]+y[i+1]*y[i+1]);
z[i+1] = (x[i+1]*y[i]-x[i]*y[i+1])/(y[i]*y[i]+y[i+1]*y[i+1]);
*/
}
}
void prod_element_conj(const float *x, const float *y, float *z, const int count)
{
int i;
for (i=0; i <= count-2; i+=2)
{
float a=x[i]; /* temporary variable */
float b=y[i]; /* temporary variable */
z[i] = x[i]*y[i]+x[i+1]*y[i+1]; /* the real part */
z[i+1] = a*y[i+1]-x[i+1]*b; /* the imaginary part */
}
}
void square_absolute(float *x, float *y, int count)
{
int i;
for (i=0; i < count; i++) // count is the length of the output
{
y[i]=x[2*i]*x[2*i]+x[2*i+1]*x[2*i+1];
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?