Boost.Random

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost.Random

Boost - Dev mailing list
I have wanted to use boost::random::random_device; as a seeder for my generator.

#include <boost/random/random_device.hpp> // For boost::random::random_device; seeder

But using this requires that I link to a library file
// LINK : fatal error LNK1104: cannot open file 'libboost_random-vc142-mt-gd-x64-1_73.lib'

So I have instead used C++ std random device successfully

  using std::random_device;
  random_device seeder;
  // Use seeder to get a different set of values each time.
  static boost::random::mt19937 gen(seeder()); // uint32_t

But is there any way I can stick to the Boost version (I imagine that it might prove more portable?
Or is this a delusion?)

Suggestions welcome.

Paul



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

winmail.dat (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list

On 17/06/2020 15:53, Paul A Bristow via Boost wrote:

> I have wanted to use boost::random::random_device; as a seeder for my generator.
>
> #include <boost/random/random_device.hpp> // For boost::random::random_device; seeder
>
> But using this requires that I link to a library file
> // LINK : fatal error LNK1104: cannot open file 'libboost_random-vc142-mt-gd-x64-1_73.lib'
>
> So I have instead used C++ std random device successfully
>
>    using std::random_device;
>    random_device seeder;
>    // Use seeder to get a different set of values each time.
>    static boost::random::mt19937 gen(seeder()); // uint32_t
>
> But is there any way I can stick to the Boost version (I imagine that it might prove more portable?
> Or is this a delusion?)

What do you mean by portable?  random_device is inherently non-portable
because it's.... random ;)

In many ways this is something that the std:: version does best as the
system implementer knows best how to implement on their OS.  Or you
could just link to Boost.Random of course which would work nearly
everywhere too I'm sure.

Best, John.


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
On 6/17/2020 1:48 PM, John Maddock via Boost wrote:

>
> On 17/06/2020 15:53, Paul A Bristow via Boost wrote:
>> I have wanted to use boost::random::random_device; as a seeder for my
>> generator.
>>
>> #include <boost/random/random_device.hpp> // For
>> boost::random::random_device; seeder
>>
>> But using this requires that I link to a library file
>> // LINK : fatal error LNK1104: cannot open file
>> 'libboost_random-vc142-mt-gd-x64-1_73.lib'
>>
>> So I have instead used C++ std random device successfully
>>
>>    using std::random_device;
>>    random_device seeder;
>>    // Use seeder to get a different set of values each time.
>>    static boost::random::mt19937 gen(seeder()); // uint32_t
>>
>> But is there any way I can stick to the Boost version (I imagine that
>> it might prove more portable?
>> Or is this a delusion?)
>
> What do you mean by portable?  random_device is inherently non-portable
> because it's.... random ;)
>
> In many ways this is something that the std:: version does best as the
> system implementer knows best how to implement on their OS.  Or you
> could just link to Boost.Random of course which would work nearly
> everywhere too I'm sure.

Sorry for breaking in but I have a Random PR for the Embarcadero C++
clang-based compilers which is a no-brainer to merge, if anyone has
access to merge boost.random. Also for Boost.regex I have an Embarcadero
C++ clang-baed PR waiting to merge.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On Wed, 17 Jun 2020 at 09:53, Paul A Bristow via Boost <
[hidden email]> wrote:

> I have wanted to use boost::random::random_device; as a seeder for my
> generator.
>
> #include <boost/random/random_device.hpp> // For
> boost::random::random_device; seeder
>
> But using this requires that I link to a library file
> // LINK : fatal error LNK1104: cannot open file
> 'libboost_random-vc142-mt-gd-x64-1_73.lib'
>
> So I have instead used C++ std random device successfully
>
>   using std::random_device;
>   random_device seeder;
>   // Use seeder to get a different set of values each time.
>   static boost::random::mt19937 gen(seeder()); // uint32_t
>
> But is there any way I can stick to the Boost version (I imagine that it
> might prove more portable?
>

Do you mean mean, more portable than the standard?

I have a *PoC* of a sax::aes_random_device at
https://github.com/degski/aes_random_device .

It is a PoC and also needs research, it is undoubtedly much better than
mt19937, and on Windows/MSVC is faster (~30%) than std::mt19937. The
Crypto-claim needs more code and research related to
backtracking-resistance, there will be no difference to the current
implementation of the hot path. The API is equal to std::random_device.

Alexander Grund has inspected the code and he has given me his feedback,
not all that feedback is (yet) incorporated.

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
On Wed, 17 Jun 2020 at 15:52, degski <[hidden email]> wrote:

> I have a *PoC* of a sax::aes_random_device at
> https://github.com/degski/aes_random_device .
>
> It is a PoC and also needs research, it is undoubtedly much better than
> mt19937, and on Windows/MSVC is faster (~30%) than std::mt19937. The
> Crypto-claim needs more code and research related to
> backtracking-resistance ...
>

The back-tracking resistance is only relevant in a cryptographic context
where the [this] CPRNG is under attack, with if I understood it well,
unlimited access to streams [blocks] of data and unlimited time [as an
assumption, i.e. somebody using a data-centre to actively crack a CPRNG].

The CPRNG is fully seeded with std::random_device, whereafter the device
needs no more entropy, it is 'spreading out' that initial entropy. The
entropy is massive as compared to a PRNG (mt19937 a.o.).

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list


> -----Original Message-----
> From: Boost <[hidden email]> On Behalf Of John Maddock via Boost
> Sent: 17 June 2020 18:48
> To: Paul A Bristow via Boost <[hidden email]>
> Cc: John Maddock <[hidden email]>
> Subject: Re: [boost] Boost.Random
>
>
> On 17/06/2020 15:53, Paul A Bristow via Boost wrote:
> > I have wanted to use boost::random::random_device; as a seeder for my generator.
> >
> > #include <boost/random/random_device.hpp> // For
> > boost::random::random_device; seeder
> >
> > But using this requires that I link to a library file // LINK : fatal
> > error LNK1104: cannot open file 'libboost_random-vc142-mt-gd-x64-1_73.lib'
> >
> > So I have instead used C++ std random device successfully
> >
> >    using std::random_device;
> >    random_device seeder;
> >    // Use seeder to get a different set of values each time.
> >    static boost::random::mt19937 gen(seeder()); // uint32_t
> >
> > But is there any way I can stick to the Boost version (I imagine that it might prove more
portable?
> > Or is this a delusion?)
>
> What do you mean by portable?  random_device is inherently non-portable because it's.... random ;)

By portable I mean 'works on as many platforms and C++ standard versions as possible'.
 
> In many ways this is something that the std:: version does best as the system implementer knows
best
> how to implement on their OS.  Or you could just link to Boost.Random of course which would work
> nearly everywhere too I'm sure.

I was just puzzled why Boost.Random needed to *link* when std:random_device doesn't  appear to.  Is
it quietly linking to a standard library?

Paul

PS Thanks for the even-more-random suggestions but I really, really don't care how randomly random
it is for my application.

So would following the crowd and using time(0) be simplest?




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
 
> So would following the crowd and using time(0)> be simplest?
I never liked time(0) for that particular use casebecause in the old days it had multiple millisecondresolution and lacked the seed resolution sometimes.
I do not know it the code below is best practice,but I usually use some kind of variation of below.You can switch system_clock for high_resolution_clock.
All this is straight off-the-rack C++11.


#include <chrono>
#include <iostream>
#include <random>

// Use time point now seed to get a different set of values each time.
const std::mt19937::result_type seed =
  std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());

// uint32_t
static std::mt19937 gen(seed);

int main()
{
  std::cout << gen() << std::endl;
}



    On Thursday, June 18, 2020, 10:27:27 AM GMT+2, Paul A Bristow via Boost <[hidden email]> wrote:  
 
 

> -----Original Message-----
> From: Boost <[hidden email]> On Behalf Of John Maddock via Boost
> Sent: 17 June 2020 18:48
> To: Paul A Bristow via Boost <[hidden email]>
> Cc: John Maddock <[hidden email]>
> Subject: Re: [boost] Boost.Random
>
>
> On 17/06/2020 15:53, Paul A Bristow via Boost wrote:
> > I have wanted to use boost::random::random_device; as a seeder for my generator.
> >
> > #include <boost/random/random_device.hpp> // For
> > boost::random::random_device; seeder
> >
> > But using this requires that I link to a library file // LINK : fatal
> > error LNK1104: cannot open file 'libboost_random-vc142-mt-gd-x64-1_73.lib'
> >
> > So I have instead used C++ std random device successfully
> >
> >    using std::random_device;
> >    random_device seeder;
> >    // Use seeder to get a different set of values each time.
> >    static boost::random::mt19937 gen(seeder()); // uint32_t
> >
> > But is there any way I can stick to the Boost version (I imagine that it might prove more
portable?
> > Or is this a delusion?)
>
> What do you mean by portable?  random_device is inherently non-portable because it's.... random ;)

By portable I mean 'works on as many platforms and C++ standard versions as possible'.
 
> In many ways this is something that the std:: version does best as the system implementer knows
best
> how to implement on their OS.  Or you could just link to Boost.Random of course which would work
> nearly everywhere too I'm sure.

I was just puzzled why Boost.Random needed to *link* when std:random_device doesn't  appear to.  Is
it quietly linking to a standard library?

Paul

PS Thanks for the even-more-random suggestions but I really, really don't care how randomly random
it is for my application.

So would following the crowd and using time(0) be simplest?




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost 

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
Using

std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());

 as seed looks nice and 'portable', assuming C++11.

No need to build Boost.Chrono library - the disadvantage that I was trying to avoid.

But using random_device looks even simpler, again assuming Standard C++11.

  using std::random_device;
  random_device seeder;
  static std::mt19937 generator(seeder());
  std::mt19937::result_type result = generator();
  std::cout << "random generated is " << result << std::endl; // 4033698283 3116091012 ...  different each run.

And showing a little more info

  using std::random_device;
  random_device seeder;
  std::mt19937::result_type seed = seeder();
  std::cout << "seed from seeder() is " << seed << std::endl;
  static std::mt19937 generator(seed);
  std::mt19937::result_type result = generator();
  std::cout << "random generated is " << result << std::endl; // 4033698283 3116091012 ...  different each run.

  std::mt19937::result_type is j
  std::is_same<std::mt19937::result_type, std::uint32_t>::value is true

  seed from seeder() is 2113960109
  random generated is 3830391306

Random zealots seem to have reservations about random_device - and pretty much anything?

All seem to work at C++11 with latest MSVC, Clang and GCC.

(Those poor unfortunates stuck in purgatory of the dark ages of c++98 are stuck with time(0)).

Thanks

Paul


> -----Original Message-----
> From: Boost <[hidden email]> On Behalf Of Christopher Kormanyos via Boost
> Sent: 20 June 2020 11:41
> To: Paul A Bristow via Boost <[hidden email]>
> Cc: Christopher Kormanyos <[hidden email]>
> Subject: Re: [boost] Boost.Random
>
>
> > So would following the crowd and using time(0)> be simplest?
> I never liked time(0) for that particular use casebecause in the old days it had multiple
> millisecondresolution and lacked the seed resolution sometimes.
> I do not know it the code below is best practice,but I usually use some kind of variation of below.You
> can switch system_clock for high_resolution_clock.
> All this is straight off-the-rack C++11.
>
>
> #include <chrono>
> #include <iostream>
> #include <random>
>
> // Use time point now seed to get a different set of values each time.
> const std::mt19937::result_type seed =
>   std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());
>
> // uint32_t
> static std::mt19937 gen(seed);
>
> int main()
> {
>   std::cout << gen() << std::endl;
> }
>
>
>
>     On Thursday, June 18, 2020, 10:27:27 AM GMT+2, Paul A Bristow via Boost <[hidden email]>
> wrote:
>
>
>
> > -----Original Message-----
> > From: Boost <[hidden email]> On Behalf Of John Maddock
> > via Boost
> > Sent: 17 June 2020 18:48
> > To: Paul A Bristow via Boost <[hidden email]>
> > Cc: John Maddock <[hidden email]>
> > Subject: Re: [boost] Boost.Random
> >
> >
> > On 17/06/2020 15:53, Paul A Bristow via Boost wrote:
> > > I have wanted to use boost::random::random_device; as a seeder for my generator.
> > >
> > > #include <boost/random/random_device.hpp> // For
> > > boost::random::random_device; seeder
> > >
> > > But using this requires that I link to a library file // LINK :
> > > fatal error LNK1104: cannot open file 'libboost_random-vc142-mt-gd-x64-1_73.lib'
> > >
> > > So I have instead used C++ std random device successfully
> > >
> > >    using std::random_device;
> > >    random_device seeder;
> > >    // Use seeder to get a different set of values each time.
> > >    static boost::random::mt19937 gen(seeder()); // uint32_t
> > >
> > > But is there any way I can stick to the Boost version (I imagine
> > > that it might prove more
> portable?
> > > Or is this a delusion?)
> >
> > What do you mean by portable?  random_device is inherently
> > non-portable because it's.... random ;)
>
> By portable I mean 'works on as many platforms and C++ standard versions as possible'.
>
> > In many ways this is something that the std:: version does best as the
> > system implementer knows
> best
> > how to implement on their OS.  Or you could just link to Boost.Random
> > of course which would work nearly everywhere too I'm sure.
>
> I was just puzzled why Boost.Random needed to *link* when std:random_device doesn't  appear to.  Is
> it quietly linking to a standard library?
>
> Paul
>
> PS Thanks for the even-more-random suggestions but I really, really don't care how randomly random it
> is for my application.
>
> So would following the crowd and using time(0) be simplest?
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
On Mon, 22 Jun 2020 at 06:59, Paul A Bristow via Boost <
[hidden email]> wrote:

> Using
>
>
> std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());
>
>  as seed looks nice and 'portable', assuming C++11.
>
> No need to build Boost.Chrono library - the disadvantage that I was trying
> to avoid.
>
> But using random_device looks even simpler, again assuming Standard C++11.
>
>   using std::random_device;
>   random_device seeder;
>   static std::mt19937 generator(seeder());
>

This can be better, you should seed the generator with a std::seed_seq,
which you would seed with the std::random_device.

If you use sax::aes_random_device non of the above is needed, the seeder
(can) serve as a CPRNG, with a speed comparable (but faster) than
std::mt19937_64 (on Windows).

  std::mt19937::result_type result = generator();

>   std::cout << "random generated is " << result << std::endl; //
> 4033698283 3116091012 ...  different each run.
>
> And showing a little more info
>
>   using std::random_device;
>   random_device seeder;
>   std::mt19937::result_type seed = seeder();
>   std::cout << "seed from seeder() is " << seed << std::endl;
>   static std::mt19937 generator(seed);
>   std::mt19937::result_type result = generator();
>   std::cout << "random generated is " << result << std::endl; //
> 4033698283 3116091012 ...  different each run.
>
>   std::mt19937::result_type is j
>   std::is_same<std::mt19937::result_type, std::uint32_t>::value is true
>
>   seed from seeder() is 2113960109
>   random generated is 3830391306
>
> Random zealots seem to have reservations about random_device - and pretty
> much anything?
>

The problem is that it is seeded by the OS and entropy might not be readily
available or not in the quantity you need. This will cause your system to
wait until sufficient randomness can  be acquired from f.e.the fan-speed at
some moment ot if you have an 'Intel Broadwell Chip'++ hardware
instructions gaussian noise within the cpu generates the system-entropy
[intel intrinsics]. The Intel story is what it says on the  box, I'm
suspicious.

degski

ps:

All seem to work at C++11 with latest MSVC, Clang and GCC.
>

We almost 2021, C++11 is almost complete on all compilers.

(Those poor unfortunates stuck in purgatory of the dark ages of c++98 are
> stuck with time(0)).
>

Some are even stuck in 2011, go figure.


> Thanks
>
> Paul
>
>
> > -----Original Message-----
> > From: Boost <[hidden email]> On Behalf Of Christopher
> Kormanyos via Boost
> > Sent: 20 June 2020 11:41
> > To: Paul A Bristow via Boost <[hidden email]>
> > Cc: Christopher Kormanyos <[hidden email]>
> > Subject: Re: [boost] Boost.Random
> >
> >
> > > So would following the crowd and using time(0)> be simplest?
> > I never liked time(0) for that particular use casebecause in the old
> days it had multiple
> > millisecondresolution and lacked the seed resolution sometimes.
> > I do not know it the code below is best practice,but I usually use some
> kind of variation of below.You
> > can switch system_clock for high_resolution_clock.
> > All this is straight off-the-rack C++11.
> >
> >
> > #include <chrono>
> > #include <iostream>
> > #include <random>
> >
> > // Use time point now seed to get a different set of values each time.
> > const std::mt19937::result_type seed =
> >
>  std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());
> >
> > // uint32_t
> > static std::mt19937 gen(seed);
> >
> > int main()
> > {
> >   std::cout << gen() << std::endl;
> > }
> >
> >
> >
> >     On Thursday, June 18, 2020, 10:27:27 AM GMT+2, Paul A Bristow via
> Boost <[hidden email]>
> > wrote:
> >
> >
> >
> > > -----Original Message-----
> > > From: Boost <[hidden email]> On Behalf Of John Maddock
> > > via Boost
> > > Sent: 17 June 2020 18:48
> > > To: Paul A Bristow via Boost <[hidden email]>
> > > Cc: John Maddock <[hidden email]>
> > > Subject: Re: [boost] Boost.Random
> > >
> > >
> > > On 17/06/2020 15:53, Paul A Bristow via Boost wrote:
> > > > I have wanted to use boost::random::random_device; as a seeder for
> my generator.
> > > >
> > > > #include <boost/random/random_device.hpp> // For
> > > > boost::random::random_device; seeder
> > > >
> > > > But using this requires that I link to a library file // LINK :
> > > > fatal error LNK1104: cannot open file
> 'libboost_random-vc142-mt-gd-x64-1_73.lib'
> > > >
> > > > So I have instead used C++ std random device successfully
> > > >
> > > >    using std::random_device;
> > > >    random_device seeder;
> > > >    // Use seeder to get a different set of values each time.
> > > >    static boost::random::mt19937 gen(seeder()); // uint32_t
> > > >
> > > > But is there any way I can stick to the Boost version (I imagine
> > > > that it might prove more
> > portable?
> > > > Or is this a delusion?)
> > >
> > > What do you mean by portable?  random_device is inherently
> > > non-portable because it's.... random ;)
> >
> > By portable I mean 'works on as many platforms and C++ standard versions
> as possible'.
> >
> > > In many ways this is something that the std:: version does best as the
> > > system implementer knows
> > best
> > > how to implement on their OS.  Or you could just link to Boost.Random
> > > of course which would work nearly everywhere too I'm sure.
> >
> > I was just puzzled why Boost.Random needed to *link* when
> std:random_device doesn't  appear to.  Is
> > it quietly linking to a standard library?
> >
> > Paul
> >
> > PS Thanks for the even-more-random suggestions but I really, really
> don't care how randomly random it
> > is for my application.
> >
> > So would following the crowd and using time(0) be simplest?
> >
> >
> >
> >
> > _______________________________________________
> > Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
> >
> > _______________________________________________
> > Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Random

Boost - Dev mailing list
On Thu, 25 Jun 2020 at 03:24, <[hidden email]> wrote:

>
>
>
>
> *From:* degski <[hidden email]>
> *Sent:* 24 June 2020 15:25
> *To:* boost <[hidden email]>
> *Cc:* Paul A. Bristow <[hidden email]>
> *Subject:* Re: [boost] Boost.Random
>
>
>
>
>
> On Mon, 22 Jun 2020 at 06:59, Paul A Bristow via Boost <
> [hidden email]> wrote:
>
> Using
>
>
> std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());
>
>  as seed looks nice and 'portable', assuming C++11.
>
> No need to build Boost.Chrono library - the disadvantage that I was trying
> to avoid.
>
> But using random_device looks even simpler, again assuming Standard C++11.
>
>   using std::random_device;
>   random_device seeder;
>   static std::mt19937 generator(seeder());
>
>
>
> This can be better, you should seed the generator with a std::seed_seq,
> which you would seed with the std::random_device.
>
>
>
> If you use sax::aes_random_device non of the above is needed, the seeder
> (can) serve as a CPRNG, with a speed comparable (but faster) than
> std::mt19937_64 (on Windows).
>
>
>
>
> Random zealots seem to have reservations about random_device - and pretty
> much anything?
>
>
>
> As I said before about random zealots!
>
>
>
> I am only testing round tripping of iostream, so true randomness is
> entirely unimportant.
>
> And since the tests take many hours, any time for a randomish seed is also
> of zero concern
>
>
>
>
>
> ps:
>
>
>
> All seem to work at C++11 with latest MSVC, Clang and GCC.
>
>
>
> We almost 2021, C++11 is almost complete on all compilers.
>
>
>
> But not necessarily standard libraries – GCC and Clang fail
> roundtrip/loopback binary > decimal > binary using std::hexfloat ☹
>

C++17 has introduced <charconv>, this does what the old stuff does, but
much better (faster, better (C-) API).

Here your caveat applies, I'm not sure this is in every standard library.
STL has done most of the heavy lifting, as IIRC the MSVC implementation
will be ported to GCC/Clang, when deemed 'finished'. I have not seen any
announcement anywhere, so I guess it's on-going. I think you'll get
std::hexfloat when the respective C++17-STL's have <charconv>.


>
> But Thanks
>
> Paul
>
>
> > -----Original Message-----
> > From: Boost <[hidden email]> On Behalf Of Christopher
> Kormanyos via Boost
> > Sent: 20 June 2020 11:41
> > To: Paul A Bristow via Boost <[hidden email]>
> > Cc: Christopher Kormanyos <[hidden email]>
> > Subject: Re: [boost] Boost.Random
> >
> >
> > > So would following the crowd and using time(0)> be simplest?
> > I never liked time(0) for that particular use casebecause in the old
> days it had multiple
> > millisecondresolution and lacked the seed resolution sometimes.
> > I do not know it the code below is best practice,but I usually use some
> kind of variation of below.You
> > can switch system_clock for high_resolution_clock.
> > All this is straight off-the-rack C++11.
> >
> >
> > #include <chrono>
> > #include <iostream>
> > #include <random>
> >
> > // Use time point now seed to get a different set of values each time.
> > const std::mt19937::result_type seed =
> >
>  std::mt19937::result_type(std::chrono::system_clock::now().time_since_epoch().count());
> >
> > // uint32_t
> > static std::mt19937 gen(seed);
> >
> > int main()
> > {
> >   std::cout << gen() << std::endl;
> > }
> >
> >
> >
> >     On Thursday, June 18, 2020, 10:27:27 AM GMT+2, Paul A Bristow via
> Boost <[hidden email]>
> > wrote:
> >
> >
> >
> > > -----Original Message-----
> > > From: Boost <[hidden email]> On Behalf Of John Maddock
> > > via Boost
> > > Sent: 17 June 2020 18:48
> > > To: Paul A Bristow via Boost <[hidden email]>
> > > Cc: John Maddock <[hidden email]>
> > > Subject: Re: [boost] Boost.Random
> > >
> > >
> > > On 17/06/2020 15:53, Paul A Bristow via Boost wrote:
> > > > I have wanted to use boost::random::random_device; as a seeder for
> my generator.
> > > >
> > > > #include <boost/random/random_device.hpp> // For
> > > > boost::random::random_device; seeder
> > > >
> > > > But using this requires that I link to a library file // LINK :
> > > > fatal error LNK1104: cannot open file
> 'libboost_random-vc142-mt-gd-x64-1_73.lib'
> > > >
> > > > So I have instead used C++ std random device successfully
> > > >
> > > >    using std::random_device;
> > > >    random_device seeder;
> > > >    // Use seeder to get a different set of values each time.
> > > >    static boost::random::mt19937 gen(seeder()); // uint32_t
> > > >
> > > > But is there any way I can stick to the Boost version (I imagine
> > > > that it might prove more
> > portable?
> > > > Or is this a delusion?)
> > >
> > > What do you mean by portable?  random_device is inherently
> > > non-portable because it's.... random ;)
> >
> > By portable I mean 'works on as many platforms and C++ standard versions
> as possible'.
> >
> > > In many ways this is something that the std:: version does best as the
> > > system implementer knows
> > best
> > > how to implement on their OS.  Or you could just link to Boost.Random
> > > of course which would work nearly everywhere too I'm sure.
> >
> > I was just puzzled why Boost.Random needed to *link* when
> std:random_device doesn't  appear to.  Is
> > it quietly linking to a standard library?
> >
> > Paul
> >
> > PS Thanks for the even-more-random suggestions but I really, really
> don't care how randomly random it
> > is for my application.
> >
> > So would following the crowd and using time(0) be simplest?
> >
> >
> >
> >
> > _______________________________________________
> > Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
> >
> > _______________________________________________
> > Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost