complex.cpp

来自「MFC编写的一个FIR的程序」· C++ 代码 · 共 60 行

CPP
60
字号
// 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));

}

double complex::abs()
{
	return sqrt(Real*Real+Image*Image);

}

double complex::ShowReal()
{return Real;

}



void complex::daon(int n)
{ Real=Real/n;
  Image=Image/n;

}


⌨️ 快捷键说明

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