[Numpy-discussion] isn't it a bug? (matrix multiplication)
Thu Feb 7 13:10:16 CST 2008
Alan G Isaac wrote:
> On Thu, 07 Feb 2008, dmitrey apparently wrote:
>> a = array((1.0, 2.0))
>> e = array(15)
>> e *= a # ... yields error:
> You are trying to stuff in two values where
> you have only allocated space for 1.
Exactly. but to expound a bit more:
The ?= operators are in-place operators -- they attempt to modify the
left hand side in-place. The regular math operators create a new array,
which can be a different size than either of the two operands, thanks to
x *= y should be the same as x = x*y iff the size of x*y is the same
size as x.
array([ 1., 2.])
array([ 15., 30.])
One more note: you're doing element-wise array multiplication, not
matrix multiplication -- a distinction that does matter sometimes.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the Numpy-discussion