I have a specific mxn matrix and a vector of nx1. The m-by-n matrix is multiplied by the first element of the vector, then the m-by-n matrix is multiplied by the second element of the vector. It runs continuously and finally the result is an nxmxn 3D matrix.
Below is the implementation result using the for statement.
However, I would like to secure the operation speed by implementing it using numpy's operation function without using the for statement. Anyone who knows please reply.
P_mat = []
a = np.ones(9).reshape(3,3)
b = np.ones(6390)
for i in range(6390):
P_mat.append(a*b[i])
c = np.array(P_mat)
print("a = ", a.shape)
print("b = ", b.shape)
print("c = ", c.shape)
Below is the result.
a = (3, 3)
b = (6390,)
c = (6390, 3, 3)