Downsample code

Need to convert c code to utilize cuda.