ODIN
tjcomplex.h
1 /***************************************************************************
2  tjcomplex.h - description
3  -------------------
4  begin : Thu Jul 13 2000
5  copyright : (C) 2000-2021 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef TJCOMPLEX_H
20 #define TJCOMPLEX_H
21 
22 
23 #include <tjutils/tjutils.h>
24 #include <tjutils/tjstring.h>
25 
26 
35 STD_string ctos(const STD_complex& z);
36 
40 STD_complex stoc(const STD_string& s);
41 
42 
44 // functions for using complex numbers with Blitz++,
45 // even if the STD_complex class is not std::complex
46 inline STD_complex float2real(float a) {return STD_complex(a,0.0f);}
47 inline STD_complex float2imag(float b) {return STD_complex(0.0f,b);}
48 inline float creal(STD_complex c) {return c.real();}
49 inline float cimag(STD_complex c) {return c.imag();}
50 inline float cabs(STD_complex c) {return float(sqrt(c.real()*c.real()+c.imag()*c.imag()));} //{return STD_abs(c);} // std::abs produces inf with GCC4 on amd64
51 inline float phase(STD_complex c) {return STD_arg(c);}
52 inline STD_complex logc(STD_complex c) {return STD_log(c);}
53 inline STD_complex expc(STD_complex c) {return STD_exp(c);}
54 inline STD_complex conjc(STD_complex c) {return STD_conj(c);}
55 
56 
57 
61 inline bool operator < (const STD_complex& c1, const STD_complex& c2) {return STD_abs(c1)<STD_abs(c2);}
62 
66 inline bool operator > (const STD_complex& c1, const STD_complex& c2) {return STD_abs(c1)>STD_abs(c2);}
67 
68 
69 
72 #endif
73 
74 
bool operator>(const STD_complex &c1, const STD_complex &c2)
Definition: tjcomplex.h:66
STD_string ctos(const STD_complex &z)
bool operator<(const STD_complex &c1, const STD_complex &c2)
Definition: tjcomplex.h:61
fvector phase(const cvector &cv)
STD_complex stoc(const STD_string &s)