[SciPy-user] weave.inline : resize an array in c++

Samuel GARCIA sgarcia at olfac.univ-lyon1.fr
Tue Apr 18 02:16:07 CDT 2006

No I can't it resize from python because it is to slow.
There are a lot of iteration and for some of them I add a new value to a
My code was only an example, of course.
Is it easier to add one element to a 1D array than a ND ?
I am porting a old code from matlab and I was able to to do that in mex
file with mxRealloc.



Prabhu Ramachandran a écrit :

>>>>>>"Samuel" == Samuel GARCIA <sgarcia at olfac.univ-lyon1.fr> writes:
>    Samuel> Hi, how to resize a array in the c++ code with
>    Samuel> weave.inline()
>    Samuel> c = ones((3,6))
>    Samuel> err = weave.inline(code, ['c'], type_converters=converters.blitz) 
>    Samuel> print c.shape #I want (4,7) !!!
>I am not sure why you'd want to do that.  Can't you resize it from
>Python?  In any case, if you really must do it, take a look at the c++
>code generated by weave and look at it.  You'll see that c_array is a
>PyArrayObject that you can use if you want it.  However, I am not sure
>what will happen if you do resize the array and are using blitz.  I
>suspect something bad may happen.  Resizing the array might also
>relocate the entire block of memory for the array so accessing the
>older pointer will likely be disastrous.  So, you should be careful
>doing this.
>SciPy-user mailing list
>SciPy-user at scipy.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scipy.net/pipermail/scipy-user/attachments/20060418/79a55159/attachment.htm

More information about the SciPy-user mailing list