I was a little confused.. According to the formula, each row also depends on the next row, and the same to columns. If that is the case, allocating another matrix to store the updated values and swap array pointers between iterations would be a better idea, if given enough memory.

TomoA

@dzxburning The important thing isn't which values it depends on per se but which values it depends on being computed first. The formula for any single dot does depend on the values of the four neighbors, but the top and left values are necessarily the newly computed values of the algorithm instead of the old ones. It's confusing because we are given a mathematical formula for index $i,j$, but the formula is written keeping in mind that we are sweeping left to right, top down and modifying in place. Then, allocating another matrix to store updated values doesn't really help because the computations themselves are inherently dependent on each other.

PandaX

@dzxburning Here we are talking about the dependency in update-rule rather than the dependency in formula.

I was a little confused.. According to the formula, each row also depends on the next row, and the same to columns. If that is the case, allocating another matrix to store the updated values and swap array pointers between iterations would be a better idea, if given enough memory.

@dzxburning The important thing isn't which values it depends on per se but which values it depends on being computed first. The formula for any single dot does depend on the values of the four neighbors, but the top and left values are necessarily the newly computed values of the algorithm instead of the old ones. It's confusing because we are given a mathematical formula for index $i,j$, but the formula is written keeping in mind that we are sweeping left to right, top down and modifying in place. Then, allocating another matrix to store updated values doesn't really help because the computations themselves are inherently dependent on each other.

@dzxburning Here we are talking about the dependency in update-rule rather than the dependency in formula.