Optimize uniform_on_sphere for dims <= 3.  Fixes #1059.