00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef ROO_COMPLEX
00017 #define ROO_COMPLEX
00018
00019 #include <math.h>
00020 #include "Rtypes.h"
00021 #include "Riosfwd.h"
00022
00023
00024
00025
00026
00027
00028
00029 class RooComplex {
00030 public:
00031 inline RooComplex(Double_t a=0, Double_t b=0) : _re(a), _im(b) { }
00032 virtual ~RooComplex() {} ;
00033 inline RooComplex& operator=(const RooComplex& other) {
00034 if (&other==this) return *this ;
00035 this->_re= other._re;
00036 this->_im= other._im;
00037 return(*this);
00038 }
00039
00040 inline RooComplex operator-() const {
00041 return RooComplex(-_re,-_im);
00042 }
00043
00044 inline RooComplex operator+(const RooComplex& other) const {
00045 return RooComplex(this->_re + other._re, this->_im + other._im);
00046 }
00047 inline RooComplex operator-(const RooComplex& other) const {
00048 return RooComplex(this->_re - other._re, this->_im - other._im);
00049 }
00050 inline RooComplex operator*(const RooComplex& other) const {
00051 return RooComplex(this->_re*other._re - this->_im*other._im,
00052 this->_re*other._im + this->_im*other._re);
00053 }
00054 inline RooComplex operator/(const RooComplex& other) const {
00055 Double_t x(other.abs2());
00056 return RooComplex((this->_re*other._re + this->_im*other._im)/x,
00057 (this->_im*other._re - this->_re*other._im)/x);
00058 }
00059 inline RooComplex operator*(const Double_t& other) const {
00060 return RooComplex(this->_re*other,this->_im*other);
00061 }
00062
00063
00064 inline Bool_t operator==(const RooComplex& other) const {
00065 return (_re==other._re && _im==other._im) ;
00066 }
00067
00068
00069 inline Double_t re() const {
00070 return _re;
00071 }
00072 inline Double_t im() const {
00073 return _im;
00074 }
00075 inline Double_t abs() const {
00076 return ::sqrt(_re*_re + _im*_im);
00077 }
00078 inline Double_t abs2() const {
00079 return _re*_re + _im*_im;
00080 }
00081 inline RooComplex exp() const {
00082 Double_t mag(::exp(_re));
00083 return RooComplex(mag*cos(_im),mag*sin(_im));
00084 }
00085 inline RooComplex conj() const {
00086 return RooComplex(_re,-_im);
00087 }
00088 inline RooComplex sqrt() const {
00089 Double_t arg=atan2(_im,_re)*0.5;
00090 Double_t mag=::sqrt(::sqrt(_re*_re + _im*_im));
00091 return RooComplex(mag*cos(arg),mag*sin(arg));
00092 }
00093
00094 void Print() const;
00095 private:
00096 Double_t _re,_im;
00097 ClassDef(RooComplex,0)
00098 };
00099
00100
00101 ostream& operator<<(ostream& os, const RooComplex& z);
00102
00103 #endif