-
Notifications
You must be signed in to change notification settings - Fork 432
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
SeedableRng
cannot be implemented for large RNGs using the recommended seed type
#354
Comments
SeedableRng
cannot be implemented for large RNGsSeedableRng
cannot be implemented for large RNGs using the recommended seed type
I think either the documentation should discuss how to implement |
8 × 32 = 256 bits which is more than enough for most purposes. Some key expansion algorithm should be used internally for larger state sizes I think. If you want compatibility with initialisation as used in another implementation, then I think a custom constructor is the best option. |
I really don't like that |
But as you say, @dhardy, 256 bit's should just be enough. |
If we decide to do drop support for large RNGs, I think we should document the limitations of Using some key expansion is not really an option if reproducibility across implementations is needed. A custom constructor is not ideal, because it does not support |
We know const generics will solve this. If we need this sooner, then we should do a PR or RFC for the needed sizes as "preparation for const generics". It might encourage them to deliver const generics sooner. If it can wait till 2019 then just let it wait. |
Ok, I think the best workaround is to wrap the large seeds in a newtype and to implement then required traits by hand. No custom constructor required. It should be enough to update the documentation. I will submit a pull request. |
Does anyone feel adventurous to make a PR to the rust repo to support some more common powers of two for |
Right, new types are beneficial anyways, so maybe something like: "We currently recommend that |
In our case we also need `Default`.
…On Fri, Mar 30, 2018, 15:19 Paul Dicker ***@***.***> wrote:
Does anyone feel adventurous to make a PR to the rust repo to support some
more common powers of two for AsRef and AsMut?
|
@vks can I close this? Or do you want to make a documentation PR? This is only a temporary problem anyway until const generics support is ready. |
I will make a PR. This is a papercut until const generics are in, which
will at least take a year.
The newtype pattern is also an elegant solution to avoid panicking in
`from_seed` by making invalid seeds unconstructible.
…On Wed, Apr 4, 2018, 12:04 Diggory Hardy ***@***.***> wrote:
@vks <https://github.com/vks> can I close this? Or do you want to make a
documentation PR?
This is only a temporary problem anyway until const generics support is
ready.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#354 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACCtLApVjeVqXIWFlExk6cWkvzxzBJfks5tlJq8gaJpZM4TATQi>
.
|
Good. The doc on |
@burdges I did not suggest to always use newtypes, because we are not doing it in Rand. If we decide to suggest this, I think we should also do it ourselves. |
For example, xorshift1024* has a recommended
[u8; 128]
seed type, for whichstd::convert::AsMut<[u8]>
is not implemented, making it impossible to implementSeedableRng
. This also affects common RNGs like the Mersenne Twister.The text was updated successfully, but these errors were encountered: