This file is indexed.

/usr/include/thrust/complex.h is in libthrust-dev 1.8.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
/*
 *  Copyright 2008-2013 NVIDIA Corporation
 *  Copyright 2013 Filipe RNC Maia
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/*! \file complex.h
 *  \brief Complex numbers
 */

#pragma once

#include <thrust/detail/config.h>

#include <cmath>
#include <complex>
#include <sstream>
#include <thrust/detail/type_traits.h>


namespace thrust
{

/*
 *  Calls to the standard math library from inside the thrust namespace 
 *  with real arguments require explicit scope otherwise they will fail
 *  to resolve as it will find the equivalent complex function but then
 *  fail to match the template, and give up looking for other scopes.
 */



/*! \addtogroup numerics
 *  \{
 */

/*! \addtogroup complex_numbers Complex Numbers
 *  \{
 */

  /*! \p complex is the Thrust equivalent to <tt>std::complex</tt>. It is functionally
   *  equivalent to it, but can also be used in device code which <tt>std::complex</tt> currently cannot.
   *
   *  \tparam T The type used to hold the real and imaginary parts. Should be <tt>float</tt> 
   *  or <tt>double</tt>. Others types are not supported.
   *
   */
template <typename T>
struct complex
{
public:

  /*! \p value_type is the type of \p complex's real and imaginary parts.
   */
  typedef T value_type;

  /* --- Constructors --- */

  /*! Construct a complex number from its real and imaginary parts.
   *
   *  \param re The real part of the number.
   *  \param im The imaginary part of the number.
   */
  inline __host__ __device__      
  complex(const T & re = T(), const T& im = T());

  /*! This copy constructor copies from a \p complex with a type that
   *  is convertible to this \p complex \c value_type.
   *
   *  \param z The \p complex to copy from.
   *
   *  \tparam X is convertible to \c value_type.
   */
  template <typename X> 
  inline __host__ __device__
  complex(const complex<X> & z);
  
  /*! This copy constructor copies from a <tt>std::complex</tt> with a type that
   *  is convertible to this \p complex \c value_type.
   *
   *  \param z The \p complex to copy from.
   *
   *  \tparam X is convertible to \c value_type.
   */
  template <typename X> 
    inline __host__
  complex(const std::complex<X> & z);



  /* --- Compound Assignment Operators --- */

  /*! Adds a \p complex to this \p complex and 
   *  assigns the result to this \p complex.
   *
   *  \param z The \p complex to be Added.
   */
  __host__ __device__
  inline complex<T>& operator+=(const complex<T> z);

  /*! Subtracts a \p complex from this \p complex and 
   *  assigns the result to this \p complex.
   *
   *  \param z The \p complex to be subtracted.
   */
  __host__ __device__
  inline complex<T>& operator-=(const complex<T> z);

  /*! Multiplies this \p complex by another \p complex and 
   *  assigns the result to this \p complex.
   *
   *  \param z The \p complex to be multiplied.
   */
  __host__ __device__
  inline complex<T>& operator*=(const complex<T> z);

  /*! Divides this \p complex by another \p complex and 
   *  assigns the result to this \p complex.
   *
   *  \param z The \p complex to be divided.
   */
  __host__ __device__
  inline complex<T>& operator/=(const complex<T> z);



  /* --- Getter functions --- 
   * The volatile ones are there to help for example
   * with certain reductions optimizations
   */

  /*! Returns the real part of this \p complex.
   */
  __host__ __device__ inline T real() const volatile{ return m_data[0]; }

  /*! Returns the imaginary part of this \p complex.
   */
  __host__ __device__ inline T imag() const volatile{ return m_data[1]; }

  /*! Returns the real part of this \p complex.
   */
  __host__ __device__ inline T real() const{ return m_data[0]; }

  /*! Returns the imaginary part of this \p complex.
   */
  __host__ __device__ inline T imag() const{ return m_data[1]; }



  /* --- Setter functions --- 
   * The volatile ones are there to help for example
   * with certain reductions optimizations
   */

  /*! Sets the real part of this \p complex.
   *
   *  \param re The new real part of this \p complex.
   */
  __host__ __device__ inline void real(T re)volatile{ m_data[0] = re; }

  /*! Sets the imaginary part of this \p complex.
   *
   *  \param im The new imaginary part of this \p complex.e
   */
  __host__ __device__ inline void imag(T im)volatile{ m_data[1] = im; }

  /*! Sets the real part of this \p complex.
   *
   *  \param re The new real part of this \p complex.
   */
  __host__ __device__ inline void real(T re){ m_data[0] = re; }

  /*! Sets the imaginary part of this \p complex.
   *
   *  \param im The new imaginary part of this \p complex.
   */
  __host__ __device__ inline void imag(T im){ m_data[1] = im; }



  /* --- Casting functions --- */

  /*! Casts this \p complex to a <tt>std::complex</tt> of the same type.
   */
  inline operator std::complex<T>() const { return std::complex<T>(real(),imag()); }

private:
  T m_data[2];
};


/* --- General Functions --- */

/*! Returns the magnitude (also known as absolute value) of a \p complex.
 *
 *  \param z The \p complex from which to calculate the absolute value.
 */
template<typename T> __host__ __device__ inline T abs(const complex<T>& z);

/*! Returns the phase angle (also known as argument) in radians of a \p complex.
 *
 *  \param z The \p complex from which to calculate the phase angle.
 */
template<typename T> __host__ __device__ inline T arg(const complex<T>& z);

/*! Returns the square of the magnitude of a \p complex.
 *
 *  \param z The \p complex from which to calculate the norm.
 */
template<typename T> __host__ __device__ inline T norm(const complex<T>& z);

/*! Returns the complex conjugate of a \p complex.
 *
 *  \param z The \p complex from which to calculate the complex conjugate.
 */
template<typename T> __host__ __device__ inline complex<T> conj(const complex<T>& z);

/*! Returns a \p complex with the specified magnitude and phase.
 *
 *  \param m The magnitude of the returned \p complex.
 *  \param theta The phase of the returned \p complex in radians.
 */
template<typename T> __host__ __device__ inline complex<T> polar(const T& m, const T& theta = 0);

/*! Returns the projection of a \p complex on the Riemann sphere.
 *  For all finite \p complex it returns the argument. For \p complexs 
 *  with a non finite part returns (INFINITY,+/-0) where the sign of 
 *  the zero matches the sign of the imaginary part of the argument.
 *
 *  \param z The \p complex argument.
 */
template<typename T> __host__ __device__ inline complex<T> proj(const T& z);



/* --- Binary Arithmetic operators --- */

/*! Multiplies two \p complex numbers.
 *
 *  \param lhs The first \p complex.
 *  \param rhs The second \p complex.
 */
template <typename T> __host__ __device__ inline complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs);

/*! Multiplies a \p complex number by a scalar.
 *
 *  \param lhs The \p complex.
 *  \param rhs The scalar.
 */
template <typename T> __host__ __device__ inline complex<T> operator*(const complex<T>& lhs, const T & rhs);

/*! Multiplies a scalr by a \p complex number.
 *
 *  \param lhs The scalar.
 *  \param rhs The \p complex.
 */
template <typename T> __host__ __device__ inline complex<T> operator*(const T& lhs, const complex<T>& rhs);

/*! Divides two \p complex numbers.
 *
 *  \param lhs The numerator (dividend).
 *  \param rhs The denomimator (divisor).
 */
template <typename T> __host__ __device__ inline complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs);

/*! Divides a \p complex number by a scalar.
 *
 *  \param lhs The complex numerator (dividend).
 *  \param rhs The scalar denomimator (divisor).
 */
template <typename T> __host__ __device__ inline complex<T> operator/(const complex<T>& lhs, const T & rhs);

/*! Divides a scalar by a \p complex number.
 *
 *  \param lhs The scalar numerator (dividend).
 *  \param rhs The complex denomimator (divisor).
 */
template <typename T> __host__ __device__ inline complex<T> operator/(const T& lhs, const complex<T> & rhs);

/*! Adds two \p complex numbers.
 *
 *  \param lhs The first \p complex.
 *  \param rhs The second \p complex.
 */
template <typename T> __host__ __device__ inline complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs);

/*! Adds a scalar to a \p complex number.
 *
 *  \param lhs The \p complex.
 *  \param rhs The scalar.
 */
template <typename T> __host__ __device__ inline complex<T> operator+(const complex<T>& lhs, const T & rhs);

/*! Adds a \p complex number to a scalar.
 *
 *  \param lhs The scalar.
 *  \param rhs The \p complex.
 */
template <typename T> __host__ __device__ inline complex<T> operator+(const T& lhs, const complex<T>& rhs);

/*! Subtracts two \p complex numbers.
 *
 *  \param lhs The first \p complex (minuend).
 *  \param rhs The second \p complex (subtrahend).
 */
template <typename T> __host__ __device__ inline complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs);

/*! Subtracts a scalar from a \p complex number.
 *
 *  \param lhs The \p complex (minuend).
 *  \param rhs The scalar (subtrahend).
 */
template <typename T> __host__ __device__ inline complex<T> operator-(const complex<T>& lhs, const T & rhs);

/*! Subtracts a \p complex number from a scalar.
 *
 *  \param lhs The scalar (minuend).
 *  \param rhs The \p complex (subtrahend).
 */
template <typename T> __host__ __device__ inline complex<T> operator-(const T& lhs, const complex<T>& rhs);



/* --- Unary Arithmetic operators --- */

/*! Unary plus, returns its \p complex argument.
 *
 *  \param rhs The \p complex argument.
 */
template <typename T> __host__ __device__ inline complex<T> operator+(const complex<T>& rhs);

/*! Unary minus, returns the additive inverse (negation) of its \p complex argument.
 *
 *  \param rhs The \p complex argument.
 */
template <typename T> __host__ __device__ inline complex<T> operator-(const complex<T>& rhs);



/* --- Exponential Functions --- */

/*! Returns the complex exponential of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> exp(const complex<T>& z);

/*! Returns the complex natural logarithm of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> log(const complex<T>& z);

/*! Returns the complex base 10 logarithm of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ inline complex<T> log10(const complex<T>& z);



/* --- Power Functions --- */

/*! Returns a \p complex number raised to another.
 *
 *  \param x The base.
 *  \param y The exponent.
 */
template <typename T> __host__ __device__ complex<T> pow(const complex<T>& x, const complex<T>& y);

/*! Returns a \p complex number raised to a scalar.
 *
 *  \param x The \p complex base.
 *  \param y The scalar exponent.
 */
template <typename T> __host__ __device__ complex<T> pow(const complex<T>& x, const T& y);

/*! Returns a scalar raised to a \p complex number.
 *
 *  \param x The scalar base.
 *  \param y The \p complex exponent.
 */
template <typename T> __host__ __device__ complex<T> pow(const T& x, const complex<T>& y);

#if !defined _MSC_VER
/*! Returns a \p complex number raised to another. The types of the two \p complex should be compatible
 * and the type of the returned \p complex is the promoted type of the two arguments.
 *
 *  \param x The base.
 *  \param y The exponent.
 */
template <typename T, typename U> __host__ __device__ complex<typename detail::promoted_numerical_type<T,U>::type > pow(const complex<T>& x, const complex<U>& y);

/*! Returns a \p complex number raised to a scalar. The type of the \p complex should be compatible with the scalar
 * and the type of the returned \p complex is the promoted type of the two arguments.
 *
 *  \param x The base.
 *  \param y The exponent.
 */
template <typename T, typename U> __host__ __device__ complex<typename detail::promoted_numerical_type<T,U>::type > pow(const complex<T>& x, const U& y);

/*! Returns a scalar raised to a \p complex number. The type of the \p complex should be compatible with the scalar
 * and the type of the returned \p complex is the promoted type of the two arguments.
 *
 *  \param x The base.
 *  \param y The exponent.
 */
template <typename T, typename U> __host__ __device__ complex<typename detail::promoted_numerical_type<T,U>::type > pow(const T& x,const complex<U>& y);

#endif // !defined _MSC_VER

/*! Returns the complex square root of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> sqrt(const complex<T>&z);



/* --- Trigonometric Functions --- */

/*! Returns the complex cosine of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> cos(const complex<T>&z);

/*! Returns the complex sine of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> sin(const complex<T>&z);

/*! Returns the complex tangent of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> tan(const complex<T>&z);



/* --- Hyperbolic Functions --- */

/*! Returns the complex hyperbolic cosine of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> cosh(const complex<T>& z);

/*! Returns the complex hyperbolic sine of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> sinh(const complex<T>&z);

/*! Returns the complex hyperbolic tangent of a \p complex number.
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> tanh(const complex<T>&z);



/* --- Inverse Trigonometric Functions --- */

/*! Returns the complex arc cosine of a \p complex number.
 *
 *  The range of the real part of the result is [0, Pi] and 
 *  the range of the imaginary part is [-inf, +inf]
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> acos(const complex<T>& z);

/*! Returns the complex arc sine of a \p complex number.
 *
 *  The range of the real part of the result is [-Pi/2, Pi/2] and 
 *  the range of the imaginary part is [-inf, +inf]
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> asin(const complex<T>& z);

/*! Returns the complex arc tangent of a \p complex number.
 *
 *  The range of the real part of the result is [-Pi/2, Pi/2] and 
 *  the range of the imaginary part is [-inf, +inf]
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> atan(const complex<T>& z);



/* --- Inverse Hyperbolic Functions --- */

/*! Returns the complex inverse hyperbolic cosine of a \p complex number.
 *
 *  The range of the real part of the result is [0, +inf] and 
 *  the range of the imaginary part is [-Pi, Pi]
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> acosh(const complex<T>& z);

/*! Returns the complex inverse hyperbolic sine of a \p complex number.
 *
 *  The range of the real part of the result is [-inf, +inf] and 
 *  the range of the imaginary part is [-Pi/2, Pi/2]
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> asinh(const complex<T>& z);

/*! Returns the complex inverse hyperbolic tangent of a \p complex number.
 *
 *  The range of the real part of the result is [-inf, +inf] and 
 *  the range of the imaginary part is [-Pi/2, Pi/2]
 *
 *  \param z The \p complex argument.
 */
template <typename T> __host__ __device__ complex<T> atanh(const complex<T>& z);



/* --- Stream Operators --- */

/*! Writes to an output stream a \p complex number in the form (real,imaginary).
 *
 *  \param os The output stream.
 *  \param z The \p complex number to output.
 */
template<typename ValueType,class charT, class traits>
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const complex<ValueType>& z);

/*! Reads a \p complex number from an input stream.
 *  The recognized formats are:
 * - real
 * - (real)
 * - (real, imaginary)
 *
 * The values read must be convertible to the \p complex's \c value_type 
 *
 *  \param is The input stream.
 *  \param z The \p complex number to set.
 */
template<typename ValueType, typename charT, class traits>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is, complex<ValueType>& z);



/* --- Equality Operators --- */

/*! Returns true if two \p complex numbers are equal and false otherwise.
 *
 *  \param lhs The first \p complex.
 *  \param rhs The second \p complex.
 */
template <typename T> __host__ __device__ inline bool operator==(const complex<T>& lhs, const complex<T>& rhs);

/*! Returns true if the imaginary part of the  \p complex number is zero and the real part is equal to the scalar. Returns false otherwise.
 *
 *  \param lhs The scalar.
 *  \param rhs The \p complex.
 */
template <typename T> __host__ __device__ inline bool operator==(const T & lhs, const complex<T>& rhs);

/*! Returns true if the imaginary part of the  \p complex number is zero and the real part is equal to the scalar. Returns false otherwise.
 *
 *  \param lhs The \p complex.
 *  \param rhs The scalar.
 */
template <typename T> __host__ __device__ inline bool operator==(const complex<T> & lhs, const T& rhs);

/*! Returns true if two \p complex numbers are different and false otherwise.
 *
 *  \param lhs The first \p complex.
 *  \param rhs The second \p complex.
 */
template <typename T> __host__ __device__ inline bool operator!=(const complex<T>& lhs, const complex<T>& rhs);

/*! Returns true if the imaginary part of the  \p complex number is not zero or the real part is different from the scalar. Returns false otherwise.
 *
 *  \param lhs The scalar.
 *  \param rhs The \p complex.
 */
template <typename T> __host__ __device__ inline bool operator!=(const T & lhs, const complex<T>& rhs);

/*! Returns true if the imaginary part of the \p complex number is not zero or the real part is different from the scalar. Returns false otherwise.
 *
 *  \param lhs The \p complex.
 *  \param rhs The scalar.
 */
template <typename T> __host__ __device__ inline bool operator!=(const complex<T> & lhs, const T& rhs);

} // end namespace thrust

#include <thrust/detail/complex/complex.inl>

/*! \} // complex_numbers
 */

/*! \} // numerics
 */