Skip to content Skip to sidebar Skip to footer

Multiple Matrix Multiplication

In numpy, I have an array of N 3x3 matrices. This would be an example of how I'm storing them (I'm abstracting away the contents): N = 10 matrices = np.ones((N, 3, 3)) I also have

Solution 1:

Use np.einsum -

np.einsum('ijk,ik->ij',matrices,vectors)

Steps :

1) Keep the first axes aligned.

2) Sum-reduce the last axes from the input arrays against each other.

3) Let the remainining axes(second axis from matrices) be element-wise multiplied.

Post a Comment for "Multiple Matrix Multiplication"