I beg to differ. I would consider them the same code generator, just with a parameter that allows you to do computations on a grid, or in a flattened space. I split up the C++ code into two pieces, so it's much easier to read, but it's still one function, since there is a lot of code shared between the two cases.