-1

Maybe it's ill advised doing this in the first place, but I'm trying to multiply a (k,k) matrix with (k,1) random vector, and I want to do this M times. I want to do this in one calculation, so having a (k,M) matrix and multiplying each column by my (k,K) matrix. Similar to how you would multiply a scalar with a vector. Is this possible without a loop?

Oscar
  • 279
  • 1
  • 10
  • 1
    What's your expected output? Maybe provide an example of sample input and output. – Shubham Sharma Apr 02 '20 at 04:58
  • Please repeat the intro tour, especially [how to ask](https://stackoverflow.com/help/how-to-ask). Also research the available operations in NumPy and other matrix-supporting packages. – Prune Apr 02 '20 at 05:39
  • Does this answer your question? [numpy matrix vector multiplication](https://stackoverflow.com/questions/21562986/numpy-matrix-vector-multiplication) – Joe Apr 02 '20 at 06:35

1 Answers1

0

Not in pure Python. The numpy package is universally used for numerical computation in Python. It provides several ways of doing this kind of vectorized matrix multiplication, of which the most common is probably numpy.matmul(): https://docs.scipy.org/doc/numpy/reference/generated/numpy.matmul.html

Dave Kielpinski
  • 1,152
  • 1
  • 9
  • 20