Thanks, it is very useful.
On Wed, Mar 9, 2011 at 7:41 PM, Benjamin Root wrote:
> This is a very good webpage that helped me when I was transitioning from
> matlab to numpy. I hope it is helpful for you as well.
>
> http://www.scipy.org/NumPy_for_Matlab_Users
>
> Ben Root
>
>
__
This is a very good webpage that helped me when I was transitioning from
matlab to numpy. I hope it is helpful for you as well.
http://www.scipy.org/NumPy_for_Matlab_Users
Ben Root
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mai
-- Forwarded message --
From: shu wei
Date: Wed, Mar 9, 2011 at 6:34 PM
Subject: Re: [Numpy-discussion] How to sum weighted matrices
To: Nicolas SCHEFFER
Thanks very much.
I just copied the code your guys gave me. Both of them work great
I used to program in Matlab. not
Or just with a dot:
===
In [17]: np.tensordot(weights, matrices, (0,0))
Out[17]:
array([[ 5., 5., 5.],
[ 5., 5., 5.]])
In [18]: np.dot(matrices.T,weights).T
Out[18]:
array([[ 5., 5., 5.],
[ 5., 5., 5.]])
==
make matrices.T C_CONTIGUOUS for maximum speed.
-n
On Mon, Mar
Thanks very much. It works.
On Mon, Mar 7, 2011 at 11:53 AM, wrote:
> for your problem, you can do:
>
>
>
> import numpy as np
>
> weights = np.array([1,2])
>
> matrix1 = np.ones((2,3))
> matrix2 = 2*np.ones((2,3))
>
> matrices = np.array([matrix1,matrix2])
>
> weigh
for your problem, you can do:
import numpy as np
weights = np.array([1,2])
matrix1 = np.ones((2,3))
matrix2 = 2*np.ones((2,3))
matrices = np.array([matrix1,matrix2])
weighted_sum = np.tensordot(weights, matrices, (0,0))
--
On Mon, Mar 07
Hello all,
I am new to python and numpy.
My question is how to sum up N weighted matrices.
For example w=[1,2] (N=2 case)
m1=[1 2 3,
3 4 5]
m2=[3 4 5,
4 5 6]
I want to get a matrix Y=w[1]*m1+w[2]*m2 by using a loop.
My original problem is like this
X=[1 2 3,
3 4 5,
4 5 6]