Skip to content

Commit a3852d5

Browse files
committed
fix clang-format
1 parent 3ac4402 commit a3852d5

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

tutorials/analysis/dataframe/df041_ThreadSafeRNG.C

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ double GetNormallyDistributedNumber()
4444

4545
double GetNormallyDistributedNumberForEntry(unsigned long long entry)
4646
{
47-
// We want to generate a random number distributed according to a normal distribution in a thread-safe way and such that it is reproducible across different RDataFrame runs, i.e. given the same input to the generator it will produce the same value.
48-
// This is one way to do it. It assumes that the input argument represents a unique entry ID, such that any thread processing an RDataFrame task will see this number once throughout the entire execution of the computation graph
47+
// We want to generate a random number distributed according to a normal distribution in a thread-safe way and such
48+
// that it is reproducible across different RDataFrame runs, i.e. given the same input to the generator it will
49+
// produce the same value. This is one way to do it. It assumes that the input argument represents a unique entry ID,
50+
// such that any thread processing an RDataFrame task will see this number once throughout the entire execution of
51+
// the computation graph
4952
thread_local std::mt19937 generator;
5053
thread_local std::normal_distribution<double> gaus(0., 1.);
51-
// Calling both `reset` and `seed` methods is fundamental here to ensure reproducibility: without them the same generator could be seeded by a different entry (depending on which is the first entry ID seen by a thread) or could be at a different step of the sequence (depending how many entries this particular thread is processing).
52-
// Alternatively, if both the generator and the distribution objects were recreated from scratch at every function call (i.e. by removing the `thread_local` attribute), then the next two method calls would not be necessary, at the cost of a possible performance degradation.
54+
// Calling both `reset` and `seed` methods is fundamental here to ensure reproducibility: without them the same
55+
// generator could be seeded by a different entry (depending on which is the first entry ID seen by a thread) or
56+
// could be at a different step of the sequence (depending how many entries this particular thread is processing).
57+
// Alternatively, if both the generator and the distribution objects were recreated from scratch at every function
58+
// call (i.e. by removing the `thread_local` attribute), then the next two method calls would not be necessary, at
59+
// the cost of a possible performance degradation.
5360
gaus.reset();
5461
generator.seed(entry);
5562
return gaus(generator);

0 commit comments

Comments
 (0)