14 #ifndef BRIDGE_COMPLEX_INCLUDED
15 #define BRIDGE_COMPLEX_INCLUDED
29 #if defined USE_STD_COMPLEX
33 typedef std::complex<int> icomplex;
34 typedef std::complex<float> fcomplex;
35 typedef std::complex<double> dcomplex;
38 inline icomplex cmplx(
const int r,
const int i) {
return icomplex(r, i); }
39 inline fcomplex cmplx(
const float r,
const float i) {
return fcomplex(r, i); }
40 inline dcomplex cmplx(
const double r,
const double i) {
return dcomplex(r, i); }
48 inline int real(
const icomplex& z) {
return z.real(); }
49 inline int imag(
const icomplex& z) {
return z.imag(); }
51 inline float real(
const fcomplex& z) {
return z.real(); }
52 inline float imag(
const fcomplex& z) {
return z.imag(); }
54 inline double real(
const dcomplex& z) {
return z.real(); }
55 inline double imag(
const dcomplex& z) {
return z.imag(); }
61 #elif defined USE_C99_COMPLEX
67 icomplex() : m_r(0), m_i(0) {}
68 icomplex(
const int r,
const int i = 0) : m_r(r), m_i(i) {}
69 icomplex(
const icomplex& rhs) : m_r(rhs.m_r), m_i(rhs.m_i) {}
72 icomplex& operator=(
const icomplex& rhs)
79 icomplex& operator*=(
const icomplex& rhs)
84 m_r = re * rhs.m_r - im * rhs.m_i;
85 m_i = re * rhs.m_i + im * rhs.m_r;
89 friend icomplex
operator*(
const icomplex& lhs,
const icomplex& rhs)
91 return icomplex(lhs.m_r * rhs.m_r - lhs.m_i * rhs.m_i,
92 lhs.m_r * rhs.m_i + lhs.m_i * rhs.m_r);
95 friend int real(
const icomplex& z) {
return z.m_r; }
96 friend int imag(
const icomplex& z) {
return z.m_i; }
103 inline icomplex cmplx(
const int real,
const int imag)
105 return icomplex(real, imag);
109 typedef float _Complex fcomplex;
110 typedef double _Complex dcomplex;
113 inline float real(
const fcomplex& z) {
return crealf(z); }
114 inline float imag(
const fcomplex& z) {
return cimagf(z); }
115 inline float abs(
const fcomplex& z) {
return cabsf(z); }
116 inline fcomplex cmplx(
const float real,
const float imag)
118 return real + imag * _Complex_I;
122 inline double real(
const dcomplex& z) {
return creal(z); }
123 inline double imag(
const dcomplex& z) {
return cimag(z); }
124 inline double abs(
const dcomplex& z) {
return cabs(z); }
125 inline dcomplex cmplx(
const double real,
const double imag)
127 return real + imag * _Complex_I;
147 #endif // BRIDGE_COMPLEX_INCLUDED
Mat_SU_N operator*(const Mat_SU_N &m1, const Mat_SU_N &m2)