📄 useful_functions.c
字号:
// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -