Skip to content

Commit 37afc37

Browse files
authored
Merge pull request #688 from jharwell/rng-distribution-fix
Fix {normal, extreme_value} distributions to work with quantities
2 parents 7945e8e + 0d664b4 commit 37afc37

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/include/mp-units/random.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ struct extreme_value_distribution : public std::extreme_value_distribution<typen
289289
template<typename Generator>
290290
Q operator()(Generator& g)
291291
{
292-
return Q(base::operator()(g));
292+
return base::operator()(g) * Q::reference;
293293
}
294294

295295
[[nodiscard]] Q a() const { return base::a() * Q::reference; }
@@ -313,7 +313,7 @@ struct normal_distribution : public std::normal_distribution<typename Q::rep> {
313313
template<typename Generator>
314314
Q operator()(Generator& g)
315315
{
316-
return Q(base::operator()(g));
316+
return base::operator()(g) * Q::reference;
317317
}
318318

319319
[[nodiscard]] Q mean() const { return base::mean() * Q::reference; }

0 commit comments

Comments
 (0)