[Matrix-SIG] broadcast rules
Warren B. Focke
Warren B. Focke" <warren@pfiesteria.gsfc.nasa.gov
Fri, 20 Nov 1998 16:49:50 -0500 (EST)
[me: Are brodcast rules for arithmetic and assignment expected to be
different?]
On Thu, 19 Nov 1998, Janko Hauser wrote:
> So the answer to your question is ``Yes''
Ok.
> Broadcasting doesn't really exist for assignment. Only scalars can be
> broadcasted.
But it's not quite this restrictive. Further poking reveals that, while
length-1 dimensions are not broadcast on assingment (this differs from how
it is handled for arithmetic), missing dimensions on the left are (this is
the same way it is handled in arithmetic).
>>> big=ones((5,3,2))
>>> junk=big+ones((2,))
>>> junk=big+ones((3,2))
>>> junk=big+ones((5,3))
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: frames are not aligned
>>> big[...]=ones((2,))
>>> big[...]=ones((3,2))
>>> big[...]=ones((5,3))
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: matrices are not aligned for copy
Warren Focke