wrote c++ functions to convert generalised sparse grid to a pce