My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
complex.h
Go to the documentation of this file.
1 /*
2  * complex.h - complex number class definitions
3  *
4  * Copyright (C) 2008 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id: complex.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __COMPLEX_H__
26 #define __COMPLEX_H__
27 
28 #include "real.h"
29 
30 #ifndef HAVE_COMPLEX
31 #include "cmplx.h"
33 #elif defined HAVE_TR1_COMPLEX
34 #include <tr1/complex>
35 using namespace std;
36 using namespace std::tr1;
37 typedef std::complex<nr_double_t> nr_complex_t;
38 #else
39 #include <complex>
40 using namespace std;
41 typedef std::complex<nr_double_t> nr_complex_t;
42 #endif
43 
44 // undefine this macro if it is defined already
45 #ifdef log2
46 #undef log2
47 #endif
48 
49 // create a complex object given rectangle coordinates
50 nr_complex_t rect (const nr_double_t x, const nr_double_t y = 0.0);
51 
52 // overloaded math functions
53 #ifndef HAVE_CXX_COMPLEX_ACOS
55 #endif
56 
57 #ifndef HAVE_CXX_COMPLEX_ACOSH
59 #endif
60 
61 #ifndef HAVE_CXX_COMPLEX_ASIN
63 #endif
64 
65 #ifndef HAVE_CXX_COMPLEX_ASINH
67 #endif
68 
69 #ifndef HAVE_CXX_COMPLEX_ATAN
71 #endif
72 
73 #ifndef HAVE_CXX_COMPLEX_ATANH
75 #endif
76 
77 #ifndef HAVE_CXX_COMPLEX_ATAN2
79 #endif
80 
81 #ifndef HAVE_CXX_COMPLEX_COS
83 #endif
84 
85 #ifndef HAVE_CXX_COMPLEX_COSH
87 #endif
88 
89 #ifndef HAVE_CXX_COMPLEX_EXP
91 #endif
92 
93 #ifndef HAVE_CXX_COMPLEX_FMOD
95 nr_complex_t fmod (const nr_complex_t x, const nr_double_t y);
96 nr_complex_t fmod (const nr_double_t x, const nr_complex_t y);
97 #endif
98 
99 #ifndef HAVE_CXX_COMPLEX_LOG
101 #endif
102 
103 #ifndef HAVE_CXX_COMPLEX_LOG10
105 #endif
106 
107 #ifndef HAVE_CXX_COMPLEX_LOG2
109 #endif
110 
111 #ifndef HAVE_CXX_COMPLEX_NORM
112 nr_double_t norm (const nr_complex_t);
113 #endif
114 
115 #ifndef HAVE_CXX_COMPLEX_POLAR
116 nr_complex_t polar (const nr_double_t mag, const nr_double_t ang = 0.0);
117 #endif
118 
119 #ifndef HAVE_CXX_COMPLEX_POLAR_COMPLEX
120 nr_complex_t polar (const nr_complex_t a, const nr_complex_t p);
121 nr_complex_t polar (const nr_double_t a, const nr_complex_t p);
122 nr_complex_t polar (const nr_complex_t a, const nr_double_t p = 0.0);
123 #endif
124 
125 #ifndef HAVE_CXX_COMPLEX_POW
126 nr_complex_t pow (const nr_complex_t, const nr_double_t);
127 nr_complex_t pow (const nr_double_t, const nr_complex_t);
129 #endif
130 
131 #ifndef HAVE_CXX_COMPLEX_SIN
133 #endif
134 
135 #ifndef HAVE_CXX_COMPLEX_SINH
137 #endif
138 
139 #ifndef HAVE_CXX_COMPLEX_SQRT
141 #endif
142 
143 #ifndef HAVE_CXX_COMPLEX_TAN
145 #endif
146 
147 #ifndef HAVE_CXX_COMPLEX_TANH
149 #endif
150 
151 // extra math functions
152 nr_double_t dB (const nr_complex_t);
159 nr_complex_t ztor (const nr_complex_t, const nr_complex_t zref = 50.0);
160 nr_complex_t rtoz (const nr_complex_t, const nr_complex_t zref = 50.0);
161 nr_complex_t ytor (const nr_complex_t, const nr_complex_t zref = 50.0);
162 nr_complex_t rtoy (const nr_complex_t, const nr_complex_t zref = 50.0);
166 nr_double_t xhypot (const nr_complex_t, const nr_complex_t);
167 nr_double_t xhypot (const nr_double_t, const nr_complex_t);
168 nr_double_t xhypot (const nr_complex_t, const nr_double_t);
176 nr_complex_t jn (const int, const nr_complex_t);
177 nr_complex_t yn (const int, const nr_complex_t);
183 
184 // modulo operators
186 nr_complex_t operator % (const nr_complex_t, const nr_double_t);
187 nr_complex_t operator % (const nr_double_t, const nr_complex_t);
188 
189 // comparisons
190 bool operator == (const nr_complex_t, const nr_complex_t);
191 bool operator != (const nr_complex_t, const nr_complex_t);
192 bool operator >= (const nr_complex_t, const nr_complex_t);
193 bool operator <= (const nr_complex_t, const nr_complex_t);
194 bool operator > (const nr_complex_t, const nr_complex_t);
195 bool operator < (const nr_complex_t, const nr_complex_t);
196 
197 #endif /* __COMPLEX_H__ */