Hello all Travis Oliphant wrote: > The ctypes-conversion object has attributes which return c_types aware > objects so that the information can be passed directly to c-code (as an > integer, the number of dimensions can already be passed using c-types). > > The information available and it's corresponding c_type is > > data - c_void_p > shape, strides - c_int * nd or c_long * nd or c_longlong * nd > depending on platform
Stefan and I did some more experiments and it seems like .ctypes.strides isn't doing the right thing for subarrays. For example: In [52]: x = N.rand(3,4) In [57]: [x.ctypes.strides[i] for i in range(x.ndim)] Out[57]: [32, 8] This looks fine. But for this subarray: In [56]: [x[1:3,1:4].ctypes.strides[i] for i in range(x.ndim)] Out[56]: [32, 8] In this case, I think one wants strides[0] (the row stride) to return 40. .ctypes.data already seems to do the right thing: In [60]: x.ctypes.data Out[60]: c_void_p(31685288) In [61]: x[1:3,1:4].ctypes.data Out[61]: c_void_p(31685328) In [62]: 31685288-31685328 Out[62]: 40 What would be a good way of dealing with discontiguous arrays? It seems like one might want to disable their .ctypes attribute. Regards, Albert Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/numpy-discussion
