a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
gslpp::complex Class Reference

A class for defining operations on and functions of complex numbers. More...

#include <gslpp_complex.h>

Detailed Description

A class for defining operations on and functions of complex numbers.

Author
HEPfit Collaboration

This class defines some common operations on complex variables using the GSL.

Definition at line 35 of file gslpp_complex.h.

Public Member Functions

double abs () const
 
double abs2 () const
 
double arg () const
 
gsl_complex & as_gsl_type ()
 
const gsl_complex & as_gsl_type () const
 
gsl_complex * as_gsl_type_ptr () const
 
void assign (const double &real, const double &imag, bool polar)
 
 complex ()
 Default constructor for the complex class. More...
 
 complex (const complex &z)
 Copy constructor for the complex class. More...
 
 complex (const double &a)
 Conversion constructor for the complex class. Converts a real double to a complex type. More...
 
 complex (const double &real, const double &imag, bool polar=false)
 Overleaded constructor for the complex class. More...
 
 complex (const gsl_complex &z)
 Conversion constructor for the complex class. Converts a gsl_complex type reference to a complex type. More...
 
 complex (const gsl_complex *z)
 Conversion constructor for the complex class. Converts a gsl_complex type pointer to a complex type. More...
 
complex conjugate () const
 
double & imag ()
 
const double & imag () const
 
complex inverse () const
 
bool is_imag () const
 Check if complex number is purely imaginary. More...
 
bool is_real () const
 Check if complex number is purely real. More...
 
double log_of_abs () const
 
 operator const gsl_complex & () const
 
 operator gsl_complex & ()
 
bool operator!= (const complex &z1) const
 Inequivalence operator between two complex variables. More...
 
complex operator* (const complex &z1) const
 Multiplication operator for a complex number. More...
 
complex operator* (const double &a) const
 Multiplication operator for multiplying a real number to a complex number. More...
 
complexoperator*= (const complex &z1)
 Muliplication assignment operator for a complex number. More...
 
complexoperator*= (const double &a)
 Multiplication assignment operator for mulitplying a real number to a complex number. More...
 
complex operator+ (const complex &z1) const
 Addition operator for a complex number. More...
 
complex operator+ (const double &a) const
 Addition operator for adding a real number to a complex number. More...
 
complexoperator+= (const complex &z1)
 Addition assignment operator for a complex number. More...
 
complexoperator+= (const double &a)
 Addition assignment operator for adding a real number to a complex number. More...
 
complex operator- () const
 Unary minus operator for a complex number. More...
 
complex operator- (const complex &z1) const
 Subtraction operator for a complex number. More...
 
complex operator- (const double &a) const
 Subtraction operator for subtracting a real number from a complex number. More...
 
complexoperator-= (const complex &z1)
 Subtraction assignment operator for a complex number. More...
 
complexoperator-= (const double &a)
 Subtraction assignment operator for subtracting a real number from a complex number. More...
 
complex operator/ (const complex &z1) const
 Division operator for a complex number. More...
 
complex operator/ (const double &a) const
 Divsion operator for dividing a complex number by a real number. More...
 
complexoperator/= (const complex &z1)
 Division assignment operator for a complex number. More...
 
complexoperator/= (const double &a)
 Division assignment operator for dividing a complex number by a real number. More...
 
complexoperator= (const complex &z)
 Assignment operator for a complex variable of complex type. More...
 
complexoperator= (const double &x)
 Assignment operator for a double variable to complex type. More...
 
bool operator== (const complex &z1) const
 Equivalence operator between two complex variables. More...
 
double & real ()
 
const double & real () const
 
virtual ~complex ()
 Default destructor for the complex class. More...
 

Static Public Member Functions

static const complexi ()
 

Private Attributes

gsl_complex _complex
 

Friends

complex arccos (const complex &z)
 
complex arccosh (const complex &z)
 
complex arccot (const complex &z)
 
complex arccoth (const complex &z)
 
complex arccsc (const complex &z)
 
complex arccsch (const complex &z)
 
complex arcsec (const complex &z)
 
complex arcsech (const complex &z)
 
complex arcsin (const complex &z)
 
complex arcsinh (const complex &z)
 
complex arctan (const complex &z)
 
complex arctanh (const complex &z)
 
complex cos (const complex &z)
 
complex cosh (const complex &z)
 
complex cot (const complex &z)
 
complex coth (const complex &z)
 
complex csc (const complex &z)
 
complex csch (const complex &z)
 
complex dilog (const complex &z)
 
complex exp (const complex &z)
 
complex log (const complex &z)
 
complex log (const complex &z, const complex &b)
 
complex log10 (const complex &z)
 
std::ostream & operator<< (std::ostream &output, const complex &z)
 
complex pow (const complex &z, const double x)
 
complex pow (const complex &z1, const complex &z2)
 
complex sec (const complex &z)
 
complex sech (const complex &z)
 
complex sin (const complex &z)
 
complex sinh (const complex &z)
 
complex sqrt (const complex &z)
 
complex tan (const complex &z)
 
complex tanh (const complex &z)
 
Operations on complex numbers
complex operator+ (const double &x1, const complex &z2)
 
complex operator- (const double &x1, const complex &z2)
 
complex operator* (const double &x1, const complex &z2)
 
complex operator/ (const double &x1, const complex &z2)
 

Constructor & Destructor Documentation

◆ complex() [1/6]

gslpp::complex::complex ( )

Default constructor for the complex class.

Definition at line 18 of file gslpp_complex.cpp.

19  {
20  assign(0., 0., false);
21  }

◆ complex() [2/6]

gslpp::complex::complex ( const double &  real,
const double &  imag,
bool  polar = false 
)

Overleaded constructor for the complex class.

Parameters
[in]realreal part of the comlex number
[in]imagimaginary part of the complex number
[in]polarboolean switch for specifying polar form of of the complex number (default: false)

Definition at line 23 of file gslpp_complex.cpp.

24  {
25  assign(real, imag, polar);
26  }

◆ complex() [3/6]

gslpp::complex::complex ( const complex z)

Copy constructor for the complex class.

Definition at line 28 of file gslpp_complex.cpp.

29  {
30  assign(z.real(), z.imag(), false);
31  }

◆ complex() [4/6]

gslpp::complex::complex ( const double &  a)

Conversion constructor for the complex class. Converts a real double to a complex type.

Definition at line 32 of file gslpp_complex.cpp.

33  {
34  assign(a, 0., false);
35  }

◆ complex() [5/6]

gslpp::complex::complex ( const gsl_complex *  z)

Conversion constructor for the complex class. Converts a gsl_complex type pointer to a complex type.

Definition at line 160 of file gslpp_complex.cpp.

161  {
162 // _complex = (gsl_complex*)malloc(sizeof(gsl_complex));
163  GSL_SET_COMPLEX(&_complex, GSL_REAL(*z), GSL_IMAG(*z));
164  }

◆ complex() [6/6]

gslpp::complex::complex ( const gsl_complex &  z)

Conversion constructor for the complex class. Converts a gsl_complex type reference to a complex type.

Definition at line 166 of file gslpp_complex.cpp.

167  {
168 // _complex = (gsl_complex*)malloc(sizeof(gsl_complex));
169  GSL_SET_COMPLEX(&_complex, GSL_REAL(z), GSL_IMAG(z));
170  }

◆ ~complex()

gslpp::complex::~complex ( )
virtual

Default destructor for the complex class.

Definition at line 37 of file gslpp_complex.cpp.

38  {
39  }

Member Function Documentation

◆ abs()

double gslpp::complex::abs ( ) const
Returns
The absolute value of a complex number

Definition at line 81 of file gslpp_complex.cpp.

82  {
83  return gsl_complex_abs(_complex);
84  }

◆ abs2()

double gslpp::complex::abs2 ( ) const
Returns
The square of the absolute value of a complex number

Definition at line 86 of file gslpp_complex.cpp.

87  {
88  return gsl_complex_abs2(_complex);
89  }

◆ arg()

double gslpp::complex::arg ( ) const
Returns
The argument of a complex number

Definition at line 76 of file gslpp_complex.cpp.

77  {
78  return gsl_complex_arg(_complex);
79  }

◆ as_gsl_type() [1/2]

gsl_complex & gslpp::complex::as_gsl_type ( )

Definition at line 123 of file gslpp_complex.cpp.

124  {
125  return _complex;
126  }

◆ as_gsl_type() [2/2]

const gsl_complex & gslpp::complex::as_gsl_type ( ) const

Definition at line 128 of file gslpp_complex.cpp.

129  {
130  return _complex;
131  }

◆ as_gsl_type_ptr()

gsl_complex * gslpp::complex::as_gsl_type_ptr ( ) const

Conversion

Definition at line 118 of file gslpp_complex.cpp.

119  {
120  return const_cast<gsl_complex*>(&_complex);
121  }

◆ assign()

void gslpp::complex::assign ( const double &  real = 0.,
const double &  imag = 0.,
bool  polar = false 
)

Assign

Definition at line 173 of file gslpp_complex.cpp.

175  {
176  if (polar)
177  _complex = gsl_complex_polar(real,imag);
178  else
179  {
180  GSL_SET_COMPLEX(&_complex, real, imag);
181  // *_complex = gsl_complex_rect(real,imag);
182  }
183  }

◆ conjugate()

complex gslpp::complex::conjugate ( ) const
Returns
The conjugate of a complex number

Definition at line 288 of file gslpp_complex.cpp.

289  {
290  gsl_complex t = gsl_complex_conjugate(_complex);
291  return complex(t);
292  }

◆ i()

const complex & gslpp::complex::i ( )
static

Definition at line 154 of file gslpp_complex.cpp.

155  {
156  static complex _i(0.,1.);
157  return _i;
158  }

◆ imag() [1/2]

double & gslpp::complex::imag ( )

Get the imaginary part

Definition at line 71 of file gslpp_complex.cpp.

72  {
73  return GSL_IMAG(_complex);
74  }

◆ imag() [2/2]

const double & gslpp::complex::imag ( ) const

Set imaginary part

Definition at line 59 of file gslpp_complex.cpp.

60  {
61  return GSL_IMAG(_complex);
62  }

◆ inverse()

complex gslpp::complex::inverse ( ) const
Returns
The inverse of a complex number

Definition at line 294 of file gslpp_complex.cpp.

295  {
296  gsl_complex t = gsl_complex_inverse(_complex);
297  return complex(t);
298  }

◆ is_imag()

bool gslpp::complex::is_imag ( ) const

Check if complex number is purely imaginary.

Returns
boolean true/false

Definition at line 47 of file gslpp_complex.cpp.

48  {
49  return ::fabs(real()/imag()) < GSLEPS;
50  }

◆ is_real()

bool gslpp::complex::is_real ( ) const

Check if complex number is purely real.

Returns
boolean true/false

Definition at line 41 of file gslpp_complex.cpp.

42  {
43  return ::fabs(imag()/real()) < GSLEPS;
44  }

◆ log_of_abs()

double gslpp::complex::log_of_abs ( ) const
Returns
The logarithm of the absolute value of a complex number

Definition at line 91 of file gslpp_complex.cpp.

92  {
93  return gsl_complex_logabs(_complex);
94  }

◆ operator const gsl_complex &()

gslpp::complex::operator const gsl_complex & ( ) const

Definition at line 138 of file gslpp_complex.cpp.

139  {
140  return _complex;
141  }

◆ operator gsl_complex &()

gslpp::complex::operator gsl_complex & ( )

Definition at line 133 of file gslpp_complex.cpp.

134  {
135  return _complex;
136  }

◆ operator!=()

bool gslpp::complex::operator!= ( const complex z1) const

Inequivalence operator between two complex variables.

Definition at line 113 of file gslpp_complex.cpp.

114  {
115  return !(GSL_COMPLEX_EQ(_complex, z1._complex));
116  }

◆ operator*() [1/2]

complex gslpp::complex::operator* ( const complex z1) const

Multiplication operator for a complex number.

Definition at line 203 of file gslpp_complex.cpp.

204  {
205  gsl_complex rl = gsl_complex_mul(_complex, z1._complex);
206  return complex(rl);
207  }

◆ operator*() [2/2]

complex gslpp::complex::operator* ( const double &  a) const

Multiplication operator for multiplying a real number to a complex number.

Definition at line 251 of file gslpp_complex.cpp.

252  {
253  gsl_complex rl = gsl_complex_mul_real(_complex,a);
254  return complex(rl);
255  }

◆ operator*=() [1/2]

complex & gslpp::complex::operator*= ( const complex z1)

Muliplication assignment operator for a complex number.

Definition at line 227 of file gslpp_complex.cpp.

228  {
229  _complex = gsl_complex_mul(_complex, z1._complex);
230  return *this;
231  }

◆ operator*=() [2/2]

complex & gslpp::complex::operator*= ( const double &  a)

Multiplication assignment operator for mulitplying a real number to a complex number.

Definition at line 276 of file gslpp_complex.cpp.

277  {
278  _complex = gsl_complex_mul_real(_complex,a);
279  return *this;
280  }

◆ operator+() [1/2]

complex gslpp::complex::operator+ ( const complex z1) const

Addition operator for a complex number.

Definition at line 191 of file gslpp_complex.cpp.

192  {
193  gsl_complex rl = gsl_complex_add(_complex, z1._complex);
194  return complex(rl);
195  }

◆ operator+() [2/2]

complex gslpp::complex::operator+ ( const double &  a) const

Addition operator for adding a real number to a complex number.

Definition at line 239 of file gslpp_complex.cpp.

240  {
241  gsl_complex rl = gsl_complex_add_real(_complex,a);
242  return complex(rl);
243  }

◆ operator+=() [1/2]

complex & gslpp::complex::operator+= ( const complex z1)

Addition assignment operator for a complex number.

Definition at line 215 of file gslpp_complex.cpp.

216  {
217  _complex = gsl_complex_add(_complex, z1._complex);
218  return *this;
219  }

◆ operator+=() [2/2]

complex & gslpp::complex::operator+= ( const double &  a)

Addition assignment operator for adding a real number to a complex number.

Definition at line 263 of file gslpp_complex.cpp.

264  {
265  _complex = gsl_complex_add_real(_complex,a);
266  return *this;
267  }

◆ operator-() [1/3]

complex gslpp::complex::operator- ( ) const

Unary minus operator for a complex number.

Definition at line 185 of file gslpp_complex.cpp.

186  {
187  gsl_complex t = gsl_complex_negative(_complex);
188  return complex(&t);
189  }

◆ operator-() [2/3]

complex gslpp::complex::operator- ( const complex z1) const

Subtraction operator for a complex number.

Definition at line 197 of file gslpp_complex.cpp.

198  {
199  gsl_complex rl = gsl_complex_sub(_complex, z1._complex);
200  return complex(rl);
201  }

◆ operator-() [3/3]

complex gslpp::complex::operator- ( const double &  a) const

Subtraction operator for subtracting a real number from a complex number.

Definition at line 245 of file gslpp_complex.cpp.

246  {
247  gsl_complex rl = gsl_complex_sub_real(_complex,a);
248  return complex(rl);
249  }

◆ operator-=() [1/2]

complex & gslpp::complex::operator-= ( const complex z1)

Subtraction assignment operator for a complex number.

Definition at line 221 of file gslpp_complex.cpp.

222  {
223  _complex = gsl_complex_sub(_complex, z1._complex);
224  return *this;
225  }

◆ operator-=() [2/2]

complex & gslpp::complex::operator-= ( const double &  a)

Subtraction assignment operator for subtracting a real number from a complex number.

Definition at line 269 of file gslpp_complex.cpp.

270  {
271  _complex = gsl_complex_sub_real(_complex,a);
272  return *this;
273  }

◆ operator/() [1/2]

complex gslpp::complex::operator/ ( const complex z1) const

Division operator for a complex number.

Definition at line 209 of file gslpp_complex.cpp.

210  {
211  gsl_complex rl = gsl_complex_div(_complex, z1._complex);
212  return complex(rl);
213  }

◆ operator/() [2/2]

complex gslpp::complex::operator/ ( const double &  a) const

Divsion operator for dividing a complex number by a real number.

Definition at line 257 of file gslpp_complex.cpp.

258  {
259  gsl_complex rl = gsl_complex_div_real(_complex,a);
260  return complex(rl);
261  }

◆ operator/=() [1/2]

complex & gslpp::complex::operator/= ( const complex z1)

Division assignment operator for a complex number.

Definition at line 233 of file gslpp_complex.cpp.

234  {
235  _complex = gsl_complex_div(_complex, z1._complex);
236  return *this;
237  }

◆ operator/=() [2/2]

complex & gslpp::complex::operator/= ( const double &  a)

Division assignment operator for dividing a complex number by a real number.

Definition at line 282 of file gslpp_complex.cpp.

283  {
284  _complex = gsl_complex_div_real(_complex,a);
285  return *this;
286  }

◆ operator=() [1/2]

complex & gslpp::complex::operator= ( const complex z)

Assignment operator for a complex variable of complex type.

Definition at line 96 of file gslpp_complex.cpp.

97  {
98  GSL_SET_COMPLEX(&_complex, z.real(), z.imag());
99  return *this;
100  }

◆ operator=() [2/2]

complex & gslpp::complex::operator= ( const double &  x)

Assignment operator for a double variable to complex type.

Definition at line 102 of file gslpp_complex.cpp.

103  {
104  GSL_SET_COMPLEX(&_complex, x, 0);
105  return *this;
106  }

◆ operator==()

bool gslpp::complex::operator== ( const complex z1) const

Equivalence operator between two complex variables.

Definition at line 108 of file gslpp_complex.cpp.

109  {
110  return GSL_COMPLEX_EQ(_complex, z1._complex);
111  }

◆ real() [1/2]

double & gslpp::complex::real ( )

Get the real part

Definition at line 65 of file gslpp_complex.cpp.

66  {
67  return GSL_REAL(_complex);
68  }

◆ real() [2/2]

const double & gslpp::complex::real ( ) const

Set the real part

Definition at line 53 of file gslpp_complex.cpp.

54  {
55  return GSL_REAL(_complex);
56  }

Friends And Related Function Documentation

◆ arccos

complex arccos ( const complex z)
friend

Inverse cosine

Parameters
[in]zComplex number
Returns
\( \arccos z \)

Definition at line 483 of file gslpp_complex.cpp.

484  {
485  return complex(gsl_complex_arccos(z.as_gsl_type()));
486  }

◆ arccosh

complex arccosh ( const complex z)
friend

Inverse hyperbolic cosine

Parameters
[in]zComplex number
Returns
\( \mathrm{acosh} z \)

Definition at line 596 of file gslpp_complex.cpp.

597  {
598  return complex(gsl_complex_arccosh(z.as_gsl_type()));
599  }

◆ arccot

complex arccot ( const complex z)
friend

Inverse cotangent

Parameters
[in]zComplex number
Returns
\( \mathrm{acot} z \)

Definition at line 519 of file gslpp_complex.cpp.

520  {
521  return complex(gsl_complex_arccot(z.as_gsl_type()));
522  }

◆ arccoth

complex arccoth ( const complex z)
friend

Inverse hyperbolic cotangent

Parameters
[in]zComplex number
Returns
\( \mathrm{acoth}(z) \)

Definition at line 632 of file gslpp_complex.cpp.

633  {
634  return complex(gsl_complex_arccoth(z.as_gsl_type()));
635  }

◆ arccsc

complex arccsc ( const complex z)
friend

Inverse cosecant

Parameters
[in]zComplex number
Returns
\( \mathrm{acsc} z \)

Definition at line 510 of file gslpp_complex.cpp.

511  {
512  return complex(gsl_complex_arccsc(z.as_gsl_type()));
513  }

◆ arccsch

complex arccsch ( const complex z)
friend

Inverse hyperbolic cosecant

Parameters
[in]zComplex number
Returns
\( \mathrm{acsch} z \)

Definition at line 623 of file gslpp_complex.cpp.

624  {
625  return complex(gsl_complex_arccsch(z.as_gsl_type()));
626  }

◆ arcsec

complex arcsec ( const complex z)
friend

Inverse secant

Parameters
[in]zComplex number
Returns
\( \mathrm{asec} z \)

Definition at line 501 of file gslpp_complex.cpp.

502  {
503  return complex(gsl_complex_arcsec(z.as_gsl_type()));
504  }

◆ arcsech

complex arcsech ( const complex z)
friend

Inverse hyperbolic secant

Parameters
[in]zComplex number
Returns
\( \mathrm{asech} z \)

Definition at line 614 of file gslpp_complex.cpp.

615  {
616  return complex(gsl_complex_arcsech(z.as_gsl_type()));
617  }

◆ arcsin

complex arcsin ( const complex z)
friend

Inverse sine

Parameters
[in]zComplex number
Returns
\( \arcsin z \)

Definition at line 474 of file gslpp_complex.cpp.

475  {
476  return complex(gsl_complex_arcsin(z.as_gsl_type()));
477  }

◆ arcsinh

complex arcsinh ( const complex z)
friend

Inverse hyperbolic sine

Parameters
[in]zComplex number
Returns
\( \mathrm{asinh} z \)

Definition at line 587 of file gslpp_complex.cpp.

588  {
589  return complex(gsl_complex_arcsinh(z.as_gsl_type()));
590  }

◆ arctan

complex arctan ( const complex z)
friend

Inverse tangent

Parameters
[in]zComplex number
Returns
\( \arctan z \)

Definition at line 492 of file gslpp_complex.cpp.

493  {
494  return complex(gsl_complex_arctan(z.as_gsl_type()));
495  }

◆ arctanh

complex arctanh ( const complex z)
friend

Inverse hyperbolic tangent

Parameters
[in]zComplex number
Returns
\( \mathrm{atanh} z \)

Definition at line 605 of file gslpp_complex.cpp.

606  {
607  return complex(gsl_complex_arctanh(z.as_gsl_type()));
608  }

◆ cos

complex cos ( const complex z)
friend

Cosine

Parameters
[in]zComplex number
Returns
\( \cos z \)

Definition at line 429 of file gslpp_complex.cpp.

430  {
431  return complex(gsl_complex_cos(z.as_gsl_type()));
432  }

◆ cosh

complex cosh ( const complex z)
friend

Hyperbolic cosine

Parameters
[in]zComplex number
Returns
\( \cosh z \)

Definition at line 542 of file gslpp_complex.cpp.

543  {
544  return complex(gsl_complex_cosh(z.as_gsl_type()));
545  }

◆ cot

complex cot ( const complex z)
friend

Cotangent

Parameters
[in]zComplex number
Returns
\( \cot z \)

Definition at line 465 of file gslpp_complex.cpp.

466  {
467  return complex(gsl_complex_cot(z.as_gsl_type()));
468  }

◆ coth

complex coth ( const complex z)
friend

Hyperbolic cotangent

Parameters
[in]zComplex number
Returns
\( \coth z \)

Definition at line 578 of file gslpp_complex.cpp.

579  {
580  return complex(gsl_complex_coth(z.as_gsl_type()));
581  }

◆ csc

complex csc ( const complex z)
friend

Cosecant

Parameters
[in]zComplex number
Returns
\( \csc z \)

Definition at line 456 of file gslpp_complex.cpp.

457  {
458  return complex(gsl_complex_csc(z.as_gsl_type()));
459  }

◆ csch

complex csch ( const complex z)
friend

Hyperbolic cosecant

Parameters
[in]zComplex number
Returns
\( \mathrm{csch} z \)

Definition at line 569 of file gslpp_complex.cpp.

570  {
571  return complex(gsl_complex_csch(z.as_gsl_type()));
572  }

◆ dilog

complex dilog ( const complex z)
friend

DiLogarithm of a complex number

Parameters
[in]zComplex number
Returns
\( Li_2(z) \)

Definition at line 370 of file gslpp_complex.cpp.

371  {
372  gsl_sf_result re, im;
373  gsl_sf_complex_dilog_xy_e(z.real(), z.imag(), &re, &im);
374  return complex(re.val, im.val, false);
375  }

◆ exp

complex exp ( const complex z)
friend

exponentioal of a complex number

Parameters
[in]zComplex number
Returns
\( e^z \)

Definition at line 333 of file gslpp_complex.cpp.

334  {
335  return complex(gsl_complex_exp(z.as_gsl_type()));
336  }

◆ log [1/2]

complex log ( const complex z)
friend

Logarithm of a complex number (base e)

Parameters
[in]zComplex number
Returns
\( \log z \)

Definition at line 342 of file gslpp_complex.cpp.

343  {
344  return complex(gsl_complex_log(z.as_gsl_type()));
345  }

◆ log [2/2]

complex log ( const complex z,
const complex b 
)
friend

Logarithm of a complex number (base b)

Parameters
[in]zComplex number
[in]bComplex number
Returns
\( \log_b z \)

Definition at line 361 of file gslpp_complex.cpp.

363  {
364  return complex(gsl_complex_log_b(z.as_gsl_type(),b.as_gsl_type()));
365  }

◆ log10

complex log10 ( const complex z)
friend

Logarithm of a complex number (base 10)

Parameters
[in]zComplex number
Returns
\( \log_{10} z \)

Definition at line 351 of file gslpp_complex.cpp.

352  {
353  return complex(gsl_complex_log10(z.as_gsl_type()));
354  }

◆ operator*

complex operator* ( const double &  x1,
const complex z2 
)
friend

Multiply a real and complex numbers

Parameters
[in]x1Real number
[in]z2Complex number
Returns
\( x_1 z_2 \)

Definition at line 314 of file gslpp_complex.cpp.

315  {
316  complex z1(x1, 0.);
317  return z1 * z2;
318  }

◆ operator+

complex operator+ ( const double &  x1,
const complex z2 
)
friend

Add a real and complex numbers

Parameters
[in]x1Real number
[in]z2Complex number
Returns
\( x_1 + z_2 \)

Definition at line 302 of file gslpp_complex.cpp.

303  {
304  complex z1(x1, 0.);
305  return z1 + z2;
306  }

◆ operator-

complex operator- ( const double &  x1,
const complex z2 
)
friend

Subtract a real and complex numbers

Parameters
[in]x1Real number
[in]z2Complex number
Returns
\( x_1 - z_2 \)

Definition at line 308 of file gslpp_complex.cpp.

309  {
310  complex z1(x1, 0.);
311  return z1 - z2;
312  }

◆ operator/

complex operator/ ( const double &  x1,
const complex z2 
)
friend

Divide a real and complex numbers

Parameters
[in]x1Real number
[in]z2Complex number
Returns
\( x_1 / z_2 \)

Definition at line 320 of file gslpp_complex.cpp.

321  {
322  complex z1(x1, 0);
323  return z1 / z2;
324  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  output,
const complex z 
)
friend

Friend functions

Parameters
[in]outputoutput stream
[in]zComplex number
Returns
formatted output for complex

Definition at line 143 of file gslpp_complex.cpp.

144  {
145  double absim = ::fabs(z.imag());
146  output << z.real() << (z.imag() < 0.? "-" : "+");
147  if (absim != 1.)
148  output << fabs(z.imag()) << "*";
149  output << "i";
150  return output;
151  }

◆ pow [1/2]

complex pow ( const complex z,
const double  x 
)
friend

Complex number to the x real order

Parameters
[in]zComplex number
[in]xReal number
Returns
\( z^x \)

Definition at line 407 of file gslpp_complex.cpp.

408  {
409  return complex(gsl_complex_pow_real(z.as_gsl_type(), x));
410  }

◆ pow [2/2]

complex pow ( const complex z1,
const complex z2 
)
friend

Complex number to the z2 complex order

Parameters
[in]z1Complex number
[in]z2Complex number
Returns
\( z_1^{z_2} \)

Definition at line 395 of file gslpp_complex.cpp.

397  {
398  return complex(gsl_complex_pow(z1.as_gsl_type(),
399  z2.as_gsl_type()));
400  }

◆ sec

complex sec ( const complex z)
friend

Secant

Parameters
[in]zComplex number
Returns
\( \sec z \)

Definition at line 447 of file gslpp_complex.cpp.

448  {
449  return complex(gsl_complex_sec(z.as_gsl_type()));
450  }

◆ sech

complex sech ( const complex z)
friend

Hyperbolic secant

Parameters
[in]zComplex number
Returns
\( \mathrm{sech} z \)

Definition at line 560 of file gslpp_complex.cpp.

561  {
562  return complex(gsl_complex_sech(z.as_gsl_type()));
563  }

◆ sin

complex sin ( const complex z)
friend

Sine

Parameters
[in]zComplex number
Returns
\( \sin z \)

Definition at line 420 of file gslpp_complex.cpp.

421  {
422  return complex(gsl_complex_sin(z.as_gsl_type()));
423  }

◆ sinh

complex sinh ( const complex z)
friend

Hyperbolic sine

Parameters
[in]zComplex number
Returns
\( \sinh z \)

Definition at line 533 of file gslpp_complex.cpp.

534  {
535  return complex(gsl_complex_sinh(z.as_gsl_type()));
536  }

◆ sqrt

complex sqrt ( const complex z)
friend

Square root of a complex number

Parameters
[in]zComplex number
Returns
\( \sqrt z \)

Definition at line 385 of file gslpp_complex.cpp.

386  {
387  return complex(gsl_complex_sqrt(z.as_gsl_type()));
388  }

◆ tan

complex tan ( const complex z)
friend

Tangent

Parameters
[in]zComplex number
Returns
\( \tan z \)

Definition at line 438 of file gslpp_complex.cpp.

439  {
440  return complex(gsl_complex_tan(z.as_gsl_type()));
441  }

◆ tanh

complex tanh ( const complex z)
friend

Hyperbolic tangent

Parameters
[in]zComplex number
Returns
\( \tanh z \)

Definition at line 551 of file gslpp_complex.cpp.

552  {
553  return complex(gsl_complex_tanh(z.as_gsl_type()));
554  }

Member Data Documentation

◆ _complex

gsl_complex gslpp::complex::_complex
private

Definition at line 37 of file gslpp_complex.h.


The documentation for this class was generated from the following files:
gslpp::complex::imag
const double & imag() const
Definition: gslpp_complex.cpp:59
gslpp::complex::_complex
gsl_complex _complex
Definition: gslpp_complex.h:37
gslpp::complex::complex
complex()
Default constructor for the complex class.
Definition: gslpp_complex.cpp:18
gslpp::complex::assign
void assign(const double &real, const double &imag, bool polar)
Definition: gslpp_complex.cpp:173
gslpp::complex::real
const double & real() const
Definition: gslpp_complex.cpp:53