Suppose I have an array of n point clouds (each containing m points, of dimension d), and then a list of n matrices (each one dxd), representing linear transformations. Is there a vectorized way to multiply each matrix with its corresponding point cloud? (I.e., multiply the first matrix with each point in the first point cloud, the second matrix with each point in the second point cloud, etc.)
For example, here's an example computation I'd like to be able to do, using a for loop:
import numpy as np
points = np.random.rand(3,5,2)
mats = np.array([np.eye(2), -np.eye(2), 2*np.eye(2)])
out = np.zeros((3,5,2))
for i in range(points.shape[0]):
out[i,:] = np.matmul(points[i,:], mats[i])
In this case, every point in the first cloud should be unchanged, every point in the second cloud should have its sign flipped, and every point in the third cloud should have each component doubled.
I appreciate any help you can provide -- I've been trying to get this working for a while with no success!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…