this is one of those things that would be trivial in C, but the rest of the program really wouldn't be. I don't feel up to fighting with C++ templates either. maybe Julia is worth looking into?