1

According to https://stackoverflow.com/a/50095314/2363712, one may initialize a Cython cdef C-array using the [:] notation:

cdef double cpc_x [16]                                                                                                                                                                              
cpc_x[:] = 0.0   

However, when I compile the code above, I get the error:

sh$ cython3 --version
Cython version 0.26.1

sh$ cython3 -a a.pyx

Error compiling Cython file:
------------------------------------------------------------
...
cdef double cpc_x [16]
cpc_x[:] = 0.0
          ^
------------------------------------------------------------

a.pyx:2:11: Cannot assign type 'double' to 'double [16]'

What did I do wrong?

Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
  • 1
    Cython 0.26.1 was released in 2017. New features may have been added since then... – DavidW Apr 10 '23 at 18:09
  • :/ I should have guessed it was something like that. Unfortunately, I'm stuck with what's available in Ubuntu Bionic. – Sylvain Leroux Apr 10 '23 at 18:30
  • 1
    Pip should be available I'd think. You can install things into the user directory with that so you don't even need root access – DavidW Apr 10 '23 at 18:48

0 Answers0