complex_math.c

来自「完整的OFDM系统,含Matlab仿真代码和DSP源代码下载.平台Tms320C」· C语言 代码 · 共 38 行

C
38
字号
//complex_math.c
//
// Project Red 2002: High Performance OFDM Modem 
// Against Channel Imperfections
// Auther: Linus Falk

//calculates the complex multiplication, returns in xy.
void complex_multiplication(float xy[2], float ab[2]){
	float re = 0;
	float im = 0;

	re = xy[0]*ab[0] - xy[1]*ab[1];
	im = xy[1]*ab[0] + xy[0]*ab[1];
	xy[0] = re;
	xy[1] = im;
}

//calculates the complex division, returns in xy;
void complex_division(float xy[2], float ab[2]){
	float div_factor = 0;
	
	div_factor = _rcpsp(ab[0]*ab[0] + ab[1]*ab[1]);
	
	ab[1] *= -1; // conjugate
	complex_multiplication(xy,ab);
	ab[1] *= -1; // conjugate back
	xy[0] *= div_factor;
	xy[1] *= div_factor;
	
}

//calculates |xy|^2, returns in value
void complex_abs_sqr(float xy[2], float *value){
	*value = xy[0]*xy[0] + xy[1]*xy[1];	
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?