evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtComplex.cpp
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
21 #include "EvtGenBase/EvtComplex.hh"
22 
23 #include "EvtGenBase/EvtPatches.hh"
24 
25 #include <iostream>
26 #include <math.h>
27 using std::ostream;
28 
29 ostream& operator<<( ostream& s, const EvtComplex& c )
30 {
31  s << "(" << c._rpart << "," << c._ipart << ")";
32  return s;
33 }
34 
36 {
37  double r = _rpart * c._rpart - _ipart * c._ipart;
38  double i = _rpart * c._ipart + _ipart * c._rpart;
39 
40  _rpart = r;
41  _ipart = i;
42 
43  return *this;
44 }
45 
47 {
48  double inv = 1.0 / ( c._rpart * c._rpart + c._ipart * c._ipart );
49 
50  double r = inv * ( _rpart * c._rpart + _ipart * c._ipart );
51  double i = inv * ( _ipart * c._rpart - _rpart * c._ipart );
52 
53  _rpart = r;
54  _ipart = i;
55 
56  return *this;
57 }
EvtComplex & operator/=(double d)
Definition: EvtComplex.hh:142
double _rpart
Definition: EvtComplex.hh:74
double _ipart
Definition: EvtComplex.hh:74
ostream & operator<<(ostream &s, const EvtComplex &c)
Definition: EvtComplex.cpp:29
EvtComplex & operator *=(double d)
Definition: EvtComplex.hh:134