Re: [Numpy-discussion] Resizing without allocating additional memory

2006-12-06 Thread David Huard
Thanks Travis, I guess we'll have to tweak the fortran subroutines. It would have been neat though. David Answer: Since g+=1 adds one to all N elements of g, the buffer a gets incremented N times. So a = array(i) g = ndarray(shape=(1,N), dtype=int, buffer=a, strides=(0,0)) g+=M returns i + M*N

Re: [Numpy-discussion] Resizing without allocating additional memory

2006-12-06 Thread Travis Oliphant
David Huard wrote: > Hi, > > I have fortran subroutines wrapped with f2py that take arrays as > arguments, and I often need to use resize(a, N) to pass an array of > copies of an element. The resize call , however, is becoming the speed > bottleneck, so my question is: > Is it possible to creat

[Numpy-discussion] Resizing without allocating additional memory

2006-12-06 Thread David Huard
Hi, I have fortran subroutines wrapped with f2py that take arrays as arguments, and I often need to use resize(a, N) to pass an array of copies of an element. The resize call , however, is becoming the speed bottleneck, so my question is: Is it possible to create an (1xN) array from a scalar with