Downsampling boundaries of a 2D array
I think the first one is more understandable to a reader, while the second is more efficient and or more easily adapted to higher dimensions. Have you thought about something like:

if (dir == LEFT || dir == RIGHT){        
  int x = dir == LEFT ? 1 : block_width-1;
  double *boundary = dir == LEFT ? left_edge : right_edge;
  for(int j = 1; j &lt;= block_height; j += 2)
    left_edge[j/2] = (u[index(x,j)]   + u[index(x+1,j)] +
                      u[index(x,j+1)] + u[index(x+1,j+1)]) / 4;
}
else if (dir == UP || dir == DOWN){
  int y = dir == UP ? 1 : block_height-1
  double *boundary = dir == UP ? top_edge : bottom_edge;
  for(int i = 1; i &lt;= block_width; i += 2)
    boundary[i/2] = (u[index(i,y)]   + u[index(i,y+1)] +
                     u[index(i+1,y)] + u[index(i+1,y+1)]) / 4;
}


Or if the second is more inclined I would recommend just clear comments to show the intention of each variables meaning.

Also in the future adapting to more c++ style arrays (vectors), utilizing a c++ Matrix library, or making your own iterator (boundary iterator) would make for a very nice solution to this problem.