How to write efficient matrix multiplication
Sorry, but this is not at all how to write efficient matrix multiplication.<p>The correct answer is: don't. Use BLAS (yes, written in Fortran) + OpenMP (if needed), and let the smart people handle this. (Unless you are one of those smart people - in which case, you should improve BLAS, which the rest of us mortals will use).<p>The longer answer is: matrix multiplication is a highly non-trivial algorithmic problem[1], which is, in fact, still open.<p>The asymptotically fast algorithms (such as Strassen's[2]) outperform the naive algorithm (i.e. by definition, such is in the article) when matrices get large.<p>After skimming the article it is still unclear to me how the optimized naive algorithm fares against Strassen's, for example.<p>The final bit of advice this article is offers is reading the paper on... implementation of BLAS (that's what Goto describes there).<p>And so that's basically <i>the</i> case where <i>avoiding</i> Goto is considered harmful.<p>[1]<a href="https://en.wikipedia.org/wiki/Matrix_multiplication_algorithm#Sub-cubic_algorithms" rel="nofollow">https://en.wikipedia.org/wiki/Matrix_multiplication_algorith...</a><p>[2]<a href="https://en.wikipedia.org/wiki/Strassen_algorithm" rel="nofollow">https://en.wikipedia.org/wiki/Strassen_algorithm</a><p>[3]<a href="https://en.wikiquote.org/wiki/Donald_Knuth" rel="nofollow">https://en.wikiquote.org/wiki/Donald_Knuth</a>