Newbie question about numpy
Paul Johnston
paul.johnston at manchester.ac.uk
Thu Aug 24 11:38:45 EDT 2006
Hi I'm new to python and have just been taking a look at what it has
to offer.
I noted the lack of matrices so installed numpy
I know the documentation is chargable so wanted a quick play to see if
I should buy it
However
_________________________________________________________
from numpy import *
a = array([[1,2,3],[4,5,6],[1,2,3]])
b = array([[1,3,6],[2,5,1],[1,1,1]])
print 'a = \n',a,"\n"
print 'b = \n',b,"\n"
print 'a has shape ', a.shape
print 'b has shape ', b.shape, "\n"
print "a * b is \n", a * b
_________________________________________________________
Gives me
_________________________________________________________
a =
[[1 2 3]
[4 5 6]
[1 2 3]]
b =
[[1 3 6]
[2 5 1]
[1 1 1]]
a has shape (3, 3)
b has shape (3, 3)
a * b is
[[ 1 6 18]
[ 8 25 6]
[ 1 2 3]]
_________________________________________________________
I know its a long time since my degree but that's not matrix
multiplication is it ?
TIA Paul
More information about the Python-list
mailing list