[SciPy-User] matrix multiplication
Josh Lawrence
josh.k.lawrence@gmail....
Fri Jan 20 14:07:38 CST 2012
You need to specify the first argument of zeros as a tuple:
A = matrix(zeros((3,1)))
That will result in a 3x1 matrix. So
B = A * A.T
will be a 3x3 matrix (3x1 * 1x3).
If you are looking to get a scalar back, you want
A = matrix(zeros((1,3)))
B = A *A.T
When you are not working with matrices, use np.dot(A,A.T).
Cheers,
--Josh
On Jan 20, 2012, at 3:03 PM, Chris Lirakis wrote:
> I have tried the following and they all yield the same result.
>
> A = zeros(3,1)
> B = A * A.T
> B = [[ 0 0 0]
> [0 0 0]
> [0 0 0]]
>
> A = matrix(zeros(3,1)
> B = A * A.T
> B = [[ 0 0 0]
> [0 0 0]
> [0 0 0]]
>
> I would have thought that the result should have been [[0]]
> if I do the following:
> A = matrix([[0 0 0]]) Then A * A.T yields [[0]]
>
> Can someone tell me why and how I might fix this?
> Chris
>
> --
> Chris Lirakis
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120120/3d4b4801/attachment.html
More information about the SciPy-User
mailing list