⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complex.cpp

📁 这是一个非常经典的FourierTransform 算法比较有新意
💻 CPP
字号:
// complex.cpp: implementation of the Complex class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "complex.h"

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

Complex::Complex(double x, double y)
:m_dReal(x), m_dImage(y)
{
}

Complex::Complex(Complex &x)
{
	this->m_dReal = x.m_dReal;
	this->m_dImage = x.m_dImage;
}

Complex::~Complex()
{

}
Complex operator *(Complex x, Complex y)
{
	
	
	return Complex(x.m_dReal*y.m_dReal-x.m_dImage*y.m_dImage, x.m_dReal*y.m_dImage+x.m_dImage*y.m_dReal);
}

Complex Complex::operator /= (Complex x)
{
	double module = x.m_dImage*x.m_dImage + x.m_dReal*x.m_dReal;
	double a, b;
	a = m_dReal*x.m_dReal + m_dImage*x.m_dImage;
	b = m_dImage*x.m_dReal - m_dReal*x.m_dImage;
	m_dReal = a/module;
	m_dImage = b/module;
	return *this;
}

Complex Complex::operator += (Complex x)
{
	this->m_dReal += x.m_dReal;
	this->m_dImage += x.m_dImage;
	return *this;
}


Complex Complex::operator / (Complex x)
{
	double module = x.m_dImage*x.m_dImage + x.m_dReal*x.m_dReal;
	double a, b;
	a = m_dReal*x.m_dReal + m_dImage*x.m_dImage;
	b = m_dImage*x.m_dReal - m_dReal*x.m_dImage;
	return Complex(a/module,b/module);
}


Complex operator -(Complex x, Complex y)
{
	Complex r;
	r.m_dReal = x.m_dReal -y.m_dReal;
	r.m_dImage = x.m_dImage -y.m_dImage;
	return r;
}

Complex operator +(Complex x, Complex y)
{
	Complex r;
	r.m_dReal = x.m_dReal + y.m_dReal;
	r.m_dImage = x.m_dImage + y.m_dImage;
	return r;
}

ostream& operator << (ostream& output, Complex x)
{
	output << "(" << x.m_dReal << "," << x.m_dImage << ")";
	return output;
}

Complex operator --(Complex x)//前置
{
	x.m_dReal--;
	return x;
}

Complex operator --(Complex x, int) //后置
{
	Complex temp(x);
//	temp.m_dReal = x.m_dReal;
//	temp.m_dImage = x.m_dImage;
	x.m_dReal--;
	return temp;
}



Complex Complex::operator ++(void)//前置
{
	this->m_dReal++;
	return *this;
}
Complex Complex::operator ++(int) //后置
{
	Complex temp(*this);
//	temp.m_dReal = this->m_dReal;
//	temp.m_dImage = this->m_dImage;
	this->m_dReal ++;
	return temp;
}

int Complex::operator !()
{	
	if (*this == 0)
		return 1;
	else 
		return 0;
}

int Complex::operator ==(Complex op)
{
	if((m_dReal == op.m_dReal)&&(m_dImage == op.m_dImage))
		return 1;
	else
		return 0;
}

⌨️ 快捷键说明

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