Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
22  *
23  */
24 
25 #ifndef __COMPLEX_H__
26 #define __COMPLEX_H__
27 
28 #include <complex>
29 #include "real.h"
30 
31 typedef std::complex<nr_double_t> nr_complex_t;
32 
33 // undefine this macro if it is defined already
34 #ifdef log2
35 #undef log2
36 #endif
37 
38 namespace qucs {
39 
40 // see http://www.cplusplus.com/reference/complex/
41 
42 //
43 // trigonometric complex
44 //
48 nr_complex_t acos (const nr_complex_t); //c++11
49 nr_complex_t asin (const nr_complex_t); //c++11
50 nr_complex_t atan (const nr_complex_t); //c++11
51 
52 //
53 // hyperbolic complex
54 //
58 nr_complex_t acosh (const nr_complex_t); //c++11
59 nr_complex_t asinh (const nr_complex_t); //c++11
60 nr_complex_t atanh (const nr_complex_t); //c++11
61 
62 //
63 // transcendentals overloads
64 //
68 nr_complex_t pow (const nr_complex_t, const nr_double_t);
69 nr_complex_t pow (const nr_double_t, const nr_complex_t);
72 
73 nr_double_t norm (const nr_complex_t);
74 
75 
76 //
77 // Qucs extra trancendental functions
78 //
87 
88 
89 //
90 // extra math
91 //
96 nr_double_t xhypot (const nr_complex_t, const nr_complex_t);
97 nr_double_t xhypot (const nr_double_t, const nr_complex_t);
98 nr_double_t xhypot (const nr_complex_t, const nr_double_t);
99 
102 
103 
104 nr_double_t dB (const nr_complex_t);
105 
107 
108 nr_complex_t polar (const nr_double_t mag, const nr_double_t theta = 0.0);
110 //nr_complex_t polar (const nr_double_t a, const nr_complex_t p);
111 //nr_complex_t polar (const nr_complex_t a, const nr_double_t p = 0.0);
112 nr_complex_t polar (const nr_complex_t a, const nr_complex_t p = 0.0);
113 
114 
115 nr_complex_t ztor (const nr_complex_t, const nr_complex_t zref = 50.0);
116 nr_complex_t rtoz (const nr_complex_t, const nr_complex_t zref = 50.0);
117 nr_complex_t ytor (const nr_complex_t, const nr_complex_t zref = 50.0);
118 nr_complex_t rtoy (const nr_complex_t, const nr_complex_t zref = 50.0);
119 
120 
123 nr_complex_t fix (const nr_complex_t );
124 
127 nr_complex_t sqr (const nr_complex_t z);
128 
130 
131 
132 // bessel functions
133 nr_complex_t jn (const int, const nr_complex_t);
134 nr_complex_t yn (const int, const nr_complex_t);
136 
137 
138 // error functions
141 nr_complex_t erfinv (const nr_complex_t); //see fspecial
142 nr_complex_t erfcinv (const nr_complex_t); //see fspecial
143 
144 
145 // modulo operators
147 nr_complex_t operator % (const nr_complex_t, const nr_double_t);
148 nr_complex_t operator % (const nr_double_t, const nr_complex_t);
149 
150 // comparisons
151 bool operator == (const nr_complex_t, const nr_complex_t);
152 bool operator != (const nr_complex_t, const nr_complex_t);
153 bool operator >= (const nr_complex_t, const nr_complex_t);
154 bool operator <= (const nr_complex_t, const nr_complex_t);
155 bool operator > (const nr_complex_t, const nr_complex_t);
156 bool operator < (const nr_complex_t, const nr_complex_t);
157 
158 } // namespace qucs
159 
160 #endif /* __COMPLEX_H__ */
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
nr_complex_t erf(const nr_complex_t z)
Error function.
Definition: complex.cpp:766
bool operator<=(const nr_complex_t z1, const nr_complex_t z2)
Inferior of equal.
Definition: complex.cpp:881
nr_complex_t ceil(const nr_complex_t z)
Complex ceil Ceil is the smallest integral value not less than argument Apply ceil to real and imagin...
Definition: complex.cpp:634
nr_complex_t coth(const nr_complex_t z)
Compute complex hyperbolic cotangent.
Definition: complex.cpp:320
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
Definition: complex.cpp:238
nr_complex_t cos(const nr_complex_t z)
Compute complex cosine.
Definition: complex.cpp:57
nr_complex_t step(const nr_complex_t z)
Heaviside step function for complex number.
Definition: complex.cpp:691
nr_complex_t signum(const nr_complex_t z)
complex signum function
Definition: complex.cpp:416
nr_complex_t atan(const nr_complex_t z)
Compute complex arc tangent.
Definition: complex.cpp:117
nr_complex_t cot(const nr_complex_t z)
Compute complex cotangent.
Definition: complex.cpp:298
nr_complex_t asech(const nr_complex_t z)
Compute complex argument hyperbolic secant.
Definition: complex.cpp:354
nr_complex_t acot(const nr_complex_t z)
Compute complex arc cotangent.
Definition: complex.cpp:310
bool operator>(const nr_complex_t z1, const nr_complex_t z2)
Superior.
Definition: complex.cpp:889
nr_complex_t acosh(const nr_complex_t z)
Compute complex arc hyperbolic cosine.
Definition: complex.cpp:162
nr_complex_t rtoz(const nr_complex_t r, nr_complex_t zref)
Converts reflexion coefficient to impedance.
Definition: complex.cpp:590
nr_complex_t sign(const nr_complex_t z)
complex sign function
Definition: complex.cpp:435
nr_complex_t asinh(const nr_complex_t z)
Compute complex arc hyperbolic sine.
Definition: complex.cpp:175
nr_complex_t cosh(const nr_complex_t z)
Compute complex hyperbolic cosine.
Definition: complex.cpp:135
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
Definition: complex.cpp:673
nr_complex_t fix(const nr_complex_t z)
Complex fix.
Definition: complex.cpp:645
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
Definition: complex.cpp:271
nr_double_t xhypot(const nr_complex_t a, const nr_complex_t b)
Euclidean distance function for complex argument.
Definition: complex.cpp:465
nr_complex_t trunc(const nr_complex_t z)
Complex trunc Apply round to integer, towards zero to real and imaginary part.
Definition: complex.cpp:512
nr_complex_t acos(const nr_complex_t z)
Compute complex arc cosine.
Definition: complex.cpp:84
nr_complex_t log2(const nr_complex_t z)
Compute principal value of binary logarithm of z.
Definition: complex.cpp:393
nr_complex_t fmod(const nr_complex_t x, const nr_complex_t y)
Complex fmod Apply fmod to the complex z.
Definition: complex.cpp:662
nr_complex_t cosech(const nr_complex_t z)
Compute complex argument hyperbolic cosec.
Definition: complex.cpp:364
nr_complex_t yn(const int n, const nr_complex_t z)
Bessel function of second kind.
Definition: complex.cpp:742
nr_complex_t tanh(const nr_complex_t z)
Compute complex hyperbolic tangent.
Definition: complex.cpp:153
nr_complex_t sin(const nr_complex_t z)
Compute complex sine.
Definition: complex.cpp:66
nr_complex_t ztor(const nr_complex_t z, nr_complex_t zref)
Converts impedance to reflexion coefficient.
Definition: complex.cpp:581
nr_double_t dB(const nr_complex_t z)
Magnitude in dB Compute .
Definition: complex.cpp:528
nr_complex_t asin(const nr_complex_t z)
Compute complex arc sine.
Definition: complex.cpp:102
nr_complex_t acoth(const nr_complex_t z)
Compute complex argument hyperbolic cotangent.
Definition: complex.cpp:332
bool operator!=(const nr_complex_t z1, const nr_complex_t z2)
Inequality of two complex.
Definition: complex.cpp:865
x
Definition: parse_mdl.y:498
nr_complex_t log10(const nr_complex_t z)
Compute principal value of decimal logarithm of z.
Definition: complex.cpp:225
nr_complex_t floor(const nr_complex_t z)
Complex floor.
Definition: complex.cpp:623
nr_complex_t sech(const nr_complex_t z)
Compute complex hyperbolic secant.
Definition: complex.cpp:343
nr_complex_t erfc(const nr_complex_t z)
Complementart error function.
Definition: complex.cpp:784
nr_complex_t ytor(const nr_complex_t y, nr_complex_t zref)
Converts admittance to reflexion coefficient.
Definition: complex.cpp:599
nr_complex_t erfinv(const nr_complex_t z)
Inverse of error function.
Definition: complex.cpp:802
nr_complex_t rtoy(const nr_complex_t r, nr_complex_t zref)
Converts reflexion coefficient to admittance.
Definition: complex.cpp:608
nr_complex_t i0(const nr_complex_t z)
Modified Bessel function of first kind.
Definition: complex.cpp:754
nr_complex_t atan2(const nr_complex_t y, const nr_complex_t x)
Compute complex arc tangent fortran like function.
Definition: complex.cpp:377
nr_complex_t sinc(const nr_complex_t z)
Cardinal sine.
Definition: complex.cpp:448
nr_complex_t erfcinv(const nr_complex_t z)
Inverse of complementart error function.
Definition: complex.cpp:813
bool operator==(const nr_complex_t z1, const nr_complex_t z2)
Equality of two complex.
Definition: complex.cpp:854
nr_complex_t limexp(const nr_complex_t z)
Compute limited complex exponential.
Definition: complex.cpp:539
nr_double_t norm(const nr_complex_t z)
Compute euclidian norm of complex number.
Definition: complex.cpp:283
nr_complex_t sinh(const nr_complex_t z)
Compute complex hyperbolic sine.
Definition: complex.cpp:144
y
Definition: parse_mdl.y:499
bool operator>=(const nr_complex_t z1, const nr_complex_t z2)
Superior of equal.
Definition: complex.cpp:873
nr_complex_t jn(const int n, const nr_complex_t z)
Bessel function of first kind.
Definition: complex.cpp:729
nr_complex_t tan(const nr_complex_t z)
Compute complex tangent.
Definition: complex.cpp:75
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
Definition: complex.cpp:205
nr_complex_t operator%(const nr_complex_t z1, const nr_complex_t z2)
Modulo.
Definition: complex.cpp:826
nr_complex_t polar(const nr_double_t mag, const nr_double_t ang)
Construct a complex number using polar notation.
Definition: complex.cpp:551
zref
Definition: parse_zvr.y:130
nr_complex_t log(const nr_complex_t z)
Compute principal value of natural logarithm of z.
Definition: complex.cpp:215
bool operator<(const nr_complex_t z1, const nr_complex_t z2)
Inferior.
Definition: complex.cpp:897
nr_complex_t round(const nr_complex_t z)
Complex round Round is the nearest integral value Apply round to real and imaginary part...
Definition: complex.cpp:496
nr_complex_t atanh(const nr_complex_t z)
Compute complex arc hyperbolic tangent.
Definition: complex.cpp:188