Cij = SUM{ Aik * Bkj }
for(Matrix_col_stream cj(C), bj(B); !cj.total_eof(); cj.next_column(), bj.next_column()) for(Matrix_row_stream ai(A); !ai.total_eof(); ai.next_row(), bj.rewind()) { register double cij = 0; while( !ai.eof() ) cij += ai.get() * bj.get(); cj.put(cij); }
The snippet with Matrix_stream is pseudocode. Although with Matrix_row_stream/Matrix_col_stream implementations (which is a piece of cake) it becomes a full-blown working code.
Note, there is no direct access to any element of the matrix anywhere in the code; everything is done in terms of the 'current' (element, row, col) and the next (element, row, col).
If you're saying it's all so corny, here's a less trivial example.
Mathematical algorithm seems to require a direct access to matrices. But it's not necessary. The whole deal is just traversing matrices in some specific ways.