C++ implementation of k-mean dynamic mean algorithm