Opened 7 years ago

Closed 7 years ago

#11454 closed Bugs (fixed)

uniform_on_sphere.cpp incorrect for 1D vectors

Reported by: jon.gammell@… Owned by: No-Maintainer
Milestone: To Be Determined Component: random
Version: Boost 1.58.0 Severity: Problem
Keywords: Cc: mmoll@…

Description

On OSX 10.10 with Boost 1.58, the boost::uniform_on_sphere distribution returns incorrect 1D "vectors" that have a magnitude that is not equal to 1. I believe that the bug exists from 1.56 onwards.

Attached is a minimum working example that demonstrates the bug.

Attachments (2)

mwe_osx.cpp (2.5 KB ) - added by jon.gammell@… 7 years ago.
minimum working example of bug
uniform_on_sphere.hpp.patch (310 bytes ) - added by jon.gammell@… 7 years ago.
Proposed fix

Download all attachments as: .zip

Change History (7)

by jon.gammell@…, 7 years ago

Attachment: mwe_osx.cpp added

minimum working example of bug

comment:1 by jon.gammell@…, 7 years ago

I believe the error is a missing break statement in the 1D case of the switch.

I've got a patch ready to test, but I don't have direct access to the affected machine. I will follow up with the results when the test is run.

in reply to:  1 comment:2 by jon.gammell@…, 7 years ago

Specifically, inserted at Line 175 of uniform_on_sphere.hpp

by jon.gammell@…, 7 years ago

Attachment: uniform_on_sphere.hpp.patch added

Proposed fix

comment:3 by jon.gammell@…, 7 years ago

I've verified that the attached patch appears to fix the problem.

comment:4 by mmoll@…, 7 years ago

I added a pull request on github: https://github.com/boostorg/random/pull/21

comment:5 by Steven Watanabe, 7 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.