from __future__ import division
import numpy
cimport numpy
cimport cython
def calc_shg(numpy.ndarray[numpy.complex128_t, ndim = 1] par,
numpy.ndarray[numpy.complex128_t, ndim = 1] spectrum,
numpy.ndarray[numpy.complex128_t, ndim = 1] phase,
numpy.ndarray[numpy.complex128_t, ndim = 1] filter, float
best_fit):
cdef int pix
cdef int i
cdef numpy.ndarray[numpy.complex128_t, ndim = 1] shaped_pulse
shaped_pulse = numpy.zeros(4096)
par = numpy.exp(-1j * par * 0.002 * numpy.pi)
for pix in xrange(128):
for i in xrange(25 - 1):
filter[2048 - 25 * 64 + pix * 25 + i] = par
[pix]
for i in xrange(4096):
shaped_pulse[i] = numpy.fft.ifft(spectrum[i] * (phase[i] * filter
[i]))
return - sum(numpy.real(shaped_pulse) ** 4) / best_fit
Error:
Sim_Cython.c: In function `__pyx_pf_10Sim_Cython_calc_shg':
Sim_Cython.c:1187: error: incompatible type for argument 1 of
`__pyx_t_double_complex_mul'
Sim_Cython.c:1187: error: incompatible type for argument 2 of
`__pyx_t_double_complex_mul'
Sim_Cython.c:1187: error: incompatible type for argument 1 of
`__pyx_t_double_complex_mul'
Sim_Cython.c:1187: error: incompatible type for argument 1 of
`__pyx_t_double_complex_mul'
Sim_Cython.c:1187: error: incompatible type for argument 2 of
`__pyx_t_double_complex_mul'
Sim_Cython.c:1187: error: incompatible type for argument 1 of
`__pyx_t_double_complex_mul'
Sim_Cython.c:1198: error: incompatible types in assignment
Dag Sverre
Compilier: gcc 4.4.0, cython 0.12.
On 2 Feb., 19:58, Dag Sverre Seljebotn <da...@student.matnat.uio.no>
wrote:
If not, it might be some platform-dependant issues with C complex numbers...
Dag Sverre
Sim_Cython.c: At top level:
C:/Python26/lib/site-packages/numpy/core/include/numpy/
__multiarray_api.h:969: warning: '_import_array' defined but not used
Sim_Cython.c:781: warning: '__pyx_k_3' defined but not used
Sim_Cython.c:782: warning: '__pyx_k_4' defined but not used
Sim_Cython.c:802: warning: '__pyx_k_24' defined but not used
Sim_Cython.c:808: warning: '__pyx_k_26' defined but not used
Sim_Cython.c:809: warning: '__pyx_k_27' defined but not used
error: command 'gcc' failed with exit status 1
But these are only warings, i think.
Maybe my build file is wrong? But i ll try to 0.12.1 today.
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("Sim_Cython", ["Sim_Cython.pyx"])],
include_dirs = ['.', np.get_include()]
)
On 3 Feb., 09:20, Dag Sverre Seljebotn <da...@student.matnat.uio.no>