So the background to this "problem" is that I'm trying to optimize a large python project. I started timing the program and noticed that almost 50% of the run time is spent on a calculation similar to this one:
import numpy as np # Example A = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) X = np.random.multivariate_normal([0,0,0,0],np.eye(4),15000) # Create a lambda function to use row based F = lambda x: np.dot(A,x) # Now calculating the value answer = np.apply_along_axis(F, 1, X) print answer.shape
I've tried to find a way to make this faster, but keep running into a wall. Is this really the optimal of doing this?