C++ implementation of Baristow's method (polynomial decomposition)