Boost logo

Boost :

Subject: Re: [boost] [xint] Third release is ready, requesting preliminary review
From: Chad Nelson (chad.thecomfychair_at_[hidden])
Date: 2010-05-02 15:58:37


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/02/2010 03:14 PM, Scott McMurray wrote:

>> Sorry again, but I wasn't just asking about semantics -- I'm asking what
>> you're suggesting the actual code should look like. I'm going through a
>> function at least partly so that I can wrap the provided random
>> generator to provide the unsigned int type that my code is expecting,
>> regardless of what type or size the generator is defined to return,
>> without overly complicating things for the user of the library. Look at
>> the definition of detail::random_generator in random.hpp to see what I mean.
>
> Are you inventing a new method here?

Not that I'm aware of, just using Boost.Random as it seems to be intended.

> It seems like there's no need for you to define anything new that
> models the NumberGenerator concept (or any of the concepts derived rom
> that), since there are plenty already
> <http://www.boost.org/doc/libs/1_42_0/libs/random/random-generators.html>.

Yes, and you can plug any one of those into XInt's current random number
system. It uses a mersenne_twister by default, since there are currently
no secure random number generators usable in Windows in Boost.Random
(though the release currently being prepped is supposed to have one).

> So to fit in the Boost.Random model, you should be providing a new
> model of the RandomDistribution concept for generating random primes.

You lost me. I'm not sure that the Boost.Random model even *could* be
adapted to use large integers (and haven't looked), but in any case,
that's not my intent. The random number system in XInt is designed
primarily and specifically for providing large random numbers for the
random_prime function, and secondarily to get numbers for the purpose of
testing the library. It has features that aren't really applicable to a
generic random number generator.

> Hopefully your integer class will also work with the uniform_int
> <http://www.boost.org/doc/libs/1_42_0/libs/random/random-distributions.html#uniform_int>
> distribution, and I'd claim that if it doesn't, that's a bug in either
> Boost.Random or your library.

XInt uses the uniform_int distribution -- again, see the
detail::random_generator class in random.hpp. And if Boost.Random can
use a user-defined type, then I'm sure someone could hook them together
without much effort to make a generic large-integer random generator.
That's not my goal, I just need a decent source of entropy so that I can
build some large random numbers for the purposes I outlined above.

> Then the user with use a variate_generator
> <http://www.boost.org/doc/libs/1_42_0/libs/random/random-variate.html>
> with appropriate template arguments to get what they want. My
> suggestion of the default_random_generator would simply be a typedef
> to a usual set of these arguments, so people could instantiate one
> without needing to know the details, and could then use it like
> they're already used to with existing Boost.Random generators.

Ah... the light dawns. :-) I think I see what you're saying now,
vaguely. Yes, that might be simple enough that people could whip
something up without much study time. I'll see what I can come up with.
- --
Chad Nelson
Oak Circle Software, Inc.
*
*
*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvd2WoACgkQp9x9jeZ9/wS5sQCfa4PxRC/kMvkOKdL2RpN9GZkZ
hC8AniBhChbVxalFxTiXbkIH/fjUx3sb
=64Qr
-----END PGP SIGNATURE-----


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk