14 #ifndef BRIDGE_COMPLEX_INCLUDED
15 #define BRIDGE_COMPLEX_INCLUDED
29 #if defined USE_STD_COMPLEX
34 typedef std::complex<int> icomplex;
35 typedef std::complex<float> fcomplex;
36 typedef std::complex<double> dcomplex;
39 inline icomplex cmplx(
const int r,
const int i) {
return icomplex(r, i); }
40 inline fcomplex cmplx(
const float r,
const float i) {
return fcomplex(r, i); }
41 inline dcomplex cmplx(
const double r,
const double i) {
return dcomplex(r, i); }
49 inline int real(
const icomplex& z) {
return z.real(); }
50 inline int imag(
const icomplex& z) {
return z.imag(); }
52 inline float real(
const fcomplex& z) {
return z.real(); }
53 inline float imag(
const fcomplex& z) {
return z.imag(); }
55 inline double real(
const dcomplex& z) {
return z.real(); }
56 inline double imag(
const dcomplex& z) {
return z.imag(); }
62 #elif defined USE_C99_COMPLEX
68 icomplex() : m_r(0), m_i(0) {}
69 icomplex(
const int r,
const int i = 0) : m_r(r), m_i(i) {}
70 icomplex(
const icomplex& rhs) : m_r(rhs.m_r), m_i(rhs.m_i) {}
73 icomplex& operator=(
const icomplex& rhs)
80 icomplex& operator*=(
const icomplex& rhs)
85 m_r = re * rhs.m_r - im * rhs.m_i;
86 m_i = re * rhs.m_i + im * rhs.m_r;
90 friend icomplex
operator*(
const icomplex& lhs,
const icomplex& rhs)
92 return icomplex(lhs.m_r * rhs.m_r - lhs.m_i * rhs.m_i,
93 lhs.m_r * rhs.m_i + lhs.m_i * rhs.m_r);
96 friend int real(
const icomplex& z) {
return z.m_r; }
97 friend int imag(
const icomplex& z) {
return z.m_i; }
104 inline icomplex cmplx(
const int real,
const int imag)
106 return icomplex(real, imag);
110 typedef float _Complex fcomplex;
111 typedef double _Complex dcomplex;
114 inline float real(
const fcomplex& z) {
return crealf(z); }
115 inline float imag(
const fcomplex& z) {
return cimagf(z); }
116 inline float abs(
const fcomplex& z) {
return cabsf(z); }
117 inline fcomplex cmplx(
const float real,
const float imag)
119 return real + imag * _Complex_I;
123 inline double real(
const dcomplex& z) {
return creal(z); }
124 inline double imag(
const dcomplex& z) {
return cimag(z); }
125 inline double abs(
const dcomplex& z) {
return cabs(z); }
126 inline dcomplex cmplx(
const double real,
const double imag)
128 return real + imag * _Complex_I;
148 #endif // BRIDGE_COMPLEX_INCLUDED
Mat_SU_N operator*(const Mat_SU_N &m1, const Mat_SU_N &m2)