📄 tcomplex.h
字号:
template <class Tradius,class Tangle> void ToPolar (Tradius * radius,Tangle * angle)
{ Extended a,b; this->ToPolar(&a,&b); *radius=a; *angle=b; }
void ToPolar (Extended * radius,Extended * angle);
template <class T> void Add (const std::complex<T> & x) { this->_Re+=x.real(); this->_Im+=x.imag(); }
template <class T> void Sub (const std::complex<T> & x) { this->_Re-=x.real(); this->_Im-=x.imag(); }
template <class T> void Mul (const std::complex<T> & x) { this->Mul(TComplex(x)); }
template <class T> void Div (const std::complex<T> & x) { this->Div(TComplex(x)); }
void Add (const TComplex & x);
void Sub (const TComplex & x);
void Mul (const TComplex & x);
void Div (const TComplex & x);
void Add (const long double & x) { this->_Re+=x; }
void Sub (const long double & x) { this->_Re-=x; }
void Mul (const long double & x) { this->_Re*=x; this->_Im*=x; }
void Div (const long double & x) { Extended r(x); r.Rev(); this->_Re*=r; this->_Im*=r; }
void Add (const double & x) { this->_Re+=x; }
void Sub (const double & x) { this->_Re-=x; }
void Mul (const double & x) { this->_Re*=x; this->_Im*=x; }
void Div (const double & x) { Extended r(x); r.Rev(); this->_Re*=r; this->_Im*=r; }
void Add (const float & x) { this->_Re+=x; }
void Sub (const float & x) { this->_Re-=x; }
void Mul (const float & x) { this->_Re*=x; this->_Im*=x; }
void Div (const float & x) { Extended r(x); r.Rev(); this->_Re*=r; this->_Im*=r; }
void Add (const _int64 & x) { this->_Re+=x; }
void Sub (const _int64 & x) { this->_Re-=x; }
void Mul (const _int64 & x) { this->_Re*=x; this->_Im*=x; }
void Div (const _int64 & x) { Extended r(x); r.Rev(); this->_Re*=r; this->_Im*=r; }
void Add (const int & x) { this->_Re+=x; }
void Sub (const int & x) { this->_Re-=x; }
void Mul (const int & x) { this->_Re*=x; this->_Im*=x; }
void Div (const int & x) { Extended r(x); r.Rev(); this->_Re*=r; this->_Im*=r; }
void Add (const Extended & x) { this->_Re+=x; }
void Sub (const Extended & x) { this->_Re-=x; }
void Mul (const Extended & x) { this->_Re*=x; this->_Im*=x; }
void Div (const Extended & x) { Extended r(x); r.Rev(); this->_Re*=r; this->_Im*=r; }
//复数绝对值、取整、距离函数
void Abs () ; //x=|Z| 绝对值
void AbsSqr () ; //x=|Z|^2
void AbsA () ; //Z.x=abs(Z.x);Z.y=abs(Z.y)
void Distance(const TComplex& x ); //|Z-x|
void Floor () ; //Z=Floor(Z) //取整,小于x的最大整数
void Ceil () ; //Z=Ceil(Z) //取整,大于x的最小整数
void Trunc () ; //Z=Trunc(Z) //向零取整,即截断
void Round () ; //Z=Round(Z) //四舍五入到整数
//单位虚数、归一化、共轭、虚实交换、倒数 、求符号
void Chs (); //Z=-Z //求负
void Zero (); //Z=0 //得零
void Imag1 (); //Z.y=1,Z.x=0
void Unity () ; //Z=Z/|Z| //归一化
void Conj () ; //Z.x=Z.x; Z.y=-Z.y //共轭
void Flip () ; //Z.x=Z.y; Z.y=Z.x //虚实交换
void Rev () ; //Z=1/Z //倒数
void Sgn (); //Z=Sgn(Z) //求符号
template <class T> void Xchg(T * x) { TComplex r(*x); this->Xchg(&r); *x=r; }
void Xchg (TComplex* x); //Z<=>x) //交换值
//复数次方
void Sqr () ; //Z=Z*Z //平方
void Sqr3 () ; //Z=Z^3 //立方
void Sqr4 () ; //Z=Z^4 //四次方
void Power (const TComplex & x); //Z=Z^x
void Exp () ; //Z=Exp(Z) //e^Z
void Sqrt (); //Z=Sqrt(Z)
//复数对数
void Ln () ; //Z=Ln(Z)
void Log2 () ; //Z=Log2(Z)
void Log10 () ; //Z=Log10(Z)
//复数三角函数
void Sin () ; //Z=Sin(Z)
void Cos () ; //Z=Cos(Z)
void Tan () ; //Z=Tan(Z)
void Cot () ; //Z=Cotan(Z) => 1/tan(Z)
void Csc () ; //Z=Csc(Z) => 1/sin(Z)
void Sec () ; //Z=Sec(Z) => 1/Cos(Z)
void ArcSin () ; //Z=ArcSin(Z)
void ArcCos () ; //Z=ArcCos(Z)
void ArcTan () ; //Z=ArcTan(Z)
void ArcCsc () ; //Z=ArcCsc(Z)
void ArcSec () ; //Z=ArcSec(Z)
void ArcCot () ; //Z=ArcCot(Z)
void SinH () ; //Z=SinH(Z)
void CosH () ; //Z=CosH(Z)
void TanH () ; //Z=TanH(Z)
void CotH () ; //Z=CotanH(Z)
void CscH () ; //Z=CscH(Z) => 1/sinH(Z)
void SecH () ; //Z=SecH(Z) => 1/CosH(Z)
void ArcSinH () ; //Z=ArcSinH(Z)
void ArcCosH () ; //Z=ArcCosH(Z)
void ArcTanH () ; //Z=ArcTanH(Z)
void ArcCscH () ; //Z=ArcCscH(Z)
void ArcSecH () ; //Z=ArcSecH(Z)
void ArcCotH () ; //Z=ArcCotH(Z)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//用下面的函数来支持表达式连写
//复数绝对值、取整、距离函数
friend const Extended C_Abs (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Abs(); return Zr; } //x=|Z1| 绝对值
friend const Extended C_AbsSqr (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.AbsSqr(); return Zr; } //x=|Z1|^2
friend const TComplex C_AbsA (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.AbsA(); return Zr; } //Z.x=abs(Z1.x);Z.y=abs(Z1.y)
friend const Extended C_Distance(const TComplex& Z1,const TComplex& Z2 ) { TComplex Zr(Z1); Zr.Distance(Z2); return Zr; } //x=|Z1-Z2|
friend const TComplex C_Floor (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Floor(); return Zr; } //Z=Floor(Z1) //取整,小于x的最大整数
friend const TComplex C_Ceil (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Ceil(); return Zr; } //Z=Ceil(Z1) //取整,大于x的最小整数
friend const TComplex C_Trunc (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Trunc(); return Zr; } //Z=Trunc(Z1) //向零取整,即截断
friend const TComplex C_Round (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Round(); return Zr; } //Z=Round(Z1) //四舍五入到整数
//单位虚数、归一化、共轭、虚实交换、倒数 、求符号
friend const TComplex C_Zero () { return TComplex(0); } //Z=0
friend const TComplex C_Imag1 () { return TComplex(0,1); } //Z.y=1,Z.x=0
friend const TComplex C_Unity (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Unity(); return Zr; } //Z=Z1/|Z1| //归一化
friend const TComplex C_Conj (const TComplex& Z1 ) { return TComplex(Z1._Re,-Z1._Im); } //Z.x=Z1.x; Z.y=-Z1.y //共轭
friend const TComplex C_Flip (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Flip(); return Zr; } //Z.x=Z1.y; Z.y=Z1.x //虚实交换
friend const TComplex C_Rev (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Rev(); return Zr; } //Z=1/Z1 //倒数
friend const TComplex C_Sgn (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Sgn(); return Zr; } //Z=Sgn(Z1) //求符号
template <class T> friend void C_Xchg(T *Z1,TComplex *Z2 ) { Z2->Xchg(Z1); }
template <class T> friend void C_Xchg(TComplex *Z1,T *Z2 ) { Z1->Xchg(Z2); }
friend void C_Xchg (TComplex *Z1 ,TComplex *Z2 ) { Z1->Xchg(Z2); } //Z1<=>Z2) //交换值
//复数次方
friend const TComplex C_Sqr (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Sqr(); return Zr; } //Z=Z1*Z1 //平方
friend const TComplex C_Sqr3 (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Sqr3(); return Zr; } //Z=Z1^3 //立方
friend const TComplex C_Sqr4 (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Sqr4(); return Zr; } //Z=Z1^4 //四次方
friend const TComplex C_Power (const TComplex& Z1,TComplex Z2) { TComplex Zr(Z1); Zr.Power(Z2); return Zr; } //Z=Z1^Z2
friend const TComplex C_Exp (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Exp(); return Zr; } //Z=Exp(Z1) //e^Z1
friend const TComplex C_Sqrt (const TComplex& Z1) { TComplex Zr(Z1); Zr.Sqrt(); return Zr; } //Z=Sqrt(Z1)
//复数对数
friend const TComplex C_Ln (const TComplex& Z1) { TComplex Zr(Z1); Zr.Ln(); return Zr; } //Z=Ln(Z1)
friend const TComplex C_Log2 (const TComplex& Z1) { TComplex Zr(Z1); Zr.Log2(); return Zr; } //Z=Log2(Z1)
friend const TComplex C_Log10 (const TComplex& Z1) { TComplex Zr(Z1); Zr.Log10(); return Zr; } //Z=Log10(Z1)
//复数三角函数
friend const TComplex C_Sin (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Sin(); return Zr; } //Z=Sin(Z1)
friend const TComplex C_Cos (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Cos(); return Zr; } //Z=Cos(Z1)
friend const TComplex C_Tan (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Tan(); return Zr; } //Z=Tan(Z1)
friend const TComplex C_Cot (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Cot(); return Zr; } //Z=Cotan(Z1) => 1/tan(Z1)
friend const TComplex C_Csc (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Csc(); return Zr; } //Z=Csc(Z1) => 1/sin(Z1)
friend const TComplex C_Sec (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.Sec(); return Zr; } //Z=Sec(Z1) => 1/Cos(Z1)
friend const TComplex C_ArcSin (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcSin(); return Zr; }//Z=ArcSin(Z1)
friend const TComplex C_ArcCos (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcCos(); return Zr; }//Z=ArcCos(Z1)
friend const TComplex C_ArcTan (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcTan(); return Zr; }//Z=ArcTan(Z1)
friend const TComplex C_ArcCsc (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcCsc(); return Zr; }//Z=ArcCsc(Z1)
friend const TComplex C_ArcSec (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcSec(); return Zr; }//Z=ArcSec(Z1)
friend const TComplex C_ArcCot (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcCot(); return Zr; }//Z=ArcCot(Z1)
friend const TComplex C_SinH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.SinH(); return Zr; } //Z=SinH(Z1)
friend const TComplex C_CosH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.CosH(); return Zr; } //Z=CosH(Z1)
friend const TComplex C_TanH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.TanH(); return Zr; } //Z=TanH(Z1)
friend const TComplex C_CotH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.CotH(); return Zr; } //Z=CotanH(Z1)
friend const TComplex C_CscH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.CscH(); return Zr; } //Z=CscH(Z1) => 1/sinH(Z1)
friend const TComplex C_SecH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.SecH(); return Zr; } //Z=SecH(Z1) => 1/CosH(Z1)
friend const TComplex C_ArcSinH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcSinH(); return Zr; }//Z=ArcSinH(Z1)
friend const TComplex C_ArcCosH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcCosH(); return Zr; }//Z=ArcCosH(Z1)
friend const TComplex C_ArcTanH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcTanH(); return Zr; }//Z=ArcTanH(Z1)
friend const TComplex C_ArcCscH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcCscH(); return Zr; }//Z=ArcCscH(Z1)
friend const TComplex C_ArcSecH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcSecH(); return Zr; }//Z=ArcSecH(Z1)
friend const TComplex C_ArcCotH (const TComplex& Z1 ) { TComplex Zr(Z1); Zr.ArcCotH(); return Zr; }//Z=ArcCotH(Z1)
};
#endif // !defined(HSS_TComplex_H__A57E05A1_BEDC_4A25_81D6_DB59EE1982E6__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -