complex.h

来自「A good resource for 2D FFT and DCT」· C头文件 代码 · 共 67 行

H
67
字号
// Complex.h: interface for the CComplex class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_COMPLEX_H__774B1FF0_7414_490F_AB45_53B7AD4EF228__INCLUDED_)
#define AFX_COMPLEX_H__774B1FF0_7414_490F_AB45_53B7AD4EF228__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define PI 3.14159265358979323846

class CComplex
{
public:
	CComplex(const double & Real = 0, const double & Imag = 0):
	  Re(Real), Im(Imag) {}
	CComplex(const CComplex & Rhs):
	  Re(Rhs.Re), Im(Rhs.Im) {}

	~CComplex() {}

	const CComplex & operator=(const CComplex & Rhs);
	const CComplex & operator=(const double & Rhs);
	const CComplex & operator+=(const CComplex & Rhs);
	const CComplex & operator+=(const double & Rhs);
	const CComplex & operator-=(const CComplex & Rhs);
	const CComplex & operator-=(const double & Rhs);
	const CComplex & operator*=(const CComplex & Rhs);
	const CComplex & operator*=(const double & Rhs);
	const CComplex & operator/=(const CComplex & Rhs);
	const CComplex & operator/=(const double & Rhs);

	CComplex operator+(const CComplex &  Rhs) const;
	CComplex operator+(const double &  Rhs) const;
	CComplex operator-(const CComplex &  Rhs) const;
	CComplex operator-(const double &  Rhs) const;
	CComplex operator*(const CComplex &  Rhs) const;
	CComplex operator*(const double &  Rhs) const;
	CComplex operator/(const CComplex &  Rhs) const;
	CComplex operator/(const double &  Rhs) const;

	bool operator!=(const CComplex & Rhs) const;
	bool operator!=(const double & Rhs) const;
	bool operator==(const CComplex & Rhs) const;
	bool operator==(const double & Rhs) const;
	
	CComplex operator-() const;

	double GetReal() {return Re;}
	void SetReal(double Real) {Re = Real;}
	double GetImag() {return Im;}
	void SetImag(double Imag) {Im = Imag;}
	const CComplex & Rotate(double angle);
	const CComplex & Normalize();

	double GetAbs();
	double GetComplexAngle();

private:
	double Re;
	double Im;
};

#endif // !defined(AFX_COMPLEX_H__774B1FF0_7414_490F_AB45_53B7AD4EF228__INCLUDED_)

⌨️ 快捷键说明

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