Vector Optimized Library of Kernels  2.5.1
Architecture-tuned implementations of math kernels
volk_complex.h
Go to the documentation of this file.
1 #ifndef INCLUDED_VOLK_COMPLEX_H
2 #define INCLUDED_VOLK_COMPLEX_H
3 
20 #ifdef __cplusplus
21 
22 #include <stdint.h>
23 #include <complex>
24 
25 typedef std::complex<int8_t> lv_8sc_t;
26 typedef std::complex<int16_t> lv_16sc_t;
27 typedef std::complex<int32_t> lv_32sc_t;
28 typedef std::complex<int64_t> lv_64sc_t;
29 typedef std::complex<float> lv_32fc_t;
30 typedef std::complex<double> lv_64fc_t;
31 
32 template <typename T>
33 inline std::complex<T> lv_cmake(const T& r, const T& i)
34 {
35  return std::complex<T>(r, i);
36 }
37 
38 template <typename T>
39 inline typename T::value_type lv_creal(const T& x)
40 {
41  return x.real();
42 }
43 
44 template <typename T>
45 inline typename T::value_type lv_cimag(const T& x)
46 {
47  return x.imag();
48 }
49 
50 template <typename T>
51 inline T lv_conj(const T& x)
52 {
53  return std::conj(x);
54 }
55 
56 #else /* __cplusplus */
57 
58 #include <complex.h>
59 #include <tgmath.h>
60 
61 typedef char complex lv_8sc_t;
62 typedef short complex lv_16sc_t;
63 typedef long complex lv_32sc_t;
64 typedef long long complex lv_64sc_t;
65 typedef float complex lv_32fc_t;
66 typedef double complex lv_64fc_t;
67 
68 #define lv_cmake(r, i) ((r) + _Complex_I * (i))
69 
70 // When GNUC is available, use the complex extensions.
71 // The extensions always return the correct value type.
72 // http://gcc.gnu.org/onlinedocs/gcc/Complex.html
73 #ifdef __GNUC__
74 
75 #define lv_creal(x) (__real__(x))
76 
77 #define lv_cimag(x) (__imag__(x))
78 
79 #define lv_conj(x) (~(x))
80 
81 // When not available, use the c99 complex function family,
82 // which always returns double regardless of the input type,
83 // unless we have C99 and thus tgmath.h overriding functions
84 // with type-generic versions.
85 #else /* __GNUC__ */
86 
87 #define lv_creal(x) (creal(x))
88 
89 #define lv_cimag(x) (cimag(x))
90 
91 #define lv_conj(x) (conj(x))
92 
93 #endif /* __GNUC__ */
94 
95 #endif /* __cplusplus */
96 
97 #endif /* INCLUDE_VOLK_COMPLEX_H */
#define lv_cimag(x)
Definition: volk_complex.h:89
#define lv_conj(x)
Definition: volk_complex.h:91
#define lv_cmake(r, i)
Definition: volk_complex.h:68
char complex lv_8sc_t
Provide typedefs and operators for all complex types in C and C++.
Definition: volk_complex.h:61
long complex lv_32sc_t
Definition: volk_complex.h:63
double complex lv_64fc_t
Definition: volk_complex.h:66
#define lv_creal(x)
Definition: volk_complex.h:87
float complex lv_32fc_t
Definition: volk_complex.h:65
short complex lv_16sc_t
Definition: volk_complex.h:62
long long complex lv_64sc_t
Definition: volk_complex.h:64
for i
Definition: volk_config_fixed.tmpl.h:25