Diana Software
QComplex.hh
Go to the documentation of this file.
1 
6 #ifndef __QCOMPLEX_HH_
7 #define __QCOMPLEX_HH_
8 
9 #include <gsl/gsl_complex.h>
10 //#include <gsl/gsl_vector_complex_double.h>
11 #include "QObject.hh"
12 //#include "QVectorC.hh"
13 #include <iostream>
14 
16 
17 class QVectorC;
18 
19 class QComplex : public QObject {
20 public:
24  QComplex();
25 
32  QComplex(const double Re, const double Im=0);
37  QComplex(const QComplex& orig);
38  ~QComplex();
42  void Clear() {fData[0]=fData[1]=Q_DOUBLE_DEFAULT;};
43  double Re() const;
44  double Im() const;
45  void SetRe(const double Re);
46  void SetIm(const double Im);
47  void Set(const double Re, const double Im);
48  void SetPolar(const double mag, const double phase);
49  double GetModulusSquare() const;
50  double GetMagnitude() const;
51  double GetPhase() const;
52  QComplex Conj() const;
53  QComplex operator+(const QComplex& other) const;
54  QComplex operator-(const QComplex& other) const;
55  QComplex operator*(const QComplex& other) const;
56  QComplex operator/(const QComplex& other) const;
57  QComplex& operator+=(const QComplex& other);
58  QComplex& operator-=(const QComplex& other);
59  QComplex& operator*=(const QComplex& other);
60  QComplex& operator/=(const QComplex& other);
61  QComplex operator+(const double other) const;
62  QComplex operator-(const double other) const;
63  QComplex operator*(const double other) const;
64  QComplex operator/(const double other) const;
65  QComplex& operator+=(const double other);
66  QComplex& operator-=(const double other);
67  QComplex& operator*=(const double other);
68  QComplex& operator/=(const double other);
69 
70  QVectorC operator*(const QVectorC& vec) const;
71 
72  const QComplex& operator=(const QComplex& other);
73 
74 private:
75  // QComplex(gsl_complex* other);
76  QComplex(double* other);
77  QComplex(gsl_complex* other);
78  QComplex(gsl_complex other);
79 
80  gsl_complex Get_gsl_complex() const ;
81 
82  bool fOwner;
83  int fSize;
84  double* fData; //[fSize]
85 
86  friend class QVectorC;
87  friend class QMatrixC;
88 
90 };
91 
93 
94 // operations other than member functions
95 Diana::QComplex operator*(double t, const Diana::QComplex& z);
96 Diana::QComplex operator/(double t, const Diana::QComplex& z);
100 Diana::QComplex pow(const Diana::QComplex &z,double a);
104 Diana::QComplex pow(const Diana::QComplex &z,const Diana::QComplex &a);
108 double Re(const Diana::QComplex &z);
112 double Im(const Diana::QComplex &z);
113 
114 
115 
116 // formatted printout
117 std::ostream& operator<<(std::ostream& s,const Diana::QComplex& z);
118 
119 #endif
TF1 a
Definition: CheckOF.C:21
QVector vec(3)
std::ostream & operator<<(std::ostream &s, const Diana::QComplex &z)
Definition: QComplex.cc:264
Diana::QComplex pow(const Diana::QComplex &z, double a)
Raise a complex number to a real power.
Definition: QComplex.cc:246
Diana::QComplex operator/(double t, const Diana::QComplex &z)
Definition: QComplex.cc:242
double Im(const Diana::QComplex &z)
Function to get the imag part.
Definition: QComplex.cc:262
double Re(const Diana::QComplex &z)
Function to get the real part.
Definition: QComplex.cc:260
Q_END_NAMESPACE Diana::QComplex operator*(double t, const Diana::QComplex &z)
Definition: QComplex.cc:237
#define Q_DOUBLE_DEFAULT
Definition: QDiana.hh:24
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
QComplex operator+(const QComplex &other) const
Definition: QComplex.cc:106
double * fData
Definition: QComplex.hh:84
QComplex & operator*=(const QComplex &other)
Definition: QComplex.cc:144
void SetIm(const double Im)
Definition: QComplex.cc:76
QComplex & operator+=(const QComplex &other)
Definition: QComplex.cc:130
~QComplex()
Definition: QComplex.cc:67
double Im() const
Definition: QComplex.cc:73
QComplex & operator-=(const QComplex &other)
Definition: QComplex.cc:137
double GetPhase() const
Definition: QComplex.cc:96
gsl_complex Get_gsl_complex() const
Definition: QComplex.cc:223
void SetRe(const double Re)
Definition: QComplex.cc:75
QComplex Conj() const
Definition: QComplex.cc:101
double Re() const
Definition: QComplex.cc:72
QComplex()
default constructor
Definition: QComplex.cc:18
QComplex operator-(const QComplex &other) const
Definition: QComplex.cc:111
bool fOwner
Definition: QComplex.hh:82
QObjectDef(QComplex, 2)
double GetModulusSquare() const
Definition: QComplex.cc:86
void Set(const double Re, const double Im)
Definition: QComplex.cc:79
const QComplex & operator=(const QComplex &other)
Definition: QComplex.cc:201
QComplex operator/(const QComplex &other) const
Definition: QComplex.cc:123
void Clear()
clear
Definition: QComplex.hh:42
QComplex & operator/=(const QComplex &other)
Definition: QComplex.cc:150
int fSize
Definition: QComplex.hh:83
double GetMagnitude() const
Definition: QComplex.cc:91
QComplex operator*(const QComplex &other) const
Definition: QComplex.cc:116
void SetPolar(const double mag, const double phase)
Definition: QComplex.cc:82
Interface for complex matrices in Diana analysis.
Definition: QMatrixC.hh:27
base class for objects handled by QEvent and QGlobalDataManager.
Definition: QObject.hh:76
Interface for complex vectors in Diana analysis.
Definition: QVectorC.hh:25