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

📄 complex.h

📁 一个2D电磁场FEM计算的VC++源程序
💻 H
字号:
#include<afx.h> // just needs afx.h to define BOOL, TRUE, and FALSE
#define PI 3.141592653589793238462643383
#define SmallNo 1.e-14
#define DEG 0.01745329251994329576923690768

class CComplex
{
	public:
		// data members
		double re,im;

		// member functions
		CComplex();
		CComplex(double x);
		CComplex(int x);
		CComplex(double x, double y);
		CComplex Sqrt();
		CComplex Conj();
		CComplex Inv();
		void Set(double x, double y);
		double Abs();
		double Arg();
		double Re();
		double Im();
		char* ToString(char *s);
		
	//operator redefinition
		//Addition
		CComplex operator+( const CComplex& z );
		CComplex operator+(double z);
		CComplex operator+(int z);
		friend CComplex operator+( int x,  const CComplex& y );
		friend CComplex operator+( double x,  const CComplex& y );
		friend CComplex operator+( const CComplex& x,  const CComplex& y );
		void operator+=( const CComplex& z);
		void operator+=(double z);
		void operator+=(int z);

		//Subtraction
		CComplex operator-();
		CComplex operator-( const CComplex& z );
		CComplex operator-(double z);
		CComplex operator-(int z);
		friend CComplex operator-( int x,  const CComplex& y );
		friend CComplex operator-( double x,  const CComplex& y );
		friend CComplex operator-( const CComplex& x,  const CComplex& y );
		friend CComplex operator-( const CComplex& x );
		void operator-=( const CComplex& z);
		void operator-=(double z);
		void operator-=(int z);

		//Multiplication
		CComplex operator*( const CComplex& z );
		CComplex operator*(double z);
		CComplex operator*(int z);
		friend CComplex operator*( int x,  const CComplex& y );
		friend CComplex operator*( double x,  const CComplex& y );
		friend CComplex operator*( const CComplex& x,  const CComplex& y );
		void operator*=( const CComplex& z);
		void operator*=(double z);
		void operator*=(int z);

		//Division
		CComplex operator/( const CComplex& z );
		CComplex operator/(double z);
		CComplex operator/(int z);
		friend CComplex operator/( int x,  const CComplex& y );
		friend CComplex operator/( double x,  const CComplex& y );
		friend CComplex operator/( const CComplex &x,  const CComplex& y );
		void operator/=( const CComplex& z);
		void operator/=(double z);
		void operator/=(int z);

		//Equals
		void operator=(double z);
		void operator=(int z);

		//Tests
		BOOL operator==( const CComplex& z);
		BOOL operator==(double z);
		BOOL operator==(int z);
		BOOL operator!=( const CComplex& z);
		BOOL operator!=(double z);
		BOOL operator!=(int z);

	private:

};

// useful functions...
#define I CComplex(0,1)
double Re( const CComplex& a);
double Im( const CComplex& a);
double abs( const CComplex& x );
double arg( const CComplex& x );
CComplex conj( const CComplex& x);
CComplex exp( const CComplex& x );
CComplex sqrt( const CComplex& x );
CComplex tanh( const CComplex& x );
CComplex sinh( const CComplex& x );
CComplex cosh( const CComplex& x );
CComplex cos( const CComplex& x );
CComplex acos( const CComplex& x );
CComplex sin( const CComplex& x );
CComplex asin( const CComplex& x );
CComplex tan( const CComplex& x );
CComplex atan( const CComplex& x );
CComplex log( const CComplex& x );
CComplex pow( const CComplex& x, int y);
CComplex pow( const CComplex& x, double y);
CComplex pow( const CComplex& x,  const CComplex& y);



⌨️ 快捷键说明

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