complex.cpp

来自「MFC编写的一个FFT算法实现」· C++ 代码 · 共 38 行

CPP
38
字号
// complex.cpp: implementation of the complex class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "sun.h"
#include "complex.h"
#include<math.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

complex operator+(const complex & c1,const complex & c2){
	return complex(c1.Real+c2.Real,c1.Image+c2.Image);
}
complex operator-(const complex & c1,const complex & c2){
	return complex(c1.Real-c2.Real,c1.Image-c2.Image);
}
complex operator*(const complex & c1,const complex & c2){
	return complex(c1.Real*c2.Real-c1.Image*c2.Image,c1.Real*c2.Image+c2.Real*c1.Image);
}

void complex:: operator=(const complex & c){
	Real=c.Real;
	Image=c.Image;
}

double complex::arg(){
	return(atan(Image/Real)/(4*atan(1.0))*180);

}

⌨️ 快捷键说明

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