Hold_My_Anger
Hold_My_Anger

Reputation: 1015

Adding 2 matrix and Multiplying 2 matrix in python by using scipy/numpy

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

Answers (1)

sverre
sverre

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

Related Questions