fastlisaresponse 1.0.9__cp312-cp312-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fastlisaresponse might be problematic. Click here for more details.
- fastlisaresponse/__init__.py +1 -0
- fastlisaresponse/_version.py +1 -0
- fastlisaresponse/cutils/__init__.py +0 -0
- fastlisaresponse/cutils/include/LISAResponse.hh +22 -0
- fastlisaresponse/cutils/include/cuda_complex.hpp +1305 -0
- fastlisaresponse/cutils/pyresponse_cpu.cpython-312-darwin.so +0 -0
- fastlisaresponse/cutils/src/LISAResponse.cpp +919 -0
- fastlisaresponse/cutils/src/LISAResponse.cu +919 -0
- fastlisaresponse/cutils/src/responselisa.pyx +65 -0
- fastlisaresponse/pointer_adjust.py +33 -0
- fastlisaresponse/response.py +784 -0
- fastlisaresponse/utils/__init__.py +1 -0
- fastlisaresponse/utils/utility.py +82 -0
- fastlisaresponse-1.0.9.dist-info/METADATA +127 -0
- fastlisaresponse-1.0.9.dist-info/RECORD +17 -0
- fastlisaresponse-1.0.9.dist-info/WHEEL +5 -0
- fastlisaresponse-1.0.9.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1305 @@
|
|
|
1
|
+
// An implementation of C++ std::complex for use on CUDA devices.
|
|
2
|
+
// Written by John C. Travers <jtravs@gmail.com> (2012)
|
|
3
|
+
//
|
|
4
|
+
// Missing:
|
|
5
|
+
// - long double support (not supported on CUDA)
|
|
6
|
+
// - some integral pow functions (due to lack of C++11 support on CUDA)
|
|
7
|
+
//
|
|
8
|
+
// Heavily derived from the LLVM libcpp project (svn revision 147853).
|
|
9
|
+
// Based on libcxx/include/complex.
|
|
10
|
+
// The git history contains the complete change history from the original.
|
|
11
|
+
// The modifications are licensed as per the original LLVM license below.
|
|
12
|
+
//
|
|
13
|
+
// -*- C++ -*-
|
|
14
|
+
//===--------------------------- complex ----------------------------------===//
|
|
15
|
+
//
|
|
16
|
+
// The LLVM Compiler Infrastructure
|
|
17
|
+
//
|
|
18
|
+
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
19
|
+
// Source Licenses. See LICENSE.TXT for details.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
#ifndef CUDA_COMPLEX_HPP
|
|
24
|
+
#define CUDA_COMPLEX_HPP
|
|
25
|
+
|
|
26
|
+
#ifdef __CUDACC__
|
|
27
|
+
#define CUDA_CALLABLE_MEMBER __host__ __device__
|
|
28
|
+
#else
|
|
29
|
+
#define CUDA_CALLABLE_MEMBER
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
complex synopsis
|
|
34
|
+
template<class T>
|
|
35
|
+
class complex
|
|
36
|
+
{
|
|
37
|
+
public:
|
|
38
|
+
typedef T value_type;
|
|
39
|
+
complex(const T& re = T(), const T& im = T());
|
|
40
|
+
complex(const complex&);
|
|
41
|
+
template<class X> complex(const complex<X>&);
|
|
42
|
+
T real() const;
|
|
43
|
+
T imag() const;
|
|
44
|
+
void real(T);
|
|
45
|
+
void imag(T);
|
|
46
|
+
complex<T>& operator= (const T&);
|
|
47
|
+
complex<T>& operator+=(const T&);
|
|
48
|
+
complex<T>& operator-=(const T&);
|
|
49
|
+
complex<T>& operator*=(const T&);
|
|
50
|
+
complex<T>& operator/=(const T&);
|
|
51
|
+
complex& operator=(const complex&);
|
|
52
|
+
template<class X> complex<T>& operator= (const complex<X>&);
|
|
53
|
+
template<class X> complex<T>& operator+=(const complex<X>&);
|
|
54
|
+
template<class X> complex<T>& operator-=(const complex<X>&);
|
|
55
|
+
template<class X> complex<T>& operator*=(const complex<X>&);
|
|
56
|
+
template<class X> complex<T>& operator/=(const complex<X>&);
|
|
57
|
+
};
|
|
58
|
+
template<>
|
|
59
|
+
class complex<float>
|
|
60
|
+
{
|
|
61
|
+
public:
|
|
62
|
+
typedef float value_type;
|
|
63
|
+
constexpr complex(float re = 0.0f, float im = 0.0f);
|
|
64
|
+
explicit constexpr complex(const complex<double>&);
|
|
65
|
+
constexpr float real() const;
|
|
66
|
+
void real(float);
|
|
67
|
+
constexpr float imag() const;
|
|
68
|
+
void imag(float);
|
|
69
|
+
complex<float>& operator= (float);
|
|
70
|
+
complex<float>& operator+=(float);
|
|
71
|
+
complex<float>& operator-=(float);
|
|
72
|
+
complex<float>& operator*=(float);
|
|
73
|
+
complex<float>& operator/=(float);
|
|
74
|
+
complex<float>& operator=(const complex<float>&);
|
|
75
|
+
template<class X> complex<float>& operator= (const complex<X>&);
|
|
76
|
+
template<class X> complex<float>& operator+=(const complex<X>&);
|
|
77
|
+
template<class X> complex<float>& operator-=(const complex<X>&);
|
|
78
|
+
template<class X> complex<float>& operator*=(const complex<X>&);
|
|
79
|
+
template<class X> complex<float>& operator/=(const complex<X>&);
|
|
80
|
+
};
|
|
81
|
+
template<>
|
|
82
|
+
class complex<double>
|
|
83
|
+
{
|
|
84
|
+
public:
|
|
85
|
+
typedef double value_type;
|
|
86
|
+
constexpr complex(double re = 0.0, double im = 0.0);
|
|
87
|
+
constexpr complex(const complex<float>&);
|
|
88
|
+
constexpr double real() const;
|
|
89
|
+
void real(double);
|
|
90
|
+
constexpr double imag() const;
|
|
91
|
+
void imag(double);
|
|
92
|
+
complex<double>& operator= (double);
|
|
93
|
+
complex<double>& operator+=(double);
|
|
94
|
+
complex<double>& operator-=(double);
|
|
95
|
+
complex<double>& operator*=(double);
|
|
96
|
+
complex<double>& operator/=(double);
|
|
97
|
+
complex<double>& operator=(const complex<double>&);
|
|
98
|
+
template<class X> complex<double>& operator= (const complex<X>&);
|
|
99
|
+
template<class X> complex<double>& operator+=(const complex<X>&);
|
|
100
|
+
template<class X> complex<double>& operator-=(const complex<X>&);
|
|
101
|
+
template<class X> complex<double>& operator*=(const complex<X>&);
|
|
102
|
+
template<class X> complex<double>& operator/=(const complex<X>&);
|
|
103
|
+
};
|
|
104
|
+
// 26.3.6 operators:
|
|
105
|
+
template<class T> complex<T> operator+(const complex<T>&, const complex<T>&);
|
|
106
|
+
template<class T> complex<T> operator+(const complex<T>&, const T&);
|
|
107
|
+
template<class T> complex<T> operator+(const T&, const complex<T>&);
|
|
108
|
+
template<class T> complex<T> operator-(const complex<T>&, const complex<T>&);
|
|
109
|
+
template<class T> complex<T> operator-(const complex<T>&, const T&);
|
|
110
|
+
template<class T> complex<T> operator-(const T&, const complex<T>&);
|
|
111
|
+
template<class T> complex<T> operator*(const complex<T>&, const complex<T>&);
|
|
112
|
+
template<class T> complex<T> operator*(const complex<T>&, const T&);
|
|
113
|
+
template<class T> complex<T> operator*(const T&, const complex<T>&);
|
|
114
|
+
template<class T> complex<T> operator/(const complex<T>&, const complex<T>&);
|
|
115
|
+
template<class T> complex<T> operator/(const complex<T>&, const T&);
|
|
116
|
+
template<class T> complex<T> operator/(const T&, const complex<T>&);
|
|
117
|
+
template<class T> complex<T> operator+(const complex<T>&);
|
|
118
|
+
template<class T> complex<T> operator-(const complex<T>&);
|
|
119
|
+
template<class T> bool operator==(const complex<T>&, const complex<T>&);
|
|
120
|
+
template<class T> bool operator==(const complex<T>&, const T&);
|
|
121
|
+
template<class T> bool operator==(const T&, const complex<T>&);
|
|
122
|
+
template<class T> bool operator!=(const complex<T>&, const complex<T>&);
|
|
123
|
+
template<class T> bool operator!=(const complex<T>&, const T&);
|
|
124
|
+
template<class T> bool operator!=(const T&, const complex<T>&);
|
|
125
|
+
template<class T, class charT, class traits>
|
|
126
|
+
basic_istream<charT, traits>&
|
|
127
|
+
operator>>(basic_istream<charT, traits>&, complex<T>&);
|
|
128
|
+
template<class T, class charT, class traits>
|
|
129
|
+
basic_ostream<charT, traits>&
|
|
130
|
+
operator<<(basic_ostream<charT, traits>&, const complex<T>&);
|
|
131
|
+
// 26.3.7 values:
|
|
132
|
+
template<class T> T real(const complex<T>&);
|
|
133
|
+
double real(double);
|
|
134
|
+
template<Integral T> double real(T);
|
|
135
|
+
float real(float);
|
|
136
|
+
template<class T> T imag(const complex<T>&);
|
|
137
|
+
double imag(double);
|
|
138
|
+
template<Integral T> double imag(T);
|
|
139
|
+
float imag(float);
|
|
140
|
+
template<class T> T abs(const complex<T>&);
|
|
141
|
+
template<class T> T arg(const complex<T>&);
|
|
142
|
+
double arg(double);
|
|
143
|
+
template<Integral T> double arg(T);
|
|
144
|
+
float arg(float);
|
|
145
|
+
template<class T> T norm(const complex<T>&);
|
|
146
|
+
double norm(double);
|
|
147
|
+
template<Integral T> double norm(T);
|
|
148
|
+
float norm(float);
|
|
149
|
+
template<class T> complex<T> conj(const complex<T>&);
|
|
150
|
+
complex<double> conj(double);
|
|
151
|
+
template<Integral T> complex<double> conj(T);
|
|
152
|
+
complex<float> conj(float);
|
|
153
|
+
template<class T> complex<T> proj(const complex<T>&);
|
|
154
|
+
complex<double> proj(double);
|
|
155
|
+
template<Integral T> complex<double> proj(T);
|
|
156
|
+
complex<float> proj(float);
|
|
157
|
+
template<class T> complex<T> polar(const T&, const T& = 0);
|
|
158
|
+
// 26.3.8 transcendentals:
|
|
159
|
+
template<class T> complex<T> acos(const complex<T>&);
|
|
160
|
+
template<class T> complex<T> asin(const complex<T>&);
|
|
161
|
+
template<class T> complex<T> atan(const complex<T>&);
|
|
162
|
+
template<class T> complex<T> acosh(const complex<T>&);
|
|
163
|
+
template<class T> complex<T> asinh(const complex<T>&);
|
|
164
|
+
template<class T> complex<T> atanh(const complex<T>&);
|
|
165
|
+
template<class T> complex<T> cos (const complex<T>&);
|
|
166
|
+
template<class T> complex<T> cosh (const complex<T>&);
|
|
167
|
+
template<class T> complex<T> exp (const complex<T>&);
|
|
168
|
+
template<class T> complex<T> log (const complex<T>&);
|
|
169
|
+
template<class T> complex<T> log10(const complex<T>&);
|
|
170
|
+
template<class T> complex<T> pow(const complex<T>&, const T&);
|
|
171
|
+
template<class T> complex<T> pow(const complex<T>&, const complex<T>&);
|
|
172
|
+
template<class T> complex<T> pow(const T&, const complex<T>&);
|
|
173
|
+
template<class T> complex<T> sin (const complex<T>&);
|
|
174
|
+
template<class T> complex<T> sinh (const complex<T>&);
|
|
175
|
+
template<class T> complex<T> sqrt (const complex<T>&);
|
|
176
|
+
template<class T> complex<T> tan (const complex<T>&);
|
|
177
|
+
template<class T> complex<T> tanh (const complex<T>&);
|
|
178
|
+
template<class T, class charT, class traits>
|
|
179
|
+
basic_istream<charT, traits>&
|
|
180
|
+
operator>>(basic_istream<charT, traits>& is, complex<T>& x);
|
|
181
|
+
template<class T, class charT, class traits>
|
|
182
|
+
basic_ostream<charT, traits>&
|
|
183
|
+
operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
#include <math.h>
|
|
187
|
+
#include <sstream>
|
|
188
|
+
#include <complex>
|
|
189
|
+
|
|
190
|
+
namespace gcmplx {
|
|
191
|
+
template<class _Tp> class complex;
|
|
192
|
+
|
|
193
|
+
template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
|
|
194
|
+
template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
|
|
195
|
+
|
|
196
|
+
template<class _Tp>
|
|
197
|
+
class complex
|
|
198
|
+
{
|
|
199
|
+
public:
|
|
200
|
+
typedef _Tp value_type;
|
|
201
|
+
private:
|
|
202
|
+
value_type __re_;
|
|
203
|
+
value_type __im_;
|
|
204
|
+
public:
|
|
205
|
+
CUDA_CALLABLE_MEMBER
|
|
206
|
+
complex(const value_type& __re = value_type(), const value_type& __im = value_type())
|
|
207
|
+
: __re_(__re), __im_(__im) {}
|
|
208
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER
|
|
209
|
+
complex(const complex<_Xp>& __c)
|
|
210
|
+
: __re_(__c.real()), __im_(__c.imag()) {}
|
|
211
|
+
|
|
212
|
+
CUDA_CALLABLE_MEMBER value_type real() const {return __re_;}
|
|
213
|
+
CUDA_CALLABLE_MEMBER value_type imag() const {return __im_;}
|
|
214
|
+
|
|
215
|
+
CUDA_CALLABLE_MEMBER void real(value_type __re) {__re_ = __re;}
|
|
216
|
+
CUDA_CALLABLE_MEMBER void imag(value_type __im) {__im_ = __im;}
|
|
217
|
+
|
|
218
|
+
CUDA_CALLABLE_MEMBER complex& operator= (const value_type& __re)
|
|
219
|
+
{__re_ = __re; __im_ = value_type(); return *this;}
|
|
220
|
+
CUDA_CALLABLE_MEMBER complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
|
|
221
|
+
CUDA_CALLABLE_MEMBER complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
|
|
222
|
+
CUDA_CALLABLE_MEMBER complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
|
|
223
|
+
CUDA_CALLABLE_MEMBER complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
|
|
224
|
+
|
|
225
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator= (const complex<_Xp>& __c)
|
|
226
|
+
{
|
|
227
|
+
__re_ = __c.real();
|
|
228
|
+
__im_ = __c.imag();
|
|
229
|
+
return *this;
|
|
230
|
+
}
|
|
231
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator+=(const complex<_Xp>& __c)
|
|
232
|
+
{
|
|
233
|
+
__re_ += __c.real();
|
|
234
|
+
__im_ += __c.imag();
|
|
235
|
+
return *this;
|
|
236
|
+
}
|
|
237
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator-=(const complex<_Xp>& __c)
|
|
238
|
+
{
|
|
239
|
+
__re_ -= __c.real();
|
|
240
|
+
__im_ -= __c.imag();
|
|
241
|
+
return *this;
|
|
242
|
+
}
|
|
243
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator*=(const complex<_Xp>& __c)
|
|
244
|
+
{
|
|
245
|
+
*this = *this * __c;
|
|
246
|
+
return *this;
|
|
247
|
+
}
|
|
248
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator/=(const complex<_Xp>& __c)
|
|
249
|
+
{
|
|
250
|
+
*this = *this / __c;
|
|
251
|
+
return *this;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
template<> class complex<double>;
|
|
256
|
+
|
|
257
|
+
template<>
|
|
258
|
+
class complex<float>
|
|
259
|
+
{
|
|
260
|
+
float __re_;
|
|
261
|
+
float __im_;
|
|
262
|
+
public:
|
|
263
|
+
typedef float value_type;
|
|
264
|
+
|
|
265
|
+
/*constexpr*/ CUDA_CALLABLE_MEMBER complex(float __re = 0.0f, float __im = 0.0f)
|
|
266
|
+
: __re_(__re), __im_(__im) {}
|
|
267
|
+
explicit /*constexpr*/ complex(const complex<double>& __c);
|
|
268
|
+
|
|
269
|
+
/*constexpr*/ CUDA_CALLABLE_MEMBER float real() const {return __re_;}
|
|
270
|
+
/*constexpr*/ CUDA_CALLABLE_MEMBER float imag() const {return __im_;}
|
|
271
|
+
|
|
272
|
+
CUDA_CALLABLE_MEMBER void real(value_type __re) {__re_ = __re;}
|
|
273
|
+
CUDA_CALLABLE_MEMBER void imag(value_type __im) {__im_ = __im;}
|
|
274
|
+
|
|
275
|
+
CUDA_CALLABLE_MEMBER complex& operator= (float __re)
|
|
276
|
+
{__re_ = __re; __im_ = value_type(); return *this;}
|
|
277
|
+
CUDA_CALLABLE_MEMBER complex& operator+=(float __re) {__re_ += __re; return *this;}
|
|
278
|
+
CUDA_CALLABLE_MEMBER complex& operator-=(float __re) {__re_ -= __re; return *this;}
|
|
279
|
+
CUDA_CALLABLE_MEMBER complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
|
|
280
|
+
CUDA_CALLABLE_MEMBER complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
|
|
281
|
+
|
|
282
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator= (const complex<_Xp>& __c)
|
|
283
|
+
{
|
|
284
|
+
__re_ = __c.real();
|
|
285
|
+
__im_ = __c.imag();
|
|
286
|
+
return *this;
|
|
287
|
+
}
|
|
288
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator+=(const complex<_Xp>& __c)
|
|
289
|
+
{
|
|
290
|
+
__re_ += __c.real();
|
|
291
|
+
__im_ += __c.imag();
|
|
292
|
+
return *this;
|
|
293
|
+
}
|
|
294
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator-=(const complex<_Xp>& __c)
|
|
295
|
+
{
|
|
296
|
+
__re_ -= __c.real();
|
|
297
|
+
__im_ -= __c.imag();
|
|
298
|
+
return *this;
|
|
299
|
+
}
|
|
300
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator*=(const complex<_Xp>& __c)
|
|
301
|
+
{
|
|
302
|
+
*this = *this * __c;
|
|
303
|
+
return *this;
|
|
304
|
+
}
|
|
305
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator/=(const complex<_Xp>& __c)
|
|
306
|
+
{
|
|
307
|
+
*this = *this / __c;
|
|
308
|
+
return *this;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
template<>
|
|
313
|
+
class complex<double>
|
|
314
|
+
{
|
|
315
|
+
double __re_;
|
|
316
|
+
double __im_;
|
|
317
|
+
public:
|
|
318
|
+
typedef double value_type;
|
|
319
|
+
|
|
320
|
+
/*constexpr*/ CUDA_CALLABLE_MEMBER complex(double __re = 0.0, double __im = 0.0)
|
|
321
|
+
: __re_(__re), __im_(__im) {}
|
|
322
|
+
/*constexpr*/ complex(const complex<float>& __c);
|
|
323
|
+
|
|
324
|
+
/*constexpr*/ CUDA_CALLABLE_MEMBER double real() const {return __re_;}
|
|
325
|
+
/*constexpr*/ CUDA_CALLABLE_MEMBER double imag() const {return __im_;}
|
|
326
|
+
|
|
327
|
+
CUDA_CALLABLE_MEMBER void real(value_type __re) {__re_ = __re;}
|
|
328
|
+
CUDA_CALLABLE_MEMBER void imag(value_type __im) {__im_ = __im;}
|
|
329
|
+
|
|
330
|
+
CUDA_CALLABLE_MEMBER complex& operator= (double __re)
|
|
331
|
+
{__re_ = __re; __im_ = value_type(); return *this;}
|
|
332
|
+
CUDA_CALLABLE_MEMBER complex& operator+=(double __re) {__re_ += __re; return *this;}
|
|
333
|
+
CUDA_CALLABLE_MEMBER complex& operator-=(double __re) {__re_ -= __re; return *this;}
|
|
334
|
+
CUDA_CALLABLE_MEMBER complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
|
|
335
|
+
CUDA_CALLABLE_MEMBER complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
|
|
336
|
+
|
|
337
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator= (const complex<_Xp>& __c)
|
|
338
|
+
{
|
|
339
|
+
__re_ = __c.real();
|
|
340
|
+
__im_ = __c.imag();
|
|
341
|
+
return *this;
|
|
342
|
+
}
|
|
343
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator+=(const complex<_Xp>& __c)
|
|
344
|
+
{
|
|
345
|
+
__re_ += __c.real();
|
|
346
|
+
__im_ += __c.imag();
|
|
347
|
+
return *this;
|
|
348
|
+
}
|
|
349
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator-=(const complex<_Xp>& __c)
|
|
350
|
+
{
|
|
351
|
+
__re_ -= __c.real();
|
|
352
|
+
__im_ -= __c.imag();
|
|
353
|
+
return *this;
|
|
354
|
+
}
|
|
355
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator*=(const complex<_Xp>& __c)
|
|
356
|
+
{
|
|
357
|
+
*this = *this * __c;
|
|
358
|
+
return *this;
|
|
359
|
+
}
|
|
360
|
+
template<class _Xp> CUDA_CALLABLE_MEMBER complex& operator/=(const complex<_Xp>& __c)
|
|
361
|
+
{
|
|
362
|
+
*this = *this / __c;
|
|
363
|
+
return *this;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
//constexpr
|
|
368
|
+
inline CUDA_CALLABLE_MEMBER
|
|
369
|
+
complex<float>::complex(const complex<double>& __c)
|
|
370
|
+
: __re_(__c.real()), __im_(__c.imag()) {}
|
|
371
|
+
|
|
372
|
+
//constexpr
|
|
373
|
+
inline CUDA_CALLABLE_MEMBER
|
|
374
|
+
complex<double>::complex(const complex<float>& __c)
|
|
375
|
+
: __re_(__c.real()), __im_(__c.imag()) {}
|
|
376
|
+
|
|
377
|
+
// 26.3.6 operators:
|
|
378
|
+
|
|
379
|
+
template<class _Tp>
|
|
380
|
+
inline CUDA_CALLABLE_MEMBER
|
|
381
|
+
complex<_Tp>
|
|
382
|
+
operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
|
|
383
|
+
{
|
|
384
|
+
complex<_Tp> __t(__x);
|
|
385
|
+
__t += __y;
|
|
386
|
+
return __t;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
template<class _Tp>
|
|
390
|
+
inline CUDA_CALLABLE_MEMBER
|
|
391
|
+
complex<_Tp>
|
|
392
|
+
operator+(const complex<_Tp>& __x, const _Tp& __y)
|
|
393
|
+
{
|
|
394
|
+
complex<_Tp> __t(__x);
|
|
395
|
+
__t += __y;
|
|
396
|
+
return __t;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
template<class _Tp>
|
|
400
|
+
inline CUDA_CALLABLE_MEMBER
|
|
401
|
+
complex<_Tp>
|
|
402
|
+
operator+(const _Tp& __x, const complex<_Tp>& __y)
|
|
403
|
+
{
|
|
404
|
+
complex<_Tp> __t(__y);
|
|
405
|
+
__t += __x;
|
|
406
|
+
return __t;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
template<class _Tp>
|
|
410
|
+
inline CUDA_CALLABLE_MEMBER
|
|
411
|
+
complex<_Tp>
|
|
412
|
+
operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
|
|
413
|
+
{
|
|
414
|
+
complex<_Tp> __t(__x);
|
|
415
|
+
__t -= __y;
|
|
416
|
+
return __t;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
template<class _Tp>
|
|
420
|
+
inline CUDA_CALLABLE_MEMBER
|
|
421
|
+
complex<_Tp>
|
|
422
|
+
operator-(const complex<_Tp>& __x, const _Tp& __y)
|
|
423
|
+
{
|
|
424
|
+
complex<_Tp> __t(__x);
|
|
425
|
+
__t -= __y;
|
|
426
|
+
return __t;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
template<class _Tp>
|
|
430
|
+
inline CUDA_CALLABLE_MEMBER
|
|
431
|
+
complex<_Tp>
|
|
432
|
+
operator-(const _Tp& __x, const complex<_Tp>& __y)
|
|
433
|
+
{
|
|
434
|
+
complex<_Tp> __t(-__y);
|
|
435
|
+
__t += __x;
|
|
436
|
+
return __t;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
template<class _Tp>
|
|
440
|
+
CUDA_CALLABLE_MEMBER
|
|
441
|
+
complex<_Tp>
|
|
442
|
+
operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
|
|
443
|
+
{
|
|
444
|
+
_Tp __a = __z.real();
|
|
445
|
+
_Tp __b = __z.imag();
|
|
446
|
+
_Tp __c = __w.real();
|
|
447
|
+
_Tp __d = __w.imag();
|
|
448
|
+
_Tp __ac = __a * __c;
|
|
449
|
+
_Tp __bd = __b * __d;
|
|
450
|
+
_Tp __ad = __a * __d;
|
|
451
|
+
_Tp __bc = __b * __c;
|
|
452
|
+
_Tp __x = __ac - __bd;
|
|
453
|
+
_Tp __y = __ad + __bc;
|
|
454
|
+
if (isnan(__x) && isnan(__y))
|
|
455
|
+
{
|
|
456
|
+
bool __recalc = false;
|
|
457
|
+
if (isinf(__a) || isinf(__b))
|
|
458
|
+
{
|
|
459
|
+
__a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a);
|
|
460
|
+
__b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b);
|
|
461
|
+
if (isnan(__c))
|
|
462
|
+
__c = copysign(_Tp(0), __c);
|
|
463
|
+
if (isnan(__d))
|
|
464
|
+
__d = copysign(_Tp(0), __d);
|
|
465
|
+
__recalc = true;
|
|
466
|
+
}
|
|
467
|
+
if (isinf(__c) || isinf(__d))
|
|
468
|
+
{
|
|
469
|
+
__c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c);
|
|
470
|
+
__d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d);
|
|
471
|
+
if (isnan(__a))
|
|
472
|
+
__a = copysign(_Tp(0), __a);
|
|
473
|
+
if (isnan(__b))
|
|
474
|
+
__b = copysign(_Tp(0), __b);
|
|
475
|
+
__recalc = true;
|
|
476
|
+
}
|
|
477
|
+
if (!__recalc && (isinf(__ac) || isinf(__bd) ||
|
|
478
|
+
isinf(__ad) || isinf(__bc)))
|
|
479
|
+
{
|
|
480
|
+
if (isnan(__a))
|
|
481
|
+
__a = copysign(_Tp(0), __a);
|
|
482
|
+
if (isnan(__b))
|
|
483
|
+
__b = copysign(_Tp(0), __b);
|
|
484
|
+
if (isnan(__c))
|
|
485
|
+
__c = copysign(_Tp(0), __c);
|
|
486
|
+
if (isnan(__d))
|
|
487
|
+
__d = copysign(_Tp(0), __d);
|
|
488
|
+
__recalc = true;
|
|
489
|
+
}
|
|
490
|
+
if (__recalc)
|
|
491
|
+
{
|
|
492
|
+
__x = _Tp(INFINITY) * (__a * __c - __b * __d);
|
|
493
|
+
__y = _Tp(INFINITY) * (__a * __d + __b * __c);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return complex<_Tp>(__x, __y);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
template<class _Tp>
|
|
500
|
+
inline CUDA_CALLABLE_MEMBER
|
|
501
|
+
complex<_Tp>
|
|
502
|
+
operator*(const complex<_Tp>& __x, const _Tp& __y)
|
|
503
|
+
{
|
|
504
|
+
complex<_Tp> __t(__x);
|
|
505
|
+
__t *= __y;
|
|
506
|
+
return __t;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
template<class _Tp>
|
|
510
|
+
inline CUDA_CALLABLE_MEMBER
|
|
511
|
+
complex<_Tp>
|
|
512
|
+
operator*(const _Tp& __x, const complex<_Tp>& __y)
|
|
513
|
+
{
|
|
514
|
+
complex<_Tp> __t(__y);
|
|
515
|
+
__t *= __x;
|
|
516
|
+
return __t;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
template<class _Tp>
|
|
520
|
+
CUDA_CALLABLE_MEMBER
|
|
521
|
+
complex<_Tp>
|
|
522
|
+
operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
|
|
523
|
+
{
|
|
524
|
+
int __ilogbw = 0;
|
|
525
|
+
_Tp __a = __z.real();
|
|
526
|
+
_Tp __b = __z.imag();
|
|
527
|
+
_Tp __c = __w.real();
|
|
528
|
+
_Tp __d = __w.imag();
|
|
529
|
+
_Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
|
|
530
|
+
if (isfinite(__logbw))
|
|
531
|
+
{
|
|
532
|
+
__ilogbw = static_cast<int>(__logbw);
|
|
533
|
+
__c = scalbn(__c, -__ilogbw);
|
|
534
|
+
__d = scalbn(__d, -__ilogbw);
|
|
535
|
+
}
|
|
536
|
+
_Tp __denom = __c * __c + __d * __d;
|
|
537
|
+
_Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
|
|
538
|
+
_Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
|
|
539
|
+
if (isnan(__x) && isnan(__y))
|
|
540
|
+
{
|
|
541
|
+
if ((__denom == _Tp(0)) && (!isnan(__a) || !isnan(__b)))
|
|
542
|
+
{
|
|
543
|
+
__x = copysign(_Tp(INFINITY), __c) * __a;
|
|
544
|
+
__y = copysign(_Tp(INFINITY), __c) * __b;
|
|
545
|
+
}
|
|
546
|
+
else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
|
|
547
|
+
{
|
|
548
|
+
__a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a);
|
|
549
|
+
__b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b);
|
|
550
|
+
__x = _Tp(INFINITY) * (__a * __c + __b * __d);
|
|
551
|
+
__y = _Tp(INFINITY) * (__b * __c - __a * __d);
|
|
552
|
+
}
|
|
553
|
+
else if (isinf(__logbw) && __logbw > _Tp(0) && isfinite(__a) && isfinite(__b))
|
|
554
|
+
{
|
|
555
|
+
__c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c);
|
|
556
|
+
__d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d);
|
|
557
|
+
__x = _Tp(0) * (__a * __c + __b * __d);
|
|
558
|
+
__y = _Tp(0) * (__b * __c - __a * __d);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return complex<_Tp>(__x, __y);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/*inline template<>
|
|
565
|
+
CUDA_CALLABLE_MEMBER
|
|
566
|
+
complex<float>
|
|
567
|
+
operator/(const complex<float>& __z, const complex<float>& __w)
|
|
568
|
+
{
|
|
569
|
+
int __ilogbw = 0;
|
|
570
|
+
float __a = __z.real();
|
|
571
|
+
float __b = __z.imag();
|
|
572
|
+
float __c = __w.real();
|
|
573
|
+
float __d = __w.imag();
|
|
574
|
+
float __logbw = logbf(fmaxf(fabsf(__c), fabsf(__d)));
|
|
575
|
+
if (isfinite(__logbw))
|
|
576
|
+
{
|
|
577
|
+
__ilogbw = static_cast<int>(__logbw);
|
|
578
|
+
__c = scalbnf(__c, -__ilogbw);
|
|
579
|
+
__d = scalbnf(__d, -__ilogbw);
|
|
580
|
+
}
|
|
581
|
+
float __denom = __c * __c + __d * __d;
|
|
582
|
+
float __x = scalbnf((__a * __c + __b * __d) / __denom, -__ilogbw);
|
|
583
|
+
float __y = scalbnf((__b * __c - __a * __d) / __denom, -__ilogbw);
|
|
584
|
+
if (isnan(__x) && isnan(__y))
|
|
585
|
+
{
|
|
586
|
+
if ((__denom == float(0)) && (!isnan(__a) || !isnan(__b)))
|
|
587
|
+
{
|
|
588
|
+
#pragma warning(suppress: 4756) // Ignore INFINITY related warning
|
|
589
|
+
__x = copysignf(INFINITY, __c) * __a;
|
|
590
|
+
#pragma warning(suppress: 4756) // Ignore INFINITY related warning
|
|
591
|
+
__y = copysignf(INFINITY, __c) * __b;
|
|
592
|
+
}
|
|
593
|
+
else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
|
|
594
|
+
{
|
|
595
|
+
__a = copysignf(isinf(__a) ? float(1) : float(0), __a);
|
|
596
|
+
__b = copysignf(isinf(__b) ? float(1) : float(0), __b);
|
|
597
|
+
#pragma warning(suppress: 4756) // Ignore INFINITY related warning
|
|
598
|
+
__x = INFINITY * (__a * __c + __b * __d);
|
|
599
|
+
#pragma warning(suppress: 4756) // Ignore INFINITY related warning
|
|
600
|
+
__y = INFINITY * (__b * __c - __a * __d);
|
|
601
|
+
}
|
|
602
|
+
else if (isinf(__logbw) && __logbw > float(0) && isfinite(__a) && isfinite(__b))
|
|
603
|
+
{
|
|
604
|
+
__c = copysignf(isinf(__c) ? float(1) : float(0), __c);
|
|
605
|
+
__d = copysignf(isinf(__d) ? float(1) : float(0), __d);
|
|
606
|
+
__x = float(0) * (__a * __c + __b * __d);
|
|
607
|
+
__y = float(0) * (__b * __c - __a * __d);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return complex<float>(__x, __y);
|
|
611
|
+
}*/
|
|
612
|
+
|
|
613
|
+
template<class _Tp>
|
|
614
|
+
inline CUDA_CALLABLE_MEMBER
|
|
615
|
+
complex<_Tp>
|
|
616
|
+
operator/(const complex<_Tp>& __x, const _Tp& __y)
|
|
617
|
+
{
|
|
618
|
+
return complex<_Tp>(__x.real() / __y, __x.imag() / __y);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
template<class _Tp>
|
|
622
|
+
inline CUDA_CALLABLE_MEMBER
|
|
623
|
+
complex<_Tp>
|
|
624
|
+
operator/(const _Tp& __x, const complex<_Tp>& __y)
|
|
625
|
+
{
|
|
626
|
+
complex<_Tp> __t(__x);
|
|
627
|
+
__t /= __y;
|
|
628
|
+
return __t;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
template<class _Tp>
|
|
632
|
+
inline CUDA_CALLABLE_MEMBER
|
|
633
|
+
complex<_Tp>
|
|
634
|
+
operator+(const complex<_Tp>& __x)
|
|
635
|
+
{
|
|
636
|
+
return __x;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
template<class _Tp>
|
|
640
|
+
inline CUDA_CALLABLE_MEMBER
|
|
641
|
+
complex<_Tp>
|
|
642
|
+
operator-(const complex<_Tp>& __x)
|
|
643
|
+
{
|
|
644
|
+
return complex<_Tp>(-__x.real(), -__x.imag());
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
template<class _Tp>
|
|
648
|
+
inline CUDA_CALLABLE_MEMBER
|
|
649
|
+
bool
|
|
650
|
+
operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
|
|
651
|
+
{
|
|
652
|
+
return __x.real() == __y.real() && __x.imag() == __y.imag();
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
template<class _Tp>
|
|
656
|
+
inline CUDA_CALLABLE_MEMBER
|
|
657
|
+
bool
|
|
658
|
+
operator==(const complex<_Tp>& __x, const _Tp& __y)
|
|
659
|
+
{
|
|
660
|
+
return __x.real() == __y && __x.imag() == 0;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
template<class _Tp>
|
|
664
|
+
inline CUDA_CALLABLE_MEMBER
|
|
665
|
+
bool
|
|
666
|
+
operator==(const _Tp& __x, const complex<_Tp>& __y)
|
|
667
|
+
{
|
|
668
|
+
return __x == __y.real() && 0 == __y.imag();
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
template<class _Tp>
|
|
672
|
+
inline CUDA_CALLABLE_MEMBER
|
|
673
|
+
bool
|
|
674
|
+
operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
|
|
675
|
+
{
|
|
676
|
+
return !(__x == __y);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
template<class _Tp>
|
|
680
|
+
inline CUDA_CALLABLE_MEMBER
|
|
681
|
+
bool
|
|
682
|
+
operator!=(const complex<_Tp>& __x, const _Tp& __y)
|
|
683
|
+
{
|
|
684
|
+
return !(__x == __y);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
template<class _Tp>
|
|
688
|
+
inline CUDA_CALLABLE_MEMBER
|
|
689
|
+
bool
|
|
690
|
+
operator!=(const _Tp& __x, const complex<_Tp>& __y)
|
|
691
|
+
{
|
|
692
|
+
return !(__x == __y);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// 26.3.7 values:
|
|
696
|
+
|
|
697
|
+
// real
|
|
698
|
+
|
|
699
|
+
template<class _Tp>
|
|
700
|
+
inline CUDA_CALLABLE_MEMBER
|
|
701
|
+
_Tp
|
|
702
|
+
real(const complex<_Tp>& __c)
|
|
703
|
+
{
|
|
704
|
+
return __c.real();
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
inline CUDA_CALLABLE_MEMBER
|
|
708
|
+
double
|
|
709
|
+
real(double __re)
|
|
710
|
+
{
|
|
711
|
+
return __re;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
inline CUDA_CALLABLE_MEMBER
|
|
715
|
+
float
|
|
716
|
+
real(float __re)
|
|
717
|
+
{
|
|
718
|
+
return __re;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// imag
|
|
722
|
+
|
|
723
|
+
template<class _Tp>
|
|
724
|
+
inline CUDA_CALLABLE_MEMBER
|
|
725
|
+
_Tp
|
|
726
|
+
imag(const complex<_Tp>& __c)
|
|
727
|
+
{
|
|
728
|
+
return __c.imag();
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
inline CUDA_CALLABLE_MEMBER
|
|
732
|
+
double
|
|
733
|
+
imag(double __re)
|
|
734
|
+
{
|
|
735
|
+
return 0;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
inline CUDA_CALLABLE_MEMBER
|
|
739
|
+
float
|
|
740
|
+
imag(float __re)
|
|
741
|
+
{
|
|
742
|
+
return 0;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// abs
|
|
746
|
+
|
|
747
|
+
template<class _Tp>
|
|
748
|
+
inline CUDA_CALLABLE_MEMBER
|
|
749
|
+
_Tp
|
|
750
|
+
abs(const complex<_Tp>& __c)
|
|
751
|
+
{
|
|
752
|
+
return hypot(__c.real(), __c.imag());
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// arg
|
|
756
|
+
|
|
757
|
+
template<class _Tp>
|
|
758
|
+
inline CUDA_CALLABLE_MEMBER
|
|
759
|
+
_Tp
|
|
760
|
+
arg(const complex<_Tp>& __c)
|
|
761
|
+
{
|
|
762
|
+
return atan2(__c.imag(), __c.real());
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
inline CUDA_CALLABLE_MEMBER
|
|
766
|
+
double
|
|
767
|
+
arg(double __re)
|
|
768
|
+
{
|
|
769
|
+
return atan2(0., __re);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
inline CUDA_CALLABLE_MEMBER
|
|
773
|
+
float
|
|
774
|
+
arg(float __re)
|
|
775
|
+
{
|
|
776
|
+
return atan2f(0.F, __re);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// norm
|
|
780
|
+
|
|
781
|
+
template<class _Tp>
|
|
782
|
+
inline CUDA_CALLABLE_MEMBER
|
|
783
|
+
_Tp
|
|
784
|
+
norm(const complex<_Tp>& __c)
|
|
785
|
+
{
|
|
786
|
+
if (isinf(__c.real()))
|
|
787
|
+
return fabs(__c.real());
|
|
788
|
+
if (isinf(__c.imag()))
|
|
789
|
+
return fabs(__c.imag());
|
|
790
|
+
return __c.real() * __c.real() + __c.imag() * __c.imag();
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
inline CUDA_CALLABLE_MEMBER
|
|
794
|
+
double
|
|
795
|
+
norm(double __re)
|
|
796
|
+
{
|
|
797
|
+
return __re * __re;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
inline CUDA_CALLABLE_MEMBER
|
|
801
|
+
float
|
|
802
|
+
norm(float __re)
|
|
803
|
+
{
|
|
804
|
+
return __re * __re;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// conj
|
|
808
|
+
|
|
809
|
+
template<class _Tp>
|
|
810
|
+
inline CUDA_CALLABLE_MEMBER
|
|
811
|
+
complex<_Tp>
|
|
812
|
+
conj(const complex<_Tp>& __c)
|
|
813
|
+
{
|
|
814
|
+
return complex<_Tp>(__c.real(), -__c.imag());
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
inline CUDA_CALLABLE_MEMBER
|
|
818
|
+
complex<double>
|
|
819
|
+
conj(double __re)
|
|
820
|
+
{
|
|
821
|
+
return complex<double>(__re);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
inline CUDA_CALLABLE_MEMBER
|
|
825
|
+
complex<float>
|
|
826
|
+
conj(float __re)
|
|
827
|
+
{
|
|
828
|
+
return complex<float>(__re);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// proj
|
|
832
|
+
|
|
833
|
+
template<class _Tp>
|
|
834
|
+
inline CUDA_CALLABLE_MEMBER
|
|
835
|
+
complex<_Tp>
|
|
836
|
+
proj(const complex<_Tp>& __c)
|
|
837
|
+
{
|
|
838
|
+
complex<_Tp> __r = __c;
|
|
839
|
+
if (isinf(__c.real()) || isinf(__c.imag()))
|
|
840
|
+
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
|
|
841
|
+
return __r;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
inline CUDA_CALLABLE_MEMBER
|
|
845
|
+
complex<double>
|
|
846
|
+
proj(double __re)
|
|
847
|
+
{
|
|
848
|
+
if (isinf(__re))
|
|
849
|
+
__re = fabs(__re);
|
|
850
|
+
return complex<double>(__re);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
inline CUDA_CALLABLE_MEMBER
|
|
854
|
+
complex<float>
|
|
855
|
+
proj(float __re)
|
|
856
|
+
{
|
|
857
|
+
if (isinf(__re))
|
|
858
|
+
__re = fabs(__re);
|
|
859
|
+
return complex<float>(__re);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// polar
|
|
863
|
+
|
|
864
|
+
template<class _Tp>
|
|
865
|
+
CUDA_CALLABLE_MEMBER
|
|
866
|
+
complex<_Tp>
|
|
867
|
+
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
|
|
868
|
+
{
|
|
869
|
+
if (isnan(__rho) || signbit(__rho))
|
|
870
|
+
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
|
|
871
|
+
if (isnan(__theta))
|
|
872
|
+
{
|
|
873
|
+
if (isinf(__rho))
|
|
874
|
+
return complex<_Tp>(__rho, __theta);
|
|
875
|
+
return complex<_Tp>(__theta, __theta);
|
|
876
|
+
}
|
|
877
|
+
if (isinf(__theta))
|
|
878
|
+
{
|
|
879
|
+
if (isinf(__rho))
|
|
880
|
+
return complex<_Tp>(__rho, _Tp(NAN));
|
|
881
|
+
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
|
|
882
|
+
}
|
|
883
|
+
_Tp __x = __rho * cos(__theta);
|
|
884
|
+
if (isnan(__x))
|
|
885
|
+
__x = 0;
|
|
886
|
+
_Tp __y = __rho * sin(__theta);
|
|
887
|
+
if (isnan(__y))
|
|
888
|
+
__y = 0;
|
|
889
|
+
return complex<_Tp>(__x, __y);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// log
|
|
893
|
+
|
|
894
|
+
template<class _Tp>
|
|
895
|
+
inline CUDA_CALLABLE_MEMBER
|
|
896
|
+
complex<_Tp>
|
|
897
|
+
log(const complex<_Tp>& __x)
|
|
898
|
+
{
|
|
899
|
+
return complex<_Tp>(log(abs(__x)), arg(__x));
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// log10
|
|
903
|
+
|
|
904
|
+
template<class _Tp>
|
|
905
|
+
inline CUDA_CALLABLE_MEMBER
|
|
906
|
+
complex<_Tp>
|
|
907
|
+
log10(const complex<_Tp>& __x)
|
|
908
|
+
{
|
|
909
|
+
return log(__x) / log(_Tp(10));
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// sqrt
|
|
913
|
+
|
|
914
|
+
template<class _Tp>
|
|
915
|
+
CUDA_CALLABLE_MEMBER
|
|
916
|
+
complex<_Tp>
|
|
917
|
+
sqrt(const complex<_Tp>& __x)
|
|
918
|
+
{
|
|
919
|
+
if (isinf(__x.imag()))
|
|
920
|
+
return complex<_Tp>(_Tp(INFINITY), __x.imag());
|
|
921
|
+
if (isinf(__x.real()))
|
|
922
|
+
{
|
|
923
|
+
if (__x.real() > _Tp(0))
|
|
924
|
+
return complex<_Tp>(__x.real(), isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
|
|
925
|
+
return complex<_Tp>(isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
|
|
926
|
+
}
|
|
927
|
+
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// exp
|
|
931
|
+
|
|
932
|
+
template<class _Tp>
|
|
933
|
+
CUDA_CALLABLE_MEMBER
|
|
934
|
+
complex<_Tp>
|
|
935
|
+
exp(const complex<_Tp>& __x)
|
|
936
|
+
{
|
|
937
|
+
using namespace std;
|
|
938
|
+
_Tp __i = __x.imag();
|
|
939
|
+
if (isinf(__x.real()))
|
|
940
|
+
{
|
|
941
|
+
if (__x.real() < _Tp(0))
|
|
942
|
+
{
|
|
943
|
+
if (!isfinite(__i))
|
|
944
|
+
__i = _Tp(1);
|
|
945
|
+
}
|
|
946
|
+
else if (__i == 0 || !isfinite(__i))
|
|
947
|
+
{
|
|
948
|
+
if (isinf(__i))
|
|
949
|
+
__i = _Tp(NAN);
|
|
950
|
+
return complex<_Tp>(__x.real(), __i);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
else if (isnan(__x.real()) && __x.imag() == 0)
|
|
954
|
+
return __x;
|
|
955
|
+
_Tp __e = std::exp(__x.real());
|
|
956
|
+
return complex<_Tp>(__e * cos(__i), __e * sin(__i));
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// pow
|
|
960
|
+
|
|
961
|
+
template<class _Tp>
|
|
962
|
+
inline CUDA_CALLABLE_MEMBER
|
|
963
|
+
complex<_Tp>
|
|
964
|
+
pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
|
|
965
|
+
{
|
|
966
|
+
return exp(__y * log(__x));
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
template<class _Tp>
|
|
970
|
+
inline CUDA_CALLABLE_MEMBER
|
|
971
|
+
complex<_Tp>
|
|
972
|
+
pow(const complex<_Tp>& __x, const _Tp& __y)
|
|
973
|
+
{
|
|
974
|
+
return pow(__x, complex<_Tp>(__y));
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
template<class _Tp>
|
|
978
|
+
inline CUDA_CALLABLE_MEMBER
|
|
979
|
+
complex<_Tp>
|
|
980
|
+
pow(const _Tp& __x, const complex<_Tp>& __y)
|
|
981
|
+
{
|
|
982
|
+
return pow(complex<_Tp>(__x), __y);
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// asinh
|
|
986
|
+
|
|
987
|
+
template<class _Tp>
|
|
988
|
+
CUDA_CALLABLE_MEMBER
|
|
989
|
+
complex<_Tp>
|
|
990
|
+
asinh(const complex<_Tp>& __x)
|
|
991
|
+
{
|
|
992
|
+
const _Tp __pi(atan2(+0., -0.));
|
|
993
|
+
if (isinf(__x.real()))
|
|
994
|
+
{
|
|
995
|
+
if (isnan(__x.imag()))
|
|
996
|
+
return __x;
|
|
997
|
+
if (isinf(__x.imag()))
|
|
998
|
+
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
|
|
999
|
+
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
|
|
1000
|
+
}
|
|
1001
|
+
if (isnan(__x.real()))
|
|
1002
|
+
{
|
|
1003
|
+
if (isinf(__x.imag()))
|
|
1004
|
+
return complex<_Tp>(__x.imag(), __x.real());
|
|
1005
|
+
if (__x.imag() == 0)
|
|
1006
|
+
return __x;
|
|
1007
|
+
return complex<_Tp>(__x.real(), __x.real());
|
|
1008
|
+
}
|
|
1009
|
+
if (isinf(__x.imag()))
|
|
1010
|
+
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
|
1011
|
+
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
|
|
1012
|
+
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// acosh
|
|
1016
|
+
|
|
1017
|
+
template<class _Tp>
|
|
1018
|
+
CUDA_CALLABLE_MEMBER
|
|
1019
|
+
complex<_Tp>
|
|
1020
|
+
acosh(const complex<_Tp>& __x)
|
|
1021
|
+
{
|
|
1022
|
+
const _Tp __pi(atan2(+0., -0.));
|
|
1023
|
+
if (isinf(__x.real()))
|
|
1024
|
+
{
|
|
1025
|
+
if (isnan(__x.imag()))
|
|
1026
|
+
return complex<_Tp>(fabs(__x.real()), __x.imag());
|
|
1027
|
+
if (isinf(__x.imag()))
|
|
1028
|
+
if (__x.real() > 0)
|
|
1029
|
+
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
|
|
1030
|
+
else
|
|
1031
|
+
return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag()));
|
|
1032
|
+
if (__x.real() < 0)
|
|
1033
|
+
return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
|
|
1034
|
+
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
|
|
1035
|
+
}
|
|
1036
|
+
if (isnan(__x.real()))
|
|
1037
|
+
{
|
|
1038
|
+
if (isinf(__x.imag()))
|
|
1039
|
+
return complex<_Tp>(fabs(__x.imag()), __x.real());
|
|
1040
|
+
return complex<_Tp>(__x.real(), __x.real());
|
|
1041
|
+
}
|
|
1042
|
+
if (isinf(__x.imag()))
|
|
1043
|
+
return complex<_Tp>(fabs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
|
|
1044
|
+
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
|
|
1045
|
+
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// atanh
|
|
1049
|
+
|
|
1050
|
+
template<class _Tp>
|
|
1051
|
+
CUDA_CALLABLE_MEMBER
|
|
1052
|
+
complex<_Tp>
|
|
1053
|
+
atanh(const complex<_Tp>& __x)
|
|
1054
|
+
{
|
|
1055
|
+
const _Tp __pi(atan2(+0., -0.));
|
|
1056
|
+
if (isinf(__x.imag()))
|
|
1057
|
+
{
|
|
1058
|
+
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
|
1059
|
+
}
|
|
1060
|
+
if (isnan(__x.imag()))
|
|
1061
|
+
{
|
|
1062
|
+
if (isinf(__x.real()) || __x.real() == 0)
|
|
1063
|
+
return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
|
|
1064
|
+
return complex<_Tp>(__x.imag(), __x.imag());
|
|
1065
|
+
}
|
|
1066
|
+
if (isnan(__x.real()))
|
|
1067
|
+
{
|
|
1068
|
+
return complex<_Tp>(__x.real(), __x.real());
|
|
1069
|
+
}
|
|
1070
|
+
if (isinf(__x.real()))
|
|
1071
|
+
{
|
|
1072
|
+
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
|
1073
|
+
}
|
|
1074
|
+
if (fabs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
|
|
1075
|
+
{
|
|
1076
|
+
return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag()));
|
|
1077
|
+
}
|
|
1078
|
+
complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
|
|
1079
|
+
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// sinh
|
|
1083
|
+
|
|
1084
|
+
template<class _Tp>
|
|
1085
|
+
CUDA_CALLABLE_MEMBER
|
|
1086
|
+
complex<_Tp>
|
|
1087
|
+
sinh(const complex<_Tp>& __x)
|
|
1088
|
+
{
|
|
1089
|
+
if (isinf(__x.real()) && !isfinite(__x.imag()))
|
|
1090
|
+
return complex<_Tp>(__x.real(), _Tp(NAN));
|
|
1091
|
+
if (__x.real() == 0 && !isfinite(__x.imag()))
|
|
1092
|
+
return complex<_Tp>(__x.real(), _Tp(NAN));
|
|
1093
|
+
if (__x.imag() == 0 && !isfinite(__x.real()))
|
|
1094
|
+
return __x;
|
|
1095
|
+
return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// cosh
|
|
1099
|
+
|
|
1100
|
+
template<class _Tp>
|
|
1101
|
+
CUDA_CALLABLE_MEMBER
|
|
1102
|
+
complex<_Tp>
|
|
1103
|
+
cosh(const complex<_Tp>& __x)
|
|
1104
|
+
{
|
|
1105
|
+
if (isinf(__x.real()) && !isfinite(__x.imag()))
|
|
1106
|
+
return complex<_Tp>(fabs(__x.real()), _Tp(NAN));
|
|
1107
|
+
if (__x.real() == 0 && !isfinite(__x.imag()))
|
|
1108
|
+
return complex<_Tp>(_Tp(NAN), __x.real());
|
|
1109
|
+
if (__x.real() == 0 && __x.imag() == 0)
|
|
1110
|
+
return complex<_Tp>(_Tp(1), __x.imag());
|
|
1111
|
+
if (__x.imag() == 0 && !isfinite(__x.real()))
|
|
1112
|
+
return complex<_Tp>(fabs(__x.real()), __x.imag());
|
|
1113
|
+
return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
// tanh
|
|
1117
|
+
|
|
1118
|
+
template<class _Tp>
|
|
1119
|
+
CUDA_CALLABLE_MEMBER
|
|
1120
|
+
complex<_Tp>
|
|
1121
|
+
tanh(const complex<_Tp>& __x)
|
|
1122
|
+
{
|
|
1123
|
+
if (isinf(__x.real()))
|
|
1124
|
+
{
|
|
1125
|
+
if (!isfinite(__x.imag()))
|
|
1126
|
+
return complex<_Tp>(_Tp(1), _Tp(0));
|
|
1127
|
+
return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
|
|
1128
|
+
}
|
|
1129
|
+
if (isnan(__x.real()) && __x.imag() == 0)
|
|
1130
|
+
return __x;
|
|
1131
|
+
_Tp __2r(_Tp(2) * __x.real());
|
|
1132
|
+
_Tp __2i(_Tp(2) * __x.imag());
|
|
1133
|
+
_Tp __d(cosh(__2r) + cos(__2i));
|
|
1134
|
+
return complex<_Tp>(sinh(__2r)/__d, sin(__2i)/__d);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// asin
|
|
1138
|
+
|
|
1139
|
+
template<class _Tp>
|
|
1140
|
+
CUDA_CALLABLE_MEMBER
|
|
1141
|
+
complex<_Tp>
|
|
1142
|
+
asin(const complex<_Tp>& __x)
|
|
1143
|
+
{
|
|
1144
|
+
complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));
|
|
1145
|
+
return complex<_Tp>(__z.imag(), -__z.real());
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// acos
|
|
1149
|
+
|
|
1150
|
+
template<class _Tp>
|
|
1151
|
+
CUDA_CALLABLE_MEMBER
|
|
1152
|
+
complex<_Tp>
|
|
1153
|
+
acos(const complex<_Tp>& __x)
|
|
1154
|
+
{
|
|
1155
|
+
const _Tp __pi(atan2(+0., -0.));
|
|
1156
|
+
if (isinf(__x.real()))
|
|
1157
|
+
{
|
|
1158
|
+
if (isnan(__x.imag()))
|
|
1159
|
+
return complex<_Tp>(__x.imag(), __x.real());
|
|
1160
|
+
if (isinf(__x.imag()))
|
|
1161
|
+
{
|
|
1162
|
+
if (__x.real() < _Tp(0))
|
|
1163
|
+
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
|
|
1164
|
+
return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
|
|
1165
|
+
}
|
|
1166
|
+
if (__x.real() < _Tp(0))
|
|
1167
|
+
return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
|
|
1168
|
+
return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
|
|
1169
|
+
}
|
|
1170
|
+
if (isnan(__x.real()))
|
|
1171
|
+
{
|
|
1172
|
+
if (isinf(__x.imag()))
|
|
1173
|
+
return complex<_Tp>(__x.real(), -__x.imag());
|
|
1174
|
+
return complex<_Tp>(__x.real(), __x.real());
|
|
1175
|
+
}
|
|
1176
|
+
if (isinf(__x.imag()))
|
|
1177
|
+
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
|
1178
|
+
if (__x.real() == 0)
|
|
1179
|
+
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
|
1180
|
+
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
|
|
1181
|
+
if (signbit(__x.imag()))
|
|
1182
|
+
return complex<_Tp>(fabs(__z.imag()), fabs(__z.real()));
|
|
1183
|
+
return complex<_Tp>(fabs(__z.imag()), -fabs(__z.real()));
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// atan
|
|
1187
|
+
|
|
1188
|
+
template<class _Tp>
|
|
1189
|
+
CUDA_CALLABLE_MEMBER
|
|
1190
|
+
complex<_Tp>
|
|
1191
|
+
atan(const complex<_Tp>& __x)
|
|
1192
|
+
{
|
|
1193
|
+
complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));
|
|
1194
|
+
return complex<_Tp>(__z.imag(), -__z.real());
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// sin
|
|
1198
|
+
|
|
1199
|
+
template<class _Tp>
|
|
1200
|
+
CUDA_CALLABLE_MEMBER
|
|
1201
|
+
complex<_Tp>
|
|
1202
|
+
sin(const complex<_Tp>& __x)
|
|
1203
|
+
{
|
|
1204
|
+
complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));
|
|
1205
|
+
return complex<_Tp>(__z.imag(), -__z.real());
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// cos
|
|
1209
|
+
|
|
1210
|
+
template<class _Tp>
|
|
1211
|
+
inline CUDA_CALLABLE_MEMBER
|
|
1212
|
+
complex<_Tp>
|
|
1213
|
+
cos(const complex<_Tp>& __x)
|
|
1214
|
+
{
|
|
1215
|
+
return cosh(complex<_Tp>(-__x.imag(), __x.real()));
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// tan
|
|
1219
|
+
|
|
1220
|
+
template<class _Tp>
|
|
1221
|
+
CUDA_CALLABLE_MEMBER
|
|
1222
|
+
complex<_Tp>
|
|
1223
|
+
tan(const complex<_Tp>& __x)
|
|
1224
|
+
{
|
|
1225
|
+
complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));
|
|
1226
|
+
return complex<_Tp>(__z.imag(), -__z.real());
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
template<class _Tp, class _CharT, class _Traits>
|
|
1230
|
+
std::basic_istream<_CharT, _Traits>&
|
|
1231
|
+
operator>>(std::basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
|
|
1232
|
+
{
|
|
1233
|
+
if (__is.good())
|
|
1234
|
+
{
|
|
1235
|
+
ws(__is);
|
|
1236
|
+
if (__is.peek() == _CharT('('))
|
|
1237
|
+
{
|
|
1238
|
+
__is.get();
|
|
1239
|
+
_Tp __r;
|
|
1240
|
+
__is >> __r;
|
|
1241
|
+
if (!__is.fail())
|
|
1242
|
+
{
|
|
1243
|
+
ws(__is);
|
|
1244
|
+
_CharT __c = __is.peek();
|
|
1245
|
+
if (__c == _CharT(','))
|
|
1246
|
+
{
|
|
1247
|
+
__is.get();
|
|
1248
|
+
_Tp __i;
|
|
1249
|
+
__is >> __i;
|
|
1250
|
+
if (!__is.fail())
|
|
1251
|
+
{
|
|
1252
|
+
ws(__is);
|
|
1253
|
+
__c = __is.peek();
|
|
1254
|
+
if (__c == _CharT(')'))
|
|
1255
|
+
{
|
|
1256
|
+
__is.get();
|
|
1257
|
+
__x = complex<_Tp>(__r, __i);
|
|
1258
|
+
}
|
|
1259
|
+
else
|
|
1260
|
+
__is.setstate(std::ios_base::failbit);
|
|
1261
|
+
}
|
|
1262
|
+
else
|
|
1263
|
+
__is.setstate(std::ios_base::failbit);
|
|
1264
|
+
}
|
|
1265
|
+
else if (__c == _CharT(')'))
|
|
1266
|
+
{
|
|
1267
|
+
__is.get();
|
|
1268
|
+
__x = complex<_Tp>(__r, _Tp(0));
|
|
1269
|
+
}
|
|
1270
|
+
else
|
|
1271
|
+
__is.setstate(std::ios_base::failbit);
|
|
1272
|
+
}
|
|
1273
|
+
else
|
|
1274
|
+
__is.setstate(std::ios_base::failbit);
|
|
1275
|
+
}
|
|
1276
|
+
else
|
|
1277
|
+
{
|
|
1278
|
+
_Tp __r;
|
|
1279
|
+
__is >> __r;
|
|
1280
|
+
if (!__is.fail())
|
|
1281
|
+
__x = complex<_Tp>(__r, _Tp(0));
|
|
1282
|
+
else
|
|
1283
|
+
__is.setstate(std::ios_base::failbit);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
else
|
|
1287
|
+
__is.setstate(std::ios_base::failbit);
|
|
1288
|
+
return __is;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
template<class _Tp, class _CharT, class _Traits>
|
|
1292
|
+
std::basic_ostream<_CharT, _Traits>&
|
|
1293
|
+
operator<<(std::basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
|
|
1294
|
+
{
|
|
1295
|
+
std::basic_ostringstream<_CharT, _Traits> __s;
|
|
1296
|
+
__s.flags(__os.flags());
|
|
1297
|
+
__s.imbue(__os.getloc());
|
|
1298
|
+
__s.precision(__os.precision());
|
|
1299
|
+
__s << '(' << __x.real() << ',' << __x.imag() << ')';
|
|
1300
|
+
return __os << __s.str();
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
} // close namespace cuda_complex
|
|
1304
|
+
|
|
1305
|
+
#endif // CUDA_COMPLEX_HPP
|