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.
More Related Contents:
- how does multiplication differ for NumPy Matrix vs Array classes?
- Bin elements per row – Vectorized 2D Bincount for NumPy
- Efficiently Calculating a Euclidean Distance Matrix Using Numpy
- Why list comprehension is much faster than numpy for multiplying arrays?
- How to get element-wise matrix multiplication (Hadamard product) in numpy?
- Most efficient way to map function over numpy array
- Performance of Pandas apply vs np.vectorize to create new column from existing columns
- Numpy matrix to array
- Implement MATLAB’s im2col ‘sliding’ in Python
- Frequency counts for unique values in a NumPy array
- Numpy ‘smart’ symmetric matrix
- Python’s sum vs. NumPy’s numpy.sum
- Pandas pd.Series.isin performance with set versus array
- Numpy and line intersections
- Deprecation status of the NumPy matrix class
- Efficiently detect sign-changes in python
- Efficient way to take the minimum/maximum n values and indices from a matrix using NumPy
- Iterating over Numpy matrix rows to apply a function each?
- Numpy vs Cython speed
- How to get faster code than numpy.dot for matrix multiplication?
- numpy float: 10x slower than builtin in arithmetic operations?
- Replace sub part of matrix by another small matrix in numpy
- Max in a sliding window in NumPy array
- No speedup when summing uint16 vs uint64 arrays with NumPy?
- Why is Numpy much faster at creating a Zero array compared to replacing the values of an existing array with zeros?
- Convert row vector to column vector in NumPy
- What is the most efficient way to check if a value exists in a NumPy array?
- Is MATLAB faster than Python?
- A numpy array unexpectedly changes when changing another one despite being separate
- What is the most efficient way of doing square root of sum of square of two numbers?