Computing flops for matrix multiplication

13.5k Views Asked by At

enter image description here

I'm trying to compute the flops necessary to multiply $A(BC)$ and $(AB)C$, given $A \in \Bbb{R}^{m\times p}, B \in \Bbb{R}^{p\times n}, C \in \Bbb{R}^{n\times q}$, using the definition above.

I've determined:

$A(BC)$ = $(2n-1)pq + (2p-1)mq$ flops and

$(AB)C$ = $(2p-1)mn + (2n-1)mq$ flops.

Seeing as only one term, $-mq$, appears after distribution, I'm not sure which choice would have less flops.

1

There are 1 best solutions below

0
On BEST ANSWER

The difference between counts for $A(BC)$ and $(AB)C$ is $2 (mpq + npq - mnp - mnq) + mn - pq$ flops. This could be either positive or negative, depending on the relations of $m,p,q,n$.