Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

TComplex.h File Reference

#include <Riostream.h>
#include <TBuffer.h>
#include <TMath.h>

Go to the source code of this file.

Data Structures

class  TComplex
class  TCplxRhoPhi

Defines

#define TCOMPLEX_USE_DOUBLE
#define TComplexBase   Double_t

Functions

Double_t Dist (TComplex &z1, TComplex &z2)
TComplex operator+ (const Double_t x, const TComplex &z)
TComplex operator- (const Double_t x, const TComplex &z)
TComplex operator * (const Int_t x, const TComplex &z)
TComplex operator * (const Double_t x, const TComplex &z)
TComplex operator * (const TComplex &x, const TComplex &y)
TComplex operator * (TComplex &x, TComplex &y)
TComplex operator% (const TComplex &x, const TComplex &y)
TComplex operator/ (const Double_t x, const TComplex &z)
Bool_t operator== (const TComplex &z1, const TComplex &z2)
Bool_t operator!= (const TComplex &z1, const TComplex &z2)
Bool_t operator== (const TComplex &z1, const Double_t &d)
Bool_t operator!= (const TComplex &z1, const Double_t &d)
Double_t Abs (const TComplex &z)
Double_t Abs2 (const TComplex &z)
TComplex Sqrt (const TComplex &z)
TComplex Sqrt3 (const TComplex &z, Int_t k)
TComplex Exp (const TComplex &z)
TComplex Log (const TComplex &z)
TComplex Log2 (const TComplex &z)
TComplex Log10 (const TComplex &z)
TComplex Sin (const TComplex &z)
TComplex Cos (const TComplex &z)

Variables

TComplex ComplexZero
TComplex ComplexOne
TComplex I


Define Documentation

#define TCOMPLEX_USE_DOUBLE
 

Definition at line 15 of file TComplex.h.

#define TComplexBase   Double_t
 

Definition at line 18 of file TComplex.h.

Referenced by TDSPVector::RandRayleigh().


Function Documentation

Double_t Abs const TComplex z  )  [inline]
 

Definition at line 466 of file TComplex.h.

References Abs2(), and Sqrt().

Referenced by TDSPMath::BesselJ0(), TDSPStochasticScalar::ChangeRepresentation(), TComplex::CosFromSin(), TDSPSymbolGenerator::DetectSymbol(), Dist(), TDSPClip::F(), TComplex::IsComplex(), TComplex::RPhi(), and Sqrt3().

00466                                        {
00467 //Calculates the absolute value of a complex number
00468   return TMath::Sqrt(Abs2(z));
00469 }

Double_t Abs2 const TComplex z  )  [inline]
 

Definition at line 470 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

Referenced by Abs().

00470                                         {
00471 //Calculates the absolute value of a complex number
00472   return z.fRe*z.fRe + z.fIm*z.fIm;
00473 }

TComplex Cos const TComplex z  )  [inline]
 

Definition at line 588 of file TComplex.h.

References Exp(), TComplex::fIm, TComplex::fRe, and Sin().

Referenced by Exp(), TComplex::FromRhoPhi(), TDSPVector::RandRayleigh(), Sin(), and Sqrt3().

00588                                        {
00589 //Calculates the cosinus of a complex number
00590   const Double_t un   = 1.0;
00591   const Double_t deux = 2.0;
00592   TComplex zz;
00593   Double_t a,b;
00594   a = TMath::Exp(z.fIm);
00595   b = un/a;
00596   zz.fRe = ((a+b)*TMath::Cos(z.fRe))/deux;
00597   zz.fIm = ((b-a)*TMath::Sin(z.fRe))/deux;
00598   return zz;
00599 }

Double_t Dist TComplex z1,
TComplex z2
[inline]
 

Definition at line 409 of file TComplex.h.

References Abs().

00409                                                  {
00410   return Abs(z1-z2);
00411 }

TComplex Exp const TComplex z  )  [inline]
 

Definition at line 540 of file TComplex.h.

References Cos(), TComplex::fIm, TComplex::fRe, and Sin().

Referenced by Cos(), TDSPSymbolGenerator::DetectSymbol(), TDSPMath::Rayleigh(), Sin(), and Sqrt3().

00540                                        {
00541 //Calculates the exponential of a complex number
00542   register Double_t ex;
00543   TComplex zz;
00544   ex = TMath::Exp(z.fRe);
00545   zz.fRe = ex*TMath::Cos(z.fIm);
00546   zz.fIm = ex*TMath::Sin(z.fIm);
00547   return zz;
00548 }

TComplex Log const TComplex z  )  [inline]
 

Definition at line 550 of file TComplex.h.

References TComplex::fIm, TComplex::fRe, TCplxRhoPhi::GetPhi(), and TCplxRhoPhi::GetRho().

00550                                        {
00551 //Calculates the logarithm of a complex number
00552   TComplex zz;
00553   TCplxRhoPhi r(z.fRe,z.fIm);
00554   zz.fRe = TMath::Log(r.GetRho());
00555   zz.fIm = r.GetPhi();
00556   return zz;
00557 }

TComplex Log10 const TComplex z  )  [inline]
 

Definition at line 566 of file TComplex.h.

References TComplex::fIm, TComplex::fRe, TCplxRhoPhi::GetPhi(), and TCplxRhoPhi::GetRho().

Referenced by TDSPMath::dB(), and TDSPSymbolGenerator::LogSER_dB().

00566                                          {
00567 //Calculates the logarithm of a complex number
00568   TComplex zz;
00569   TCplxRhoPhi r(z.fRe,z.fIm);
00570   zz.fRe = TMath::Log10(r.GetRho());
00571   zz.fIm = r.GetPhi();
00572   return zz;
00573 }

TComplex Log2 const TComplex z  )  [inline]
 

Definition at line 558 of file TComplex.h.

References TComplex::fIm, TComplex::fRe, TCplxRhoPhi::GetPhi(), and TCplxRhoPhi::GetRho().

00558                                         {
00559 //Calculates the logarithm of a complex number
00560   TComplex zz;
00561   TCplxRhoPhi r(z.fRe,z.fIm);
00562   zz.fRe = TMath::Log2(r.GetRho());
00563   zz.fIm = r.GetPhi();
00564   return zz;
00565 }

TComplex operator * TComplex x,
TComplex y
[inline]
 

Definition at line 434 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00434                                                       {
00435 //multiplication of a complex by a complex
00436   return TComplex(x.fRe*y.fRe - x.fIm*y.fIm,x.fRe*y.fIm + x.fIm*y.fRe);
00437 }

TComplex operator * const TComplex x,
const TComplex y
[inline]
 

Definition at line 430 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00430                                                                   {
00431 //multiplication of a complex by a complex
00432   return TComplex(x.fRe*y.fRe - x.fIm*y.fIm,x.fRe*y.fIm + x.fIm*y.fRe);
00433 }

TComplex operator * const Double_t  x,
const TComplex z
[inline]
 

Definition at line 426 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00426                                                                  {
00427 //multiplication of a real by a complex
00428   return TComplex(x*z.fRe,x*z.fIm);
00429 }

TComplex operator * const Int_t  x,
const TComplex z
[inline]
 

Definition at line 422 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00422                                                               {
00423 //multiplication of a real by a complex
00424   return TComplex(x*z.fRe,x*z.fIm);
00425 }

Bool_t operator!= const TComplex z1,
const Double_t &  d
[inline]
 

Definition at line 463 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00463                                                                  {
00464   return ((z1.fRe!=d)||(z1.fIm!=0.0));
00465 }

Bool_t operator!= const TComplex z1,
const TComplex z2
[inline]
 

Definition at line 456 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00456                                                                   {
00457   return ((z1.fRe!=z2.fRe)||(z1.fIm!=z2.fIm));
00458 }

TComplex operator% const TComplex x,
const TComplex y
[inline]
 

Definition at line 438 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00438                                                                   {
00439 //multiplication of a complex-transposed by a complex
00440   return TComplex(x.fRe*y.fRe + x.fIm*y.fIm,x.fRe*y.fIm - x.fIm*y.fRe);
00441 }

TComplex operator+ const Double_t  x,
const TComplex z
[inline]
 

Definition at line 413 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00413                                                                  {
00414 //addition of a real and a complex
00415   return TComplex(x + z.fRe,z.fIm);
00416 }

TComplex operator- const Double_t  x,
const TComplex z
[inline]
 

Definition at line 418 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00418                                                                  {
00419 //substraction of a complex from a real
00420   return TComplex(x - z.fRe,-z.fIm);
00421 }

TComplex operator/ const Double_t  x,
const TComplex z
[inline]
 

Definition at line 442 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00442                                                                  {
00443 //division of a real by a complex
00444   TComplex z4;
00445   Double_t d;
00446   d = z.fRe*z.fRe + z.fIm*z.fIm;
00447   z4.fRe =  (x*z.fRe)/d;
00448   z4.fIm = -(x*z.fIm)/d;
00449   return z4;
00450 }

Bool_t operator== const TComplex z1,
const Double_t &  d
[inline]
 

Definition at line 459 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00459                                                                  {
00460   return ((z1.fRe==d)&&(z1.fIm==0.0));
00461 }

Bool_t operator== const TComplex z1,
const TComplex z2
[inline]
 

Definition at line 452 of file TComplex.h.

References TComplex::fIm, and TComplex::fRe.

00452                                                                   {
00453   return ((z1.fRe==z2.fRe)&&(z1.fIm==z2.fIm));
00454 }

TComplex Sin const TComplex z  )  [inline]
 

Definition at line 575 of file TComplex.h.

References Cos(), Exp(), TComplex::fIm, and TComplex::fRe.

Referenced by Cos(), Exp(), TComplex::FromRhoPhi(), TDSPVector::RandRayleigh(), and Sqrt3().

00575                                        {
00576 //Calculates the sinus of a complex number
00577   const Double_t un   = 1.0;
00578   const Double_t deux = 2.0;
00579   TComplex zz;
00580   Double_t a,b;
00581   a = TMath::Exp(z.fIm);
00582   b = un/a;
00583   zz.fRe = ((a+b)*TMath::Sin(z.fRe))/deux;
00584   zz.fIm = ((a-b)*TMath::Cos(z.fRe))/deux;
00585   return zz;
00586 }

TComplex Sqrt const TComplex z  )  [inline]
 

Definition at line 475 of file TComplex.h.

References TComplex::fIm, TComplex::fRe, TComplex::FromRhoPhi(), and TCplxRhoPhi::Sqrt().

Referenced by Abs(), TDSPVector::Dist(), TDSPVector::MaxAbs(), TDSPVector::MinAbs(), TDSPVector::RandRayleigh(), TComplex::RPhi(), TCplxRhoPhi::Sqrt(), TDSPVector::SqrtImag(), TDSPVector::SqrtReal(), Std(), and TCplxRhoPhi::TCplxRhoPhi().

00475                                         {
00476 //Calculates the square root of a complex number
00477   const Double_t zero = 0.0;
00478   TComplex zz;
00479   if (z.fRe >= zero) {
00480     TCplxRhoPhi r(z.fRe,z.fIm);
00481     r.Sqrt();
00482     zz.FromRhoPhi(r);
00483   }
00484   else {
00485     TCplxRhoPhi r(-z.fRe,-z.fIm);
00486     r.Sqrt();
00487     zz.FromRhoPhi(r);
00488     TComplex j(0,1);
00489     //zz = zz*j;
00490     zz*=j;
00491   }
00492   return zz;
00493 }

TComplex Sqrt3 const TComplex z,
Int_t  k
[inline]
 

Definition at line 495 of file TComplex.h.

References Abs(), Cos(), Exp(), TComplex::fIm, TComplex::fRe, TCplxRhoPhi::GetPhi(), TCplxRhoPhi::GetRho(), Pi, and Sin().

00495                                                  {
00496 //
00497 //  Calculates the cubic root of a complex number.
00498 //  If the real part is negative, calculates the cubic root of minus the complex
00499 //number and then changes the sign of the solution.
00500 //  There are 3 possible solutions. k decides which one is taken :
00501 //    - k = 0  ==>  phi --> phi/3
00502 //    - k = 1  ==>  phi --> (phi+2pi)/3
00503 //    - k = 2  ==>  phi --> (phi-2pi)/3
00504 //
00505   const Double_t zero   = 0.0;
00506   const Double_t deux   = 2.0;
00507   const Double_t trois  = 3.0;
00508   const Double_t small  = 1.0e-7;
00509   const Double_t wsmall = 1.0e-300;
00510   Double_t rho,phi;
00511   Bool_t isreal,isneg;
00512   TComplex z1,zz;
00513   isreal = (TMath::Abs(z.fIm)<wsmall);
00514   isneg  = (z.fRe<zero);
00515   if (isneg) z1 = zero - z;
00516   else       z1 = z;
00517   k      = k % 3;
00518   TCplxRhoPhi r(z1.fRe,z1.fIm);
00519   rho = r.GetRho();
00520   phi = r.GetPhi();
00521   rho = TMath::Exp(TMath::Log(rho)/trois);
00522   switch (k) {
00523   case 0:
00524     phi = phi/trois;
00525     break;
00526   case 1:
00527     phi = (phi + deux*TMath::Pi())/trois;
00528     break;
00529   case 2:
00530     phi = (phi - deux*TMath::Pi())/trois;
00531     break;
00532   }
00533   zz.fRe = rho*TMath::Cos(phi);
00534   zz.fIm = rho*TMath::Sin(phi);
00535   if (isreal && (TMath::Abs(zz.fIm)<small)) zz.fIm = zero;
00536   if (isneg) zz = zero - zz;
00537   return zz;
00538 }


Variable Documentation

TComplex ComplexOne
 

Definition at line 603 of file TComplex.h.

TComplex ComplexZero
 

Definition at line 602 of file TComplex.h.

Referenced by TDSPVector::operator()(), TDSPMatrix::operator()(), and TDSPFifo::Shift().

TComplex I
 

Definition at line 604 of file TComplex.h.


Generated on Fri Apr 23 16:23:44 2004 by doxygen 1.3.2