The D4 ordering is a method used in direct solution methods to renumber the grid blocks so as to reduce the amount of computation and storage. Natural ordering numbers the grid blocks by rows or by columns, which for the two-dimensional five-point scheme yields a pentadiagonal system of equations; the D4 ordering arranges the grid blocks along the diagonal direction, and does not place adjacent grid blocks consecutively into the coefficient matrix. The ordering changes the structure of the matrix, so that subsequent solution by Gauss elimination saves memory and runs faster.
Let the two-dimensional grid have I × J blocks, with J < I. Natural ordering (numbering along the y direction, which has fewer blocks) requires approximately IJ³ operations and IJ² storage units for Gauss elimination; the D4 ordering requires approximately IJ³/2 − J⁴/4 operations and IJ²/2 − J³/4 storage units. When I = J, the work is only 1/4 of that of natural ordering, and in general the ratio lies between 1/2 and 1/4; in three dimensions it is generally 0.2–0.5, and when I = J = K it can be below 0.2. Among direct solution methods for systems of pentadiagonal equations, the D4 ordering is generally considered superior.