OpComplex Class Reference

#include <OpComplex.h>

List of all members.

Public Member Functions

 OpComplex ()
 OpComplex (Double_t real, Double_t imaginary)
 ~OpComplex ()
Double_t GetReal () const
Double_t GetImaginary () const
Double_t GetModulus () const
Double_t GetArgument () const
Double_t Re () const
Double_t Im () const
OpComplex GetConjugate () const
void SetReal (Double_t real)
void SetImaginary (Double_t imaginary)
void SetArgument (Double_t argument)
void SetModulus (Double_t modulus)
OpComplexoperator= (const OpComplex &)
OpComplex operator+ (const OpComplex &)
OpComplex operator- (const OpComplex &)
OpComplex operator* (const OpComplex &) const
OpComplex operator/ (const OpComplex &)

Protected Member Functions

Double_t CalculateArgument (Double_t real, Double_t imaginary)

Protected Attributes

Double_t fModulus
Double_t fArgument

Detailed Description

Definition at line 6 of file OpComplex.h.


Constructor & Destructor Documentation

OpComplex::OpComplex (  ) 

Definition at line 8 of file OpComplex.cxx.

00009 {
00010   fModulus = 0;
00011   fArgument = 0;
00012 }

OpComplex::OpComplex ( Double_t  real,
Double_t  imaginary 
)

Definition at line 20 of file OpComplex.cxx.

References fArgument, and fModulus.

00021 {
00022   fModulus = modulus;
00023   fArgument = argument;
00024 
00025 }

OpComplex::~OpComplex (  ) 

Definition at line 14 of file OpComplex.cxx.

00015 {
00016 
00017 }


Member Function Documentation

Double_t OpComplex::CalculateArgument ( Double_t  real,
Double_t  imaginary 
) [protected]

Definition at line 126 of file OpComplex.cxx.

Referenced by SetImaginary(), and SetReal().

00127 {
00128   if(imaginary == 0) {
00129     if(real >= 0) {
00130       return 0;
00131     }
00132     if(real < 0) {
00133       return TMath::Pi();
00134     }
00135   }
00136 
00137   if(real == 0) {
00138     if(imaginary >= 0) {
00139       return TMath::Pi() / 2;
00140     }
00141     if(imaginary < 0) {
00142       return -1 * TMath::Pi() / 2;
00143     }
00144   }
00145 
00146   Double_t tan = imaginary / real; 
00147 
00148   if(imaginary > 0) {
00149     if(real > 0) {
00150       return TMath::ATan(tan);
00151     }
00152     if(real < 0) {
00153       return TMath::Pi() + TMath::ATan(tan);
00154     }
00155   }
00156 
00157   if(imaginary < 0) {
00158     if(real > 0) {
00159       return  TMath::ATan(tan);
00160     }
00161     if(real < 0) {
00162       return (-1. * TMath::Pi()) + TMath::ATan(tan);
00163     }
00164   }
00165 
00166   return 0;
00167 }

Double_t OpComplex::GetArgument (  )  const

Definition at line 53 of file OpComplex.cxx.

References fArgument.

Referenced by operator*(), and operator/().

00054 {
00055   return fArgument;
00056 }

OpComplex OpComplex::GetConjugate (  )  const

Definition at line 118 of file OpComplex.cxx.

References GetImaginary(), GetReal(), SetImaginary(), and SetReal().

00119 {
00120   OpComplex tmp;
00121   tmp.SetReal(GetReal());
00122   tmp.SetImaginary(-1 * GetImaginary());
00123   return tmp;
00124 }

Double_t OpComplex::GetImaginary (  )  const

Definition at line 40 of file OpComplex.cxx.

References fArgument, and fModulus.

Referenced by GetConjugate(), Im(), operator+(), and operator-().

00041 {
00042   return fModulus * TMath::Sin(fArgument);
00043 }

Double_t OpComplex::GetModulus (  )  const

Definition at line 46 of file OpComplex.cxx.

References fModulus.

Referenced by OpProbability::GetProbability(), operator*(), and operator/().

00047 {
00048   return fModulus;
00049 }

Double_t OpComplex::GetReal (  )  const

Definition at line 35 of file OpComplex.cxx.

References fArgument, and fModulus.

Referenced by GetConjugate(), operator+(), operator-(), and Re().

00036 {
00037   return fModulus * TMath::Cos(fArgument);
00038 }

Double_t OpComplex::Im (  )  const

Definition at line 113 of file OpComplex.cxx.

References GetImaginary().

Referenced by SetReal().

00114 {
00115   return GetImaginary();
00116 }

OpComplex OpComplex::operator* ( const OpComplex a  )  const [inline]

Definition at line 68 of file OpComplex.h.

References GetArgument(), GetModulus(), SetImaginary(), and SetReal().

00068                                                                {
00069   OpComplex tmp;
00070   Double_t r = this->GetModulus() * a.GetModulus();
00071   Double_t theta = this->GetArgument() + a.GetArgument();
00072   tmp.SetReal( r * TMath::Cos(theta) );
00073   tmp.SetImaginary( r * TMath::Sin(theta) );
00074   return tmp;
00075 }

OpComplex OpComplex::operator+ ( const OpComplex a  )  [inline]

Definition at line 52 of file OpComplex.h.

References GetImaginary(), GetReal(), SetImaginary(), and SetReal().

00052                                                          {
00053   OpComplex tmp;
00054   tmp.SetReal( this->GetReal() + a.GetReal() );
00055   tmp.SetImaginary( this->GetImaginary() + a.GetImaginary());
00056   return tmp;
00057 }

OpComplex OpComplex::operator- ( const OpComplex a  )  [inline]

Definition at line 60 of file OpComplex.h.

References GetImaginary(), GetReal(), SetImaginary(), and SetReal().

00060                                                          {
00061   OpComplex tmp;
00062   tmp.SetReal( this->GetReal() - a.GetReal() );
00063   tmp.SetImaginary( this->GetImaginary() - a.GetImaginary());
00064   return tmp;
00065 }

OpComplex OpComplex::operator/ ( const OpComplex a  )  [inline]

Definition at line 77 of file OpComplex.h.

References GetArgument(), GetModulus(), SetImaginary(), and SetReal().

00077                                                          {
00078   OpComplex tmp;
00079   Double_t r = this->GetModulus() / a.GetModulus();
00080   Double_t theta = this->GetArgument() - a.GetArgument();
00081   tmp.SetReal( r * TMath::Cos(theta) );
00082   tmp.SetImaginary( r * TMath::Sin(theta) );
00083   return tmp;
00084 }

OpComplex & OpComplex::operator= ( const OpComplex a  )  [inline]

Definition at line 46 of file OpComplex.h.

References fArgument, and fModulus.

00046                                                               {
00047       fModulus = a.fModulus;
00048       fArgument = a.fArgument;
00049       return *this;
00050     }

Double_t OpComplex::Re (  )  const

Definition at line 107 of file OpComplex.cxx.

References GetReal().

Referenced by SetImaginary().

00108 {
00109   return GetReal();
00110 }

void OpComplex::SetArgument ( Double_t  argument  ) 

Definition at line 58 of file OpComplex.cxx.

References fArgument.

Referenced by OpProbability::Calculate_U_e(), OpProbability::Calculate_X_Matrix(), SetImaginary(), and SetReal().

00059 {
00060   fArgument = argument;
00061 }

void OpComplex::SetImaginary ( Double_t  imaginary  ) 

Definition at line 90 of file OpComplex.cxx.

References CalculateArgument(), Re(), SetArgument(), and SetModulus().

Referenced by GetConjugate(), operator*(), operator+(), operator-(), and operator/().

00091 {
00092   Double_t real = Re();
00093   Double_t r = TMath::Sqrt( (real * real) + (imaginary * imaginary) );
00094   Double_t theta = CalculateArgument(real, imaginary);
00095 
00096 //    cout << "In SetImaginary():" << endl;
00097 //    cout << " Real part: " << real << endl;
00098 //    cout << " Imaginary part: " << imaginary << endl;
00099 //    cout << " r: " << r << endl;
00100 //    cout << " theta: " << theta << endl;
00101 
00102   
00103   SetModulus(r);
00104   SetArgument(theta);
00105 }

void OpComplex::SetModulus ( Double_t  modulus  ) 

Definition at line 63 of file OpComplex.cxx.

References fModulus.

Referenced by OpProbability::Calculate_U_e(), OpProbability::Calculate_X_Matrix(), SetImaginary(), and SetReal().

00064 {
00065   if(modulus < 0) {
00066     cout << "Cannot have negative modulus" << endl;
00067     return;
00068   }
00069 
00070   fModulus = modulus;
00071 }

void OpComplex::SetReal ( Double_t  real  ) 

Definition at line 73 of file OpComplex.cxx.

References CalculateArgument(), Im(), SetArgument(), and SetModulus().

Referenced by OpProbability::Calculate_H_Matrix(), OpProbability::Calculate_U_e(), OpProbability::Calculate_U_mu(), OpProbability::Calculate_U_tau(), OpProbability::Calculate_X_Matrix(), GetConjugate(), operator*(), operator+(), operator-(), and operator/().

00074 {
00075   Double_t imaginary = Im();
00076   Double_t r = TMath::Sqrt( (real * real) + (imaginary * imaginary) );
00077   Double_t theta = CalculateArgument(real, imaginary);
00078 
00079 //    cout << "In SetReal():" << endl;
00080 //    cout << " Real part: " << real << endl;
00081 //    cout << " Imaginary part: " << imaginary << endl;
00082 //    cout << " r: " << r << endl;
00083 //    cout << " theta: " << theta << endl;
00084 
00085   
00086   SetModulus(r);
00087   SetArgument(theta);
00088 }


Member Data Documentation

Double_t OpComplex::fArgument [protected]

Definition at line 37 of file OpComplex.h.

Referenced by GetArgument(), GetImaginary(), GetReal(), OpComplex(), operator=(), and SetArgument().

Double_t OpComplex::fModulus [protected]

Definition at line 36 of file OpComplex.h.

Referenced by GetImaginary(), GetModulus(), GetReal(), OpComplex(), operator=(), and SetModulus().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1