Ported shared memory solution. Uses the num typedef so can swap between double and float. Double should be faster.