Python 如何将矩阵列表按元素相乘?
考虑以下代码:Python 如何将矩阵列表按元素相乘?,python,numpy,matrix,Python,Numpy,Matrix,考虑以下代码: A=np.asmatrix([[1, 2],[3,4]]) B=[np.asmatrix([[2,0],[0,2]]), np.asmatrix([[10,0],[0,10]])] 我想做一个矩阵互应用程序,它将返回我: C=[A@B[0], A@B[1] ] 是否有一个内置的方法允许这样做?使用理解: c = [A@E for E in B] 这种方法速度快吗?因为我知道在python中我们必须避免使用循环(我是python初学者)
A=np.asmatrix([[1, 2],[3,4]])
B=[np.asmatrix([[2,0],[0,2]]), np.asmatrix([[10,0],[0,10]])]
我想做一个矩阵互应用程序,它将返回我:
C=[A@B[0], A@B[1] ]
是否有一个内置的方法允许这样做?使用理解:
c = [A@E for E in B]
这种方法速度快吗?因为我知道在python中我们必须避免使用循环(我是python初学者)