[Numpy-discussion] Broadcasting question

Stéfan van der Walt stefan@sun.ac...
Thu Dec 4 09:53:01 CST 2008


Hi Olivier

2008/12/4 Olivier Grisel <olivier.grisel@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?

Regards
Stéfan


More information about the Numpy-discussion mailing list