C++ version modified to use TCLAP to parse command line arguments.