Cython: <double[:width,:height]> what is this ?

Hopefully, there are some Cython programmers on this forum.

My cython is a bit and rusty. I am modifying old cython code but I can't remember what <double ...> in the following line of code means exactly (and can't locate the information in the documentation)

 
cdef double[:,:] mv = <double[:self._W.width,:self._W.height]>self._W.getarr()


2. Originally, getarr() was returning a pointer to a C++ array. I would like to change my code and use a std::vector<double> as a data store instead. getarr() would then return a reference to the vector . Is it possible to create a memoryview on the basis of a std::vector? I was hoping that replacing getarr() with getarr().data() would do the trick but it doesn't work.
Last edited on
wild guess, that's casting
you are converting the pointer that gives you .getarr() into a matrix of .width x .height
edit: ¿isn't wxh backwards?


> but it doesn't work.
that's not an error message
Last edited on
Yes, that's correct. I finally remembered that I had found that syntax in the book W. Smith's book Cython: A Guide for Python Programmers.

The <double ... > specifies how the compiler should interpret the data that is pointed by the pointer that follows.

The problem in debugging is that the error was generated by GCC when it compiled the C++ code produced by the Cython compiler. This automatically generated code is hard to follow!
Topic archived. No new replies allowed.