26 #include "EvtGenBase/EvtConst.hh"
41 inline friend double abs2(
const EvtComplex& c);
43 inline friend double real(
const EvtComplex& c);
44 inline friend double imag(
const EvtComplex& c);
46 friend std::ostream& operator<<(std::ostream& s,
const EvtComplex& c);
50 EvtComplex(
double rpart,
double ipart=0.0):_rpart(rpart),_ipart(ipart){}
151 double Num=d/(c._rpart*c._rpart+c._ipart*c._ipart);
153 return EvtComplex( Num*c._rpart, -Num*c._ipart );
161 double inv=1.0/(c2._rpart*c2._rpart+c2._ipart*c2._ipart);
163 return EvtComplex(inv*(c1._rpart*c2._rpart+c1._ipart*c2._ipart),
164 inv*(c1._ipart*c2._rpart-c1._rpart*c2._ipart));
170 return EvtComplex(c1._rpart*c2._rpart-c1._ipart*c2._ipart,
171 c1._rpart*c2._ipart+c1._ipart*c2._rpart);
177 return EvtComplex(c1._rpart-c2._rpart,c1._ipart-c2._ipart);
183 return EvtComplex(c1._rpart+c2._rpart,c1._ipart+c2._ipart);
187 int EvtComplex::operator==(
const EvtComplex c){
189 return _rpart==c._rpart&&_ipart==c._ipart;
193 int EvtComplex::operator!=(
const EvtComplex c){
195 return _rpart!=c._rpart||_ipart!=c._ipart;
214 double c2=c._rpart*c._rpart+c._ipart*c._ipart;
215 if (c2<=0.0)
return 0.0;
223 return c._rpart*c._rpart+c._ipart*c._ipart;
228 if ((c._rpart==0)&&(c._ipart==0)) {
return 0.0;}
231 return EvtConst::pi/2;
233 return -EvtConst::pi/2;
236 return atan2(c._ipart,c._rpart);
254 return exp(c._rpart)*
EvtComplex(cos(c._ipart),sin(c._ipart));