GNU Radio 3.4.0 C++ API
volk_complex.h
Go to the documentation of this file.
00001 #ifndef INCLUDE_VOLK_COMPLEX_H
00002 #define INCLUDE_VOLK_COMPLEX_H
00003 
00004 /*!
00005   \brief This header file is to prevent issues with having <complex> and <complex.h> variables in the same code as the gcc compiler does not allow that
00006 */
00007 #ifdef __cplusplus
00008 
00009 #include <complex>
00010 #include <stdint.h>
00011 
00012 typedef std::complex<int8_t>  lv_8sc_t;
00013 typedef std::complex<int16_t> lv_16sc_t;
00014 typedef std::complex<int32_t> lv_32sc_t;
00015 typedef std::complex<float>   lv_32fc_t;
00016 typedef std::complex<double>  lv_64fc_t;
00017 
00018 static inline float lv_creal(const lv_32fc_t x){
00019   return x.real();
00020 }
00021 
00022 static inline float lv_cimag(const lv_32fc_t x){
00023   return x.imag();
00024 }
00025 
00026 static inline lv_32fc_t lv_conj(const lv_32fc_t x){
00027   return std::conj(x);
00028 }
00029 
00030 static inline lv_32fc_t lv_cpow(const lv_32fc_t x, const lv_32fc_t y){
00031   return std::pow(x, y);
00032 }
00033 
00034 static inline lv_32fc_t lv_32fc_init(const float x, const float y){
00035   return std::complex<float>(x,y);
00036 }
00037 
00038 #else
00039 
00040 #include <complex.h>
00041 
00042 typedef char complex         lv_8sc_t;
00043 typedef short complex        lv_16sc_t;
00044 typedef int complex          lv_32sc_t;
00045 typedef float complex        lv_32fc_t;
00046 typedef double complex       lv_64fc_t;
00047 
00048 static inline float lv_creal(const lv_32fc_t x){
00049   return creal(x);
00050 }
00051 
00052 static inline float lv_cimag(const lv_32fc_t x){
00053   return cimag(x);
00054 }
00055 
00056 static inline lv_32fc_t lv_conj(const lv_32fc_t x){
00057   return conj(x);
00058 }
00059 
00060 static inline lv_32fc_t lv_cpow(const lv_32fc_t x, const lv_32fc_t y){
00061   return cpow(x, y);
00062 }
00063 
00064 static inline lv_32fc_t lv_32fc_init(const float x, const float y){
00065   return x + I*y;
00066 }
00067 
00068 #endif
00069 
00070 
00071 #endif /* INCLUDE_VOLK_COMPLEX_H */