[SciPy-user] Mathematica Element-wise Multiplication

Stefan van der Walt stefan@sun.ac...
Sat Dec 15 05:31:42 CST 2007

Hi Tom

On Fri, Dec 14, 2007 at 09:26:59PM -0800, Tom Johnson wrote:
> While playing with Mathematica, I must say that I was surprised to
> find that it handled element-wise multiplication differently from
> scipy.
> In scipy,
> >>> A = array([[1,2],[3,4]])
> >>> B = array([2,3])
> >>> A * B
> array([[2,6],[6,12]])
> which essentially multiplies each COLUMN of A with each COLUMN of B.

Numpy does what we call broadcasting.  You can read more about it at


If you'd like to have the Mathematica behaviour, you can always use
the transpose property (i.e. x.T).


More information about the SciPy-user mailing list