Most recent code.Doubles have been changed to floats.Still does not work
for outputs of the size of 4096 and beyond.