python - How to fix compiler error: cannot convert to a pointer type with Cython + numpy? -


i'm trying wrap c function use in python using cython , numpy.

when compile following error:

_fastlp.c: in function ‘__pyx_pf_6fastlp_fastlp_func’: _fastlp.c:1351:3: error: cannot convert pointer type    fastlp(((double *)pyarray_data(((pyarrayobject *)__pyx_v_obj))),     ((double *)pyarray_data(((pyarrayobject *)__pyx_v_mat))),     ((double *)pyarray_data(((pyarrayobject *)__pyx_v_rhs))), (&__pyx_v_m0),     (&__pyx_v_n0), ((double *)pyarray_data(__pyx_v_opt)),     (&__pyx_v_status), ((double *)__pyx_v_lam));       ^ 

the arrow ^ points (&__pyx_v_status).

my .pyx file is:

import numpy np cimport numpy np  np.import_array()  # cdefine signature of c function cdef extern "fastlp.h":     void fastlp(double *obj, double *mat, double *rhs, int *m0 , int *n0,                  double *opt, int *status, double *lam)  def fastlp_func(np.ndarray[double, ndim=1, mode="c"] obj not none,                 np.ndarray[double, ndim=2, mode="c"] mat not none,                 np.ndarray[double, ndim=1, mode="c"] rhs not none,                 double lam):         #define output     cdef np.ndarray opt = np.zeros((len(obj),), dtype = np.float64)     cdef int status = 0      #call external c function     cdef int m0 = mat.shape[0]     cdef int n0 = mat.shape[1]      fastlp(<double*> np.pyarray_data(obj),            <double*> np.pyarray_data(mat),            <double*> np.pyarray_data(rhs),            &m0,            &n0,            <double*> np.pyarray_data(opt),            &status,            <double*> lam)      return (opt,status) 

any appreciated! i've been working on long , think i'm close. thank you!

turns out needed use <double*> &lam in calling external function. trying cast variable pointer...when shouldn't have.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -