[Numpy-discussion] Broadcasting question
Olivier Grisel
olivier.grisel at ensta.org
Thu Dec 4 11:53:36 EST 2008
2008/12/4 Stéfan van der Walt <stefan at sun.ac.za>:
> Hi Olivier
>
> 2008/12/4 Olivier Grisel <olivier.grisel at ensta.org>:
>> To avoid the python level loop I then tried to use broadcasting as follows:
>>
>>>>> c = sum((a[:,newaxis,:] - b) ** 2, axis=2)
>>
>> But this build a useless and huge (d1, d2, d3) temporary array that
>> does not fit in memory for large values of d1, d2 and d3...
>
> Does numpy.lib.broadcast_arrays do what you need?
That looks exactly what I am looking for. Apparently this is new in
1.2 since I cannot find it in the 1.1 version of my system.
Thanks,
--
Olivier
More information about the NumPy-Discussion
mailing list