使用scipy/numpy在python中添加2个矩阵和乘以2矩阵

Hol*_*ger 8 python math numpy matrix scipy

我试图使用scipy和numpy来执行矩阵加法和乘法.

我有2个矩阵"a"和"b".我的目标是将"a"和"b"加在一起并将结果存储到矩阵"c"中

我还想将"a"和"b"相乘并存储到矩阵"d"中.

在Scipy/Numpy中有没有像这样的功能?

非常感谢.

sve*_*rre 12

矩阵乘法:

a = numpy.matrix(a)
b = numpy.matrix(b)
c = a+b
d = a*b
Run Code Online (Sandbox Code Playgroud)

数组乘法(map operator.mul):

a = numpy.array(a)
b = numpy.array(b)
c = a+b
d = a*b
Run Code Online (Sandbox Code Playgroud)