This is a c++ version of Sparse code