1648
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1648
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_oct_cmplx_h) |
|
24 #define octave_oct_cmplx_h 1 |
|
25 |
3775
|
26 // By using this file instead of <complex>, we can easily avoid buggy |
|
27 // implementations of the standard complex data type (if needed). |
|
28 |
1648
|
29 #include <complex> |
|
30 |
3504
|
31 typedef std::complex<double> Complex; |
1648
|
32 |
3775
|
33 #if defined (CXX_ISO_COMPLIANT_LIBRARY) |
|
34 |
|
35 // If namespaces don't work, we will end up with some infinite looping. |
|
36 |
|
37 inline double |
|
38 real (const Complex& z) |
|
39 { |
|
40 return std::real (z); |
|
41 } |
|
42 |
|
43 inline double |
|
44 imag (const Complex& z) |
|
45 { |
|
46 return std::imag (z); |
|
47 } |
|
48 |
|
49 inline double |
|
50 abs (const Complex& z) |
|
51 { |
|
52 return std::abs (z); |
|
53 } |
|
54 |
|
55 inline double |
|
56 arg (const Complex& z) |
|
57 { |
|
58 return std::arg (z); |
|
59 } |
|
60 |
|
61 inline double |
|
62 norm (const Complex& z) |
|
63 { |
|
64 return std::norm (z); |
|
65 } |
|
66 |
|
67 inline Complex |
|
68 conj (const Complex& z) |
|
69 { |
|
70 return std::conj (z); |
|
71 } |
|
72 |
|
73 inline Complex |
|
74 polar (const double& x, const double& y); |
|
75 |
|
76 inline Complex |
|
77 cos (const Complex& z) |
|
78 { |
|
79 return std::cos (z); |
|
80 } |
|
81 |
|
82 inline Complex |
|
83 cosh (const Complex& z) |
|
84 { |
|
85 return std::cosh (z); |
|
86 } |
|
87 |
|
88 inline Complex |
|
89 exp (const Complex& z) |
|
90 { |
|
91 return std::exp (z); |
|
92 } |
|
93 |
|
94 inline Complex |
|
95 log (const Complex& z) |
|
96 { |
|
97 return std::log (z); |
|
98 } |
|
99 |
|
100 inline Complex |
|
101 log10 (const Complex& z) |
|
102 { |
|
103 return std::log10 (z); |
|
104 } |
|
105 |
|
106 inline Complex |
|
107 pow (const Complex& z, int n) |
|
108 { |
|
109 return std::pow (z, n); |
|
110 } |
|
111 |
|
112 inline Complex |
|
113 pow (const Complex& z, const double& x) |
|
114 { |
4921
|
115 // XXX FIXME XXX -- this should not be needed, but it avoids a bug |
|
116 // in some versions of libstdc++ (3.3.x and possibly others). |
|
117 |
|
118 return std::pow (z, Complex (x)); |
3775
|
119 } |
|
120 |
|
121 inline Complex |
|
122 pow (const Complex& z1, const Complex& z2) |
|
123 { |
|
124 return std::pow (z1, z2); |
|
125 } |
|
126 |
|
127 inline Complex |
|
128 pow (const double& x, const Complex& z) |
|
129 { |
|
130 return std::pow (x, z); |
|
131 } |
|
132 |
|
133 inline Complex |
|
134 sin (const Complex& z) |
|
135 { |
|
136 return std::sin (z); |
|
137 } |
|
138 |
|
139 inline Complex |
|
140 sinh (const Complex& z) |
|
141 { |
|
142 return std::sinh (z); |
|
143 } |
|
144 |
|
145 inline Complex |
|
146 sqrt (const Complex& z) |
|
147 { |
|
148 return std::sqrt (z); |
|
149 } |
|
150 |
|
151 inline Complex |
|
152 tan (const Complex& z) |
|
153 { |
|
154 return std::tan (z); |
|
155 } |
|
156 |
|
157 inline Complex |
|
158 tanh (const Complex& z) |
|
159 { |
|
160 return std::tanh (z); |
|
161 } |
|
162 |
|
163 #endif |
|
164 |
1648
|
165 #endif |
|
166 |
|
167 /* |
|
168 ;;; Local Variables: *** |
|
169 ;;; mode: C++ *** |
|
170 ;;; End: *** |
|
171 */ |