Suppose I have a numpy array of matricies
X = np.array([[[1.1, 2.1],
[2.1, 1.1]],
[[1.2, 2.2],
[2.2, 1.2]],
[[1.3, 2.3],
[2.3, 1.3]]])
How do I make a matrix multiplication of all of them?
The problem comes from the function X = foo(a)
that gives a matrix output. Once I calculate it on vector of length N
, I have N
matricies. Mathematically, I want to find this
ans = X[0] @ X[1] ... @ X[N-1]
For extremely large N
loop approach is going to be slow :(
So I want to vectorize it somehow.
Any help is appriciated!