Python numpy:向量x矩阵x向量乘法

Python numpy:向量x矩阵x向量乘法,python,numpy,linear-algebra,Python,Numpy,Linear Algebra,如何将多个向量和矩阵以numpy形式相乘,如下例所示: # 1. vector a = np.array([1, 2]) # matrix b = np.array([[4, 0],[0, 5]]) # 2. vector c = a.T 我想将axbxc相乘,并找到结果24。使用numpy.matmul(a,b),如下所示: import numpy as np # 1. vector a = np.array([1, 2]) # matrix b = np.array([[4, 0],[0

如何将多个向量和矩阵以numpy形式相乘,如下例所示:

# 1. vector
a = np.array([1, 2])
# matrix
b = np.array([[4, 0],[0, 5]])
# 2. vector
c = a.T
我想将axbxc相乘,并找到结果24。

使用numpy.matmul(a,b),如下所示:

import numpy as np
# 1. vector
a = np.array([1, 2])
# matrix
b = np.array([[4, 0],[0, 5]])
# 2. vector
c = a.T
# np.matmul gets 2 inputs which are matrix (1x2, 2x3 etc.) and returns result.
result = np.matmul(np.matmul(a,b), c)

print(result)
# 24

嗨,欢迎来到StackOverflow。请参考提问指南。请用更多的细节回复问题,包括您迄今为止尝试过的内容。