Reputation: 1015
I am trying to use scipy and numpy to perform matrix addition and multiplication.
I have 2 matrix "a" and "b". my goal is to add "a" and "b" together and store the result into a matrix "c"
Also I want to multiply "a" and "b" and store into a matrix "d".
Are there any function perform like that in Scipy/Numpy?
Thanks a lot.
Upvotes: 9
Views: 21086
Reputation: 6919
Matrix multiplication:
a = numpy.matrix(a)
b = numpy.matrix(b)
c = a+b
d = a*b
Array multiplication (map operator.mul):
a = numpy.array(a)
b = numpy.array(b)
c = a+b
d = a*b
Upvotes: 14