Opened 9 years ago
Closed 7 years ago
#602 closed enhancement (done)
Platform independent pseudo random sequences
Reported by: | Alpar Juttner | Owned by: | Alpar Juttner |
---|---|---|---|
Priority: | major | Milestone: | LEMON 1.4 release |
Component: | core | Version: | hg main |
Keywords: | Cc: | ||
Revision id: |
Description
LEMON's random generator is based on the Mersenne Twister algoritm and it is optimized to 32 and 64 bit architecture. This is fine, except when someone want to obtain reproducible results (for a given initial seed) on each platform. The attached patch provides the following solution to this.
The original Random
class becomes a template and goes to the _random_bits
namespace, then three typedefs are defined:
Random
is exactly the same as the class Random was before,Random32
is the 32 bit version (on all platform) andRandom64
is the 64 bit version (on all platform).
This solution is fully backward compatible and the only drawback I can see is the documentation - one has to visit the template version to see the detailed API.
What do you think, is the documentation is acceptable in this form? If not, what would be a better solution?
Attachments (3)
Change History (9)
Changed 9 years ago by
Attachment: | 602-db1d342a1087.patch added |
---|
comment:1 Changed 8 years ago by
Type: | defect → enhancement |
---|
Changed 7 years ago by
Attachment: | 602-026829fdb6d4.patch added |
---|
comment:3 follow-up: 4 Changed 7 years ago by
I cannot apply 602-026829fdb6d4.patch with --exact, mercurial says this patch is corrupt.
Changed 7 years ago by
Attachment: | 602-04f57dad1b07.patch added |
---|
comment:4 Changed 7 years ago by
Replying to alpar:
I cannot apply 602-026829fdb6d4.patch with --exact, mercurial says this patch is corrupt.
Strange. I can reproduce the issue, but I do not understand its cause. It seems that if I export a changeset after it was modified (e.g. hg commit --amend
), then it cannot be imported with --exact. But if I import it without --exact, it works and a new hash ID is added to the commit. If I export this new version, then it can be imported with --exact. I do not understand why this happens. (I use Mercurial 4.3.1 on Ubuntu 17.10)
I recreated the patch as [04f57dad1b07] and tested it, it should work correctly.
comment:6 Changed 7 years ago by
Resolution: | → done |
---|---|
Status: | new → closed |
Changesets [db1d342a1087] and [04f57dad1b07] are pushed to the main branch.
I do like this changeset, we should merge it to the main branch.
I also added a patch [026829fdb6d4] with javadoc improvements (it is on the top of the proposed patch).