Newbie question

Joe Hays joey_hays at hotmail.com
Thu Nov 6 16:14:08 EST 2008


I'm a newbie to python. Can anyone tell me why the following little program complains about incorrect dimensions?

<snip>
import pylab
from pylab import *

n = 10; m = 2*n;
A = randn(m,n);
b = A*rand(n,1) + 2*rand(m,1);
</snip>

The actual error I receive is,

<snip>
b = A*rand(n,1) + 2*rand(m,1);
ValueError: shape mismatch: objects cannot be broadcast to a single shape
</snip>

This is supposed to be doing a matrix multply of an (m,n)(n,1). This results in an (m,1). This should then be able to be added to the 2*rand(m,1), but, its not for some reason.

Ideas?

Joe


_________________________________________________________________
Windows Live Hotmail now works up to 70% faster.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_faster_112008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081106/2b031530/attachment.html>


More information about the Python-list mailing list