mirror of
https://github.com/triqs/dft_tools
synced 2024-11-01 11:43:47 +01:00
f2c7d449cc
for earlier commits, see TRIQS0.x repository.
22 lines
504 B
Cython
22 lines
504 B
Cython
cdef extern from "<complex>" namespace "std":
|
|
cdef cppclass dcomplex "std::complex<double>":
|
|
dcomplex()
|
|
dcomplex(dcomplex &)
|
|
dcomplex(double,double)
|
|
double real()
|
|
double imag()
|
|
|
|
# Python -> C
|
|
cdef inline dcomplex as_dcomplex (a) :
|
|
x = complex(a)
|
|
return dcomplex(a.real, a.imag)
|
|
|
|
# C -> Python
|
|
cdef inline make_dcomplex (dcomplex z) :
|
|
return complex(z.real(), z.imag())
|
|
|
|
# Python -> C
|
|
cdef inline float as_float (a) :
|
|
return float (a)
|
|
|