[Numpy-discussion] How's our broadcasting?

Olivier Delalleau shish at keba.be
Wed Dec 28 14:53:46 EST 2011


2011/12/28 Jordi Gutiérrez Hermoso <jordigh at octave.org>

> On 28 December 2011 13:41, Ralf Gommers <ralf.gommers at googlemail.com>
> wrote:
> >
> >
> > 2011/12/28 Jordi Gutiérrez Hermoso <jordigh at octave.org>
> >>
> >> Just FYI, the next stable release of Octave (3.6) will have
> >> broadcasting. I used Numpy as an inspiration.
> >>
> >> Here is the WIP manual for it:
> >>
> >>
> >>
> http://jordi.platinum.linux.pl/octave.html/Broadcasting.html#Broadcasting
> >
> > Is this a departure of maintaining full compatibility with Matlab?
>
> No, Matlab code will still work in Octave, except in very rare cases,
> but it's a matter of flipping a switch to make those weird cases work
> as well.
>
> Octave isn't a Matlab clone. The goal is to be source compatible to
> Matlab: code that runs in Matlab should run in Octave, but we don't
> try to limit ourselves to whatever Matlab does, nor do we copy every
> bug unless there's a very good reason to copy its bugs.
>
> I think I may be missing a few broadcasting behaviours regarding
> assignment. Is something like that possible, to broadcast a vector
> across a matrix during assignment?
>
> - Jordi G. H.
>

Numpy does it:

In [12]: x = numpy.zeros((3, 3))
In [15]: x[:] = numpy.arange(3)
In [16]: x
Out[16]:
array([[ 0.,  1.,  2.],
       [ 0.,  1.,  2.],
       [ 0.,  1.,  2.]])

-=- Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111228/5d07d03f/attachment.html>


More information about the NumPy-Discussion mailing list