BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
DifComplex.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: DifComplex.h,v 1.2 2009/12/23 02:59:56 zhangy Exp $
4//
5// Description:
6// Class Header for |DifComplex|
7// Represent a complex diffential number
8//
9// Environment:
10// Software developed for the BaBar Detector at the SLAC B-Factory.
11//
12// Author List:
13// A. Snyder
14//
15// Copyright Information:
16// Copyright (C) 1997 SLAC
17//
18// History:
19// Migration for BESIII MDC
20//
21//------------------------------------------------------------------------Dif
22
23#ifndef DifComplex_H
24#define DifComplex_H
25
26#include <assert.h>
27#include <stdlib.h>
29
30class ostream;
31
33
34public:
35
36 //constructors
37 inline DifComplex();
38 inline DifComplex(const DifNumber& r);
39 inline DifComplex(double r);
40 inline DifComplex(const DifNumber& r,const DifNumber& i);
41 inline DifComplex(double r,double i);
42 inline DifComplex(const DifComplex& c);
43
44 //access
45 inline const DifNumber& real()const {return _r;}
46 inline DifNumber& gimeReal(){return _r;}
47 inline const DifNumber& imag()const {return _i;}
48 inline DifNumber& gimeImag(){return _i;}
49
50 //set
51 void setReal(const DifNumber& r) {_r=r;}
52 void setImag(const DifNumber& i) {_i=i;}
53
54 //operators and such
55 inline DifComplex& operator+=(const DifComplex& a);
56 inline DifComplex& operator-=(const DifComplex& a);
57 inline DifComplex& operator*=(const DifComplex& a);
58 inline DifComplex& operator/=(const DifComplex& a);
59 inline DifComplex& operator/=(const DifNumber& a);
60 inline DifComplex& operator=(const DifComplex& a);
61 inline DifComplex operator-()const;
62
63 //manupulate *this guy - reverse polish style
64 inline DifComplex& conjugate(); // take complex conjugate
65 inline DifComplex& inverse(); // invert
66 inline DifComplex& flipsign(); // flip sign
67 inline DifComplex& takeLog(); // take log
68 inline DifComplex& power(const DifNumber& p); // raise to a power
69 inline DifComplex& power(const DifComplex& p); // raise to a power
70
71 //complex specfic function
72 inline DifNumber mag()const; // magnitude
73 inline DifNumber magsq()const; // magnitude squared
74 inline DifNumber arg()const; // phase
75 inline DifNumber phase()const {return arg();} // a rose by ...
76
77 //io
78 inline void print()const;
79
80 //friends
81 inline friend DifComplex operator+(const DifComplex& a,const DifComplex& b);
82 inline friend DifComplex operator-(const DifComplex& a,const DifComplex& b);
83 inline friend DifComplex operator*(const DifComplex& a,const DifComplex& b);
84 inline friend DifComplex operator/(const DifComplex& a,const DifComplex& b);
85 inline friend bool operator==(const DifComplex& a,const DifComplex& b);
86 inline friend bool operator!=(const DifComplex& a,const DifComplex& b);
87 inline friend DifComplex sin(const DifComplex& a);
88 inline friend DifComplex cos(const DifComplex& a);
89 inline friend DifComplex tan(const DifComplex &a);
90 inline friend DifComplex sec(const DifComplex &a);
91 inline friend DifComplex asin(const DifComplex &a);
92 inline friend DifComplex acos(const DifComplex &a);
93 inline friend DifComplex atan(const DifComplex &a);
94 inline friend DifComplex atan2(const DifComplex& a,const DifComplex& b);
95 inline friend DifComplex exp(const DifComplex& a);
96 inline friend DifComplex cosh(const DifComplex& a);
97 inline friend DifComplex sinh(const DifComplex& a);
98 inline friend DifComplex tanh(const DifComplex& a);
99 inline friend DifComplex sqrt(const DifComplex& a);
100 inline friend DifComplex log(const DifComplex& a);
101 inline friend DifComplex pow(const DifComplex& a,const DifComplex& p);
102 inline friend DifComplex pow(const DifComplex& a,const DifNumber& p);
103 inline friend DifComplex cc(const DifComplex& a);
104 inline friend DifComplex fromPolar
105 (const DifNumber& mag,const DifNumber& phase);
106
107
108
109 //destructor
110 inline virtual ~DifComplex(){};
111
112private:
113
114 //data
115 DifNumber _r;
116 DifNumber _i;
117
118 //functions
119 inline DifNumber& gimeR() {return _r;}
120 inline DifNumber& gimeI() {return _i;}
121 inline const DifNumber& R()const {return _r;}
122 inline const DifNumber& I()const {return _i;}
123};
124
125#include "MdcRecoUtil/DifComplex.icc"
126/*del**
127inline ostream& operator<<(ostream& o,const DifComplex& c){
128 c.print(o);
129 return o;
130}
131 */
132#endif
133
134
135
136
137
friend DifComplex sinh(const DifComplex &a)
DifComplex & power(const DifComplex &p)
const DifNumber & imag() const
Definition: DifComplex.h:47
friend DifComplex asin(const DifComplex &a)
DifComplex & conjugate()
friend DifComplex operator+(const DifComplex &a, const DifComplex &b)
friend DifComplex sin(const DifComplex &a)
friend DifComplex exp(const DifComplex &a)
void setImag(const DifNumber &i)
Definition: DifComplex.h:52
DifNumber magsq() const
DifNumber & gimeReal()
Definition: DifComplex.h:46
DifComplex & operator/=(const DifNumber &a)
friend DifComplex atan(const DifComplex &a)
friend DifComplex acos(const DifComplex &a)
virtual ~DifComplex()
Definition: DifComplex.h:110
friend bool operator==(const DifComplex &a, const DifComplex &b)
DifComplex(const DifComplex &c)
DifComplex & power(const DifNumber &p)
friend DifComplex cc(const DifComplex &a)
friend DifComplex atan2(const DifComplex &a, const DifComplex &b)
friend DifComplex operator/(const DifComplex &a, const DifComplex &b)
DifNumber & gimeImag()
Definition: DifComplex.h:48
DifNumber mag() const
friend DifComplex operator-(const DifComplex &a, const DifComplex &b)
friend DifComplex fromPolar(const DifNumber &mag, const DifNumber &phase)
friend DifComplex pow(const DifComplex &a, const DifNumber &p)
friend bool operator!=(const DifComplex &a, const DifComplex &b)
friend DifComplex cosh(const DifComplex &a)
DifNumber phase() const
Definition: DifComplex.h:75
friend DifComplex sqrt(const DifComplex &a)
DifComplex & operator+=(const DifComplex &a)
DifComplex & operator=(const DifComplex &a)
DifComplex & operator/=(const DifComplex &a)
DifNumber arg() const
friend DifComplex tanh(const DifComplex &a)
friend DifComplex pow(const DifComplex &a, const DifComplex &p)
friend DifComplex log(const DifComplex &a)
DifComplex & inverse()
friend DifComplex cos(const DifComplex &a)
DifComplex operator-() const
DifComplex & operator-=(const DifComplex &a)
friend DifComplex operator*(const DifComplex &a, const DifComplex &b)
void print() const
friend DifComplex tan(const DifComplex &a)
friend DifComplex sec(const DifComplex &a)
const DifNumber & real() const
Definition: DifComplex.h:45
DifComplex & operator*=(const DifComplex &a)
DifComplex(const DifNumber &r)
DifComplex(const DifNumber &r, const DifNumber &i)
DifComplex(double r)
DifComplex & flipsign()
void setReal(const DifNumber &r)
Definition: DifComplex.h:51
DifComplex & takeLog()
DifComplex(double r, double i)
std::ostream ostream
Definition: bpkt_streams.h:41
const double b
Definition: slope.cxx:9