Linear Algebra and Its Applications · Problem 1.4.8
Matrices and Gaussian Elimination — Gilbert Strang
Mathematics · matrix-notation-and-multiplication
Problem
Do these subroutines multiply Ax by rows or columns? Start with B(I)=0:
\begin{verbatim}
DO 10 I = 1, N DO 10 J = 1, N
DO 10 J = 1, N DO 10 I = 1, N
10 B(I) = B(I) + A(I,J) * X(J) 10 B(I) = B(I) + A(I,J) * X(J)
\end{verbatim}
The outputs Bx=Ax are the same. The second code is slightly more efficient in FORTRAN and much more efficient on a vector machine (the first changes single entries B(I), the second can update whole vectors).