REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends
TRestComplex Class Reference

Detailed Description

A generic class to handle complex numbers with real precision.

TRestComplex is a class that defines static methods with mathematical operations using complex numbers. This class has been generated by refurbishing the existing ROOT TComplex object and updating the double type by real MPFR types that allow to define an arbitrary precision.

It is possible to redefine the numbers precision as number of digits using TRestComplex::SetPrecision.

Code example inside restRoot:

root [0] TRestComplex::SetPrecision(30)
root [1] TRestComplex a
(TRestComplex &) (1,0i)
root [2] TRestComplex b(1.e-15)
(TRestComplex &) (1e-15,0i)
root [3] TRestComplex c(0,1)
(TRestComplex &) (0,1i)
root [4] TRestComplex d(0,1.e-25)
(TRestComplex &) (0,1e-25i)
root [5] a + b + c + d
(TRestComplex) (1.000000000000001,1.0000000000000000000000001i)
root [6] TRestComplex e = (a+b)/(c+d)
(TRestComplex &) (0,-1.0000000000000009999999999i)
A generic class to handle complex numbers with real precision.
Definition: TRestComplex.h:33

RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2016-December: First concept. Javier Galan

Author
Javier Galan javie.nosp@m.r.ga.nosp@m.lan@u.nosp@m.niza.nosp@m.r.es

Definition at line 33 of file TRestComplex.h.

#include <TRestComplex.h>

Public Member Functions

mpfr::mpreal Im () const
 
 operator Double_t () const
 
 operator Float_t () const
 
 operator Int_t () const
 
TRestComplex operator() (mpfr::mpreal x, mpfr::mpreal y, Bool_t polar=kFALSE)
 
TRestComplex operator* (const TRestComplex &c) const
 
TRestComplex operator* (mpfr::mpreal c) const
 
TRestComplex operator*= (const TRestComplex &c)
 
TRestComplex operator+ ()
 
TRestComplex operator+ (const TRestComplex &c) const
 
TRestComplex operator+ (mpfr::mpreal c) const
 
TRestComplex operator+= (const TRestComplex &c)
 
TRestComplex operator- ()
 
TRestComplex operator- (const TRestComplex &c) const
 
TRestComplex operator- (mpfr::mpreal c) const
 
TRestComplex operator-= (const TRestComplex &c)
 
TRestComplex operator/ (const TRestComplex &c) const
 
TRestComplex operator/ (mpfr::mpreal c) const
 
TRestComplex operator/= (const TRestComplex &c)
 
mpfr::mpreal Re () const
 
mpfr::mpreal Rho () const
 
mpfr::mpreal Rho2 () const
 
int Sign (const mpfr::mpreal &re, const mpfr::mpreal &im)
 
mpfr::mpreal Theta () const
 
 TRestComplex (mpfr::mpreal re, mpfr::mpreal im=0, Bool_t polar=kFALSE)
 Standard constructor. More...
 

Static Public Member Functions

static mpfr::mpreal Abs (const TRestComplex &c)
 
static TRestComplex ACos (const TRestComplex &c)
 
static TRestComplex ACosH (const TRestComplex &c)
 
static TRestComplex ASin (const TRestComplex &c)
 
static TRestComplex ASinH (const TRestComplex &c)
 
static TRestComplex ATan (const TRestComplex &c)
 
static TRestComplex ATanH (const TRestComplex &c)
 
static TRestComplex Conjugate (const TRestComplex &c)
 
static TRestComplex Cos (const TRestComplex &c)
 
static TRestComplex CosH (const TRestComplex &c)
 
static TRestComplex Exp (const TRestComplex &c)
 
static int GetPrecision ()
 
static TRestComplex I ()
 
static Int_t IsNaN (const TRestComplex &c)
 
static TRestComplex Log (const TRestComplex &c)
 
static TRestComplex Log10 (const TRestComplex &c)
 
static TRestComplex Log2 (const TRestComplex &c)
 
static TRestComplex Max (const TRestComplex &a, const TRestComplex &b)
 
static TRestComplex Min (const TRestComplex &a, const TRestComplex &b)
 
static TRestComplex Normalize (const TRestComplex &c)
 
static TRestComplex One ()
 
static TRestComplex Power (const TRestComplex &x, const TRestComplex &y)
 
static TRestComplex Power (const TRestComplex &x, Int_t y)
 
static TRestComplex Power (const TRestComplex &x, mpfr::mpreal y)
 
static TRestComplex Power (mpfr::mpreal x, const TRestComplex &y)
 
static TRestComplex Range (const TRestComplex &lb, const TRestComplex &ub, const TRestComplex &c)
 
static void SetPrecision (Int_t precision)
 
static TRestComplex Sin (const TRestComplex &c)
 
static TRestComplex SinH (const TRestComplex &c)
 
static TRestComplex Sqrt (const TRestComplex &c)
 
static TRestComplex Tan (const TRestComplex &c)
 
static TRestComplex TanH (const TRestComplex &c)
 

Protected Attributes

mpfr::mpreal fIm = 0
 The imaginary part of the complex number using MPFR precision. More...
 
mpfr::mpreal fRe = 1
 The real part of the complex number using MPFR precision. More...
 

Friends

TRestComplex operator* (Double_t d, const TRestComplex &c)
 
TRestComplex operator+ (Double_t d, const TRestComplex &c)
 
TRestComplex operator- (Double_t d, const TRestComplex &c)
 
TRestComplex operator/ (Double_t d, const TRestComplex &c)
 
std::ostream & operator<< (std::ostream &out, const TRestComplex &c)
 
std::istream & operator>> (std::istream &in, TRestComplex &c)
 

Constructor & Destructor Documentation

◆ TRestComplex() [1/2]

TRestComplex::TRestComplex ( )
inline

Definition at line 42 of file TRestComplex.h.

◆ TRestComplex() [2/2]

TRestComplex::TRestComplex ( mpfr::mpreal  re,
mpfr::mpreal  im = 0,
Bool_t  polar = kFALSE 
)

Standard constructor.

Definition at line 77 of file TRestComplex.cxx.

◆ ~TRestComplex()

virtual TRestComplex::~TRestComplex ( )
inlinevirtual

Definition at line 44 of file TRestComplex.h.

Member Function Documentation

◆ Abs()

static mpfr::mpreal TRestComplex::Abs ( const TRestComplex c)
inlinestatic

Definition at line 181 of file TRestComplex.h.

◆ ACos()

static TRestComplex TRestComplex::ACos ( const TRestComplex c)
inlinestatic

MUST be implemented

Definition at line 149 of file TRestComplex.h.

◆ ACosH()

static TRestComplex TRestComplex::ACosH ( const TRestComplex c)
inlinestatic

MUST be implemented

Definition at line 174 of file TRestComplex.h.

◆ ASin()

static TRestComplex TRestComplex::ASin ( const TRestComplex c)
inlinestatic

MUST be implemented

Definition at line 144 of file TRestComplex.h.

◆ ASinH()

static TRestComplex TRestComplex::ASinH ( const TRestComplex c)
inlinestatic

MUST be implemented

Definition at line 169 of file TRestComplex.h.

◆ ATan()

static TRestComplex TRestComplex::ATan ( const TRestComplex c)
inlinestatic

Definition at line 154 of file TRestComplex.h.

◆ ATanH()

static TRestComplex TRestComplex::ATanH ( const TRestComplex c)
inlinestatic

Definition at line 179 of file TRestComplex.h.

◆ Conjugate()

static TRestComplex TRestComplex::Conjugate ( const TRestComplex c)
inlinestatic

Definition at line 209 of file TRestComplex.h.

◆ Cos()

static TRestComplex TRestComplex::Cos ( const TRestComplex c)
inlinestatic

Definition at line 131 of file TRestComplex.h.

◆ CosH()

static TRestComplex TRestComplex::CosH ( const TRestComplex c)
inlinestatic

Definition at line 161 of file TRestComplex.h.

◆ Exp()

static TRestComplex TRestComplex::Exp ( const TRestComplex c)
inlinestatic

Definition at line 121 of file TRestComplex.h.

◆ GetPrecision()

static int TRestComplex::GetPrecision ( )
inlinestatic

Definition at line 50 of file TRestComplex.h.

◆ I()

static TRestComplex TRestComplex::I ( )
inlinestatic

Definition at line 53 of file TRestComplex.h.

◆ Im()

mpfr::mpreal TRestComplex::Im ( ) const
inline

Definition at line 58 of file TRestComplex.h.

◆ IsNaN()

static Int_t TRestComplex::IsNaN ( const TRestComplex c)
inlinestatic

Definition at line 200 of file TRestComplex.h.

◆ Log()

static TRestComplex TRestComplex::Log ( const TRestComplex c)
inlinestatic

Definition at line 122 of file TRestComplex.h.

◆ Log10()

static TRestComplex TRestComplex::Log10 ( const TRestComplex c)
inlinestatic

Definition at line 126 of file TRestComplex.h.

◆ Log2()

static TRestComplex TRestComplex::Log2 ( const TRestComplex c)
inlinestatic

Definition at line 125 of file TRestComplex.h.

◆ Max()

static TRestComplex TRestComplex::Max ( const TRestComplex a,
const TRestComplex b 
)
inlinestatic

Definition at line 205 of file TRestComplex.h.

◆ Min()

static TRestComplex TRestComplex::Min ( const TRestComplex a,
const TRestComplex b 
)
inlinestatic

Definition at line 202 of file TRestComplex.h.

◆ Normalize()

static TRestComplex TRestComplex::Normalize ( const TRestComplex c)
inlinestatic

Definition at line 208 of file TRestComplex.h.

◆ One()

static TRestComplex TRestComplex::One ( )
inlinestatic

Definition at line 54 of file TRestComplex.h.

◆ operator Double_t()

TRestComplex::operator Double_t ( ) const
inline

Definition at line 112 of file TRestComplex.h.

◆ operator Float_t()

TRestComplex::operator Float_t ( ) const
inline

Definition at line 113 of file TRestComplex.h.

◆ operator Int_t()

TRestComplex::operator Int_t ( ) const
inline

Definition at line 114 of file TRestComplex.h.

◆ operator()()

TRestComplex TRestComplex::operator() ( mpfr::mpreal  x,
mpfr::mpreal  y,
Bool_t  polar = kFALSE 
)
inline

Definition at line 62 of file TRestComplex.h.

◆ operator*() [1/2]

TRestComplex TRestComplex::operator* ( const TRestComplex c) const
inline

Definition at line 74 of file TRestComplex.h.

◆ operator*() [2/2]

TRestComplex TRestComplex::operator* ( mpfr::mpreal  c) const
inline

Definition at line 92 of file TRestComplex.h.

◆ operator*=()

TRestComplex TRestComplex::operator*= ( const TRestComplex c)
inline

Definition at line 83 of file TRestComplex.h.

◆ operator+() [1/3]

TRestComplex TRestComplex::operator+ ( )
inline

Definition at line 89 of file TRestComplex.h.

◆ operator+() [2/3]

TRestComplex TRestComplex::operator+ ( const TRestComplex c) const
inline

Definition at line 77 of file TRestComplex.h.

◆ operator+() [3/3]

TRestComplex TRestComplex::operator+ ( mpfr::mpreal  c) const
inline

Definition at line 93 of file TRestComplex.h.

◆ operator+=()

TRestComplex TRestComplex::operator+= ( const TRestComplex c)
inline

Definition at line 84 of file TRestComplex.h.

◆ operator-() [1/3]

TRestComplex TRestComplex::operator- ( )
inline

Definition at line 88 of file TRestComplex.h.

◆ operator-() [2/3]

TRestComplex TRestComplex::operator- ( const TRestComplex c) const
inline

Definition at line 81 of file TRestComplex.h.

◆ operator-() [3/3]

TRestComplex TRestComplex::operator- ( mpfr::mpreal  c) const
inline

Definition at line 95 of file TRestComplex.h.

◆ operator-=()

TRestComplex TRestComplex::operator-= ( const TRestComplex c)
inline

Definition at line 86 of file TRestComplex.h.

◆ operator/() [1/2]

TRestComplex TRestComplex::operator/ ( const TRestComplex c) const
inline

Definition at line 78 of file TRestComplex.h.

◆ operator/() [2/2]

TRestComplex TRestComplex::operator/ ( mpfr::mpreal  c) const
inline

Definition at line 94 of file TRestComplex.h.

◆ operator/=()

TRestComplex TRestComplex::operator/= ( const TRestComplex c)
inline

Definition at line 85 of file TRestComplex.h.

◆ Power() [1/4]

static TRestComplex TRestComplex::Power ( const TRestComplex x,
const TRestComplex y 
)
inlinestatic

Definition at line 183 of file TRestComplex.h.

◆ Power() [2/4]

static TRestComplex TRestComplex::Power ( const TRestComplex x,
Int_t  y 
)
inlinestatic

Definition at line 196 of file TRestComplex.h.

◆ Power() [3/4]

static TRestComplex TRestComplex::Power ( const TRestComplex x,
mpfr::mpreal  y 
)
inlinestatic

Definition at line 188 of file TRestComplex.h.

◆ Power() [4/4]

static TRestComplex TRestComplex::Power ( mpfr::mpreal  x,
const TRestComplex y 
)
inlinestatic

Definition at line 191 of file TRestComplex.h.

◆ Range()

static TRestComplex TRestComplex::Range ( const TRestComplex lb,
const TRestComplex ub,
const TRestComplex c 
)
inlinestatic

Definition at line 210 of file TRestComplex.h.

◆ Re()

mpfr::mpreal TRestComplex::Re ( ) const
inline

Definition at line 57 of file TRestComplex.h.

◆ Rho()

mpfr::mpreal TRestComplex::Rho ( ) const
inline

Definition at line 59 of file TRestComplex.h.

◆ Rho2()

mpfr::mpreal TRestComplex::Rho2 ( ) const
inline

Definition at line 60 of file TRestComplex.h.

◆ SetPrecision()

static void TRestComplex::SetPrecision ( Int_t  precision)
inlinestatic

Definition at line 46 of file TRestComplex.h.

◆ Sign()

int TRestComplex::Sign ( const mpfr::mpreal &  re,
const mpfr::mpreal &  im 
)
inline

MUST be implemented

Definition at line 139 of file TRestComplex.h.

◆ Sin()

static TRestComplex TRestComplex::Sin ( const TRestComplex c)
inlinestatic

Definition at line 128 of file TRestComplex.h.

◆ SinH()

static TRestComplex TRestComplex::SinH ( const TRestComplex c)
inlinestatic

Definition at line 158 of file TRestComplex.h.

◆ Sqrt()

static TRestComplex TRestComplex::Sqrt ( const TRestComplex c)
inlinestatic

Definition at line 117 of file TRestComplex.h.

◆ Tan()

static TRestComplex TRestComplex::Tan ( const TRestComplex c)
inlinestatic

Definition at line 134 of file TRestComplex.h.

◆ TanH()

static TRestComplex TRestComplex::TanH ( const TRestComplex c)
inlinestatic

Definition at line 164 of file TRestComplex.h.

◆ Theta()

mpfr::mpreal TRestComplex::Theta ( ) const
inline

Definition at line 61 of file TRestComplex.h.

Friends And Related Function Documentation

◆ operator*

TRestComplex operator* ( Double_t  d,
const TRestComplex c 
)
friend

Definition at line 98 of file TRestComplex.h.

◆ operator+

TRestComplex operator+ ( Double_t  d,
const TRestComplex c 
)
friend

Definition at line 101 of file TRestComplex.h.

◆ operator-

TRestComplex operator- ( Double_t  d,
const TRestComplex c 
)
friend

Definition at line 107 of file TRestComplex.h.

◆ operator/

TRestComplex operator/ ( Double_t  d,
const TRestComplex c 
)
friend

Definition at line 104 of file TRestComplex.h.

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const TRestComplex c 
)
friend

Definition at line 89 of file TRestComplex.cxx.

◆ operator>>

std::istream & operator>> ( std::istream &  in,
TRestComplex c 
)
friend

Definition at line 105 of file TRestComplex.cxx.

Field Documentation

◆ fIm

mpfr::mpreal TRestComplex::fIm = 0
protected

The imaginary part of the complex number using MPFR precision.

Definition at line 38 of file TRestComplex.h.

◆ fRe

mpfr::mpreal TRestComplex::fRe = 1
protected

The real part of the complex number using MPFR precision.

Definition at line 36 of file TRestComplex.h.


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