What is the complexity when multiplying an mxn matrix by an nxm matrix?

3.7k Views Asked by At

what is the matrix complexity when you multiply an mxn matrix by nxm matrix? my guess is that it will be m^2 since it would result to an m by m matrix, but im not too sure

all help would be much appreciated

1

There are 1 best solutions below

1
On BEST ANSWER

Computing the dot product of two length $n$ vectors requires $2n$ operations. In your case, you compute a dot product of two length $n$ vectors for each entry in the result. A total of $m^2 \cot 2n$ operations. The the operation count is $2m^2n$.

You can generalize this idea for an $n\times m$ matrix multiplied by a $m\times p$ matrix to get an operation count of $2mnp$