public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Oliver Kullmann <o.kullmann@swansea.ac.uk>
Cc: gcc-help@gcc.gnu.org
Subject: Re: where are the implementations for <random>?
Date: Sun, 09 Apr 2017 18:24:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.20.1704092015110.1870@stedding.saclay.inria.fr> (raw)
In-Reply-To: <20170409173101.GA10474@csltok.swansea.ac.uk>

On Sun, 9 Apr 2017, Oliver Kullmann wrote:

> Hello,
>
> I thought that with the facilities from <random> we had good and
> well-defined ones -- but alas, only recently I realised that only say
> the Mersenne twister is well-defined in the standard, but roughly
> everything else is up to the implementer.
>
> Since reproducibility is crucial for us (as with most scientific
> applications), thus we need to implement ourselves the algorithms for
>
> 1. std::seed_seq
> 2. std::uniform_int_distribution
> 3. std::bernoulli_distribution (only for default p=0.5).
>
> Easiest would be to copy (and specialise) the gcc-implementations.
> I searched for it in the source-code, but couldn't find it:
>
> Where do I find the implementations for <random> ?

Option 1)
First you find the file called "random" (/usr/include/c++/6/random here), 
then you notice that it contains
#include <bits/random.h>
#include <bits/opt_random.h>
#include <bits/random.tcc>
so you look for those files (and recursively if needed)

Option 2)
You compile a file that contains #include <random> using the -E flag, and 
look for bernoulli_distribution or whatever in the output.

Option 3)
Get the sources for gcc.
grep -r bernoulli_distribution /the/sources

They all point to bits/random.h (with one function implemented in 
bits/random.tcc), with older versions in tr1/.

-- 
Marc Glisse

  reply	other threads:[~2017-04-09 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-09 17:31 Oliver Kullmann
2017-04-09 18:24 ` Marc Glisse [this message]
2017-04-09 23:32   ` Martin Sebor
2017-04-11 13:03     ` Oliver Kullmann
2017-04-11 18:26       ` Oliver Kullmann
2017-04-11 20:17         ` Oliver Kullmann
2017-04-11 20:27           ` Jonathan Wakely
2017-04-12  3:41             ` Oliver Kullmann
2017-04-12  5:01               ` Oliver Kullmann
2018-12-21 12:34 ` wrong sha512 values for 7.4.0 ? Oliver Kullmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1704092015110.1870@stedding.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-help@gcc.gnu.org \
    --cc=o.kullmann@swansea.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).