[Numpy-discussion] question about in-place operations

Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Tue May 22 10:32:07 EDT 2012


On 05/22/2012 04:25 PM, Massimo DiPierro wrote:
> hello everybody,
>
> first of all thanks to the developed for bumpy which is very useful. I am building a software that uses numpy+pyopencl for lattice qcd computations. One problem that I am facing is that I need to perform most operations on arrays in place and I must avoid creating temporary arrays (because my arrays are many gigabyte large).
>
> One typical operation is this
>
> a[i] += const * b[i]
>
> What is the efficient way to do is when a and b are arbitrary arrays?  const is usually a complex number.
> a and b have the same shape but are not necessarily uni-dimensional.

I don't think NumPy support this; if you can't modify b[i] in-place, I 
think your only option will be one of numexpr/Theano/Cython.

Dag



More information about the NumPy-Discussion mailing list