Working version, just need to figure out how to choose the k (in SciPy they choose based on whether we're using float32 or float64).