I'm trying to use the functionality of numpy's cumprod, but for matrices. Having a matrix filled with homogeneous transformations (here random for simplicity) I want to accumulate the transformations using numpy's matrix multiplication.
n = 1000
data = np.random([n, 4,4])
dataAcc = cumProd(data, np.matmul)
dataAcc should contain the following:
dataAcc[0,:,:] = data[0,:,:]
dataAcc[1,:,:] = data[0,:,:] @ data[1,:,:] = dataAcc[0,:,:] @ data[1,:,:]
dataAcc[2,:,:] = dataAcc[1,:,:] @ data[2,:,:]
...
Is there a way to do this using fast numpy functions or some equivalent? I do not want to use loops...
Cheers