[Numpy-discussion] How-to: Uniform vector scale

Robert Dailey rcdailey@gmail....
Wed Sep 5 14:05:15 CDT 2007


I have a scalar value S. I want to perform the following math on vectors A
and B (both of type array):

A + B * S

By order of operations, B * S should be done first. This is a vector
multiplied by a real number and should be valid. However, the interpreter
    "ValueError: shape mismatch: objects cannot be broadcast to a single

I am not sure how I am supposed to multiply a vector with a scalar value.
For example:

array([5,2]) * 2 = [10,4]

The above should happen. However, I get the error message instead. Any
ideas? Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070905/99955b96/attachment.html 

More information about the Numpy-discussion mailing list