[Numpy-discussion] Broadcasting rules (Ticket 76).

Sasha ndarray at mac.com
Thu Apr 27 12:29:03 CDT 2006


On 4/27/06, Travis Oliphant <oliphant at ee.byu.edu> wrote:
> [...]
> > I'm still confused as to what behavior Sasha wants that doesn't exist.
>
>
> I'm not exactly sure.   But, one of the things I think he has suggested
> (please tell me if my understanding is wrong) is to allow a 2x3 array to
> be "broadcast" to a (2n)x(3m) array by repeated copying as needed.

Yes, this is the only new feature that I've suggested. I was also
hoping that the same code that allows shape=(3,) being broadcast to
shape (2,3) can be reused to broadcast (3,) to (6,).  The idea is that
since in terms of memory operations broadcasting  and repetition is
the same, the code can be reused.

The idea is that since repetition can be achieved using broadcasting:

>>> x = zeros(3)
>>> x.reshape((2,3)) += arange(3)
>>> x
array([0, 1, 2, 0, 1, 2])

if we allow x += arange(3), it can use the same code as broadcasting internally.




More information about the Numpy-discussion mailing list