I tried this at jupyter notebook
%load_ext Cython
I was able to install cython successfully but I couldn't use cimport
%%cython
from libc.math cimport sqrt
import numpy as np
def filt_conv3(double complex[:,:] filterInput, Py_ssize_t sample_per_symbol, double[:] h, int flag, Py_ssize_t num_of_taps):
cdef Py_ssize_t input_batch_size = filterInput.shape[0]
cdef Py_ssize_t input_length = filterInput.shape[1]
cdef Py_ssize_t num_of_output = num_of_taps + (input_length-1) * sample_per_symbol
cdef double complex[:,:] output = np.zeros((input_batch_size, num_of_output), dtype=np.complex)
cdef double complex[:,:] FiltSig = np.zeros((input_batch_size, num_of_output), dtype=np.complex)
But it returned me the following error:
Cell In[12], line 4
from libc.math cimport sqrt
^
SyntaxError: invalid syntax
What is the cause of this syntax error? What should I do?
I replaced cimport with import
%%cython
from libc.math import sqrt
import numpy as np
I got another error
def filt_conv3(double complex[:,:] filterInput, Py_ssize_t sample_per_symbol, double[:] h, int flag, Py_ssize_t num_of_taps):
^
SyntaxError: invalid syntax`your text`
And also this code got error
import numpy as np
cimport cython
from libc.math cimport sqrt
cimport cython
^
SyntaxError: invalid syntax
Well, I ran your original code in jupyter and got no error. But I got the same error if I put a annotation line
#test
befere%%cython
line. You can try to make sure the%%cython
line is at the very top of your code block.