One of the applications of minimum bandwidth ordering is in optimizing cache performance of numerical calculations. For example, in multiplying a sparse matrix with a vector, if the matrix is preordered to minimize the bandwidth, then elements of the vector will not be accessed randomly, thus improving cache performance. Because ordering itself takes time, this improvement in cache performance would be beneficial only if the matrix-vector product operation is to be performed repeatedly many times.
This generates a banded matrix, and then randomly permutes it:
This performs a matrix-vector product 50 times:
This permutes the matrix to minimize the bandwidth, and permutes the vector correspondingly:
This shows that the matrix-vector product now takes less time:
This checks that the answer is the same, subject to a permutation: