C++ implementation of Smooth