Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some RNGs for the standard library, plus typeclass interfaces. #70

Merged
merged 7 commits into from Aug 27, 2019

Conversation

markbrown
Copy link
Contributor

Julien, would you be able to review this?

One difference with the typeclass interface in extras/gator/tausworthe3.m is that there is no method for reseeding a generator. In generic code, it would be useful to reseed without knowing the generator's type, but the problem is that different generators need different amounts of information with which to seed. Therefore the seed type must be a typeclass parameter, or be something sufficiently generic like a list of ints. If a typeclass parameter is desired it would be better to put the reseed method in a separate typeclass, much as the random_dup method is separate.

Comments welcome from anyone.

@juliensf
Copy link
Member

Hi Mark, I will definitely review this ;-) Although probably on the mailing list.

@markbrown
Copy link
Contributor Author

Thanks. Just in case it wasn't obvious, it is much easier to come up with a sensible interface now that we have fixed sized integers :-)

library/rng.m:
    Top-level module containing typeclasses and generic routines,
    as well as overall documentation.

library/rng.binfile.m:
    A generator that reads from a file.

library/rng.marsaglia.m:
    Fast, simple generator. Diehard results for default seed:
        PASSED: 109
        WEAK:   2
        FAILED: 3

library/rng.tausworthe.m:
    Combined Tausworthe generators. Diehard results for default seed:

    generator T3
        PASSED: 113
        WEAK:   1
        FAILED: 0

    generator T4
        PASSED: 112
        WEAK:   2
        FAILED: 0

library/library.m:
library/MODULES_DOC:
    Add the new modules to the public interface.

library/float.m:
    Add functions to convert from (u)int32/64 to float.

library/uint32.m:
    Add function to convert from uint64 to uint32.

tests/hard_coded/Mmakefile:
tests/hard_coded/rng1.{m,exp}:
tests/hard_coded/rng2.{m,exp}:
    Test the generators. The expected outputs are derived from
    the output of the C reference implementations.
library/rng.sfc.m:
	New module that implements the above.

library/MODULES_DOC:
library/library.m:
library/rng.m:
	Add the new library module.

library/uint16.m:
	Add functions to cast to/from uint64.

tests/hard_coded/Mmakefile:
tests/hard_coded/*.*:
	Update/extend tests.
library/random.m:
    Move the new code to the existing random module. Update names and
    typeclass methods.

    Add adaptors to attach any ground or shared generator to the I/O
    state.

library/random.sfc{16,32,64}.m:
    Move sfc generators to here. Update for changes to interface.

extras/README:
extras/random/*.m:
    Move unused generators to a new directory under extras.

library/uint32.m:
    Add cast_from_uint/1.

library/MODULES_DOC:
library/library.m:
    Update for the module changes.

tests/hard_coded/*:
    Rename test cases to correspond with the library module name.

    Test the I/O adaptor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants