extent: use matching types for random calls

This commit is contained in:
Danny Robson 2019-04-11 11:48:34 +10:00
parent 6f440d0bcf
commit ea8416592a

View File

@ -166,13 +166,17 @@ namespace cruft {
}
/// Return a uniform random point that lies within the extent.
///
/// The interval conventions are the same as for the std library; close for
/// integers, half-open for reals.
template <size_t S, typename T, typename GeneratorT>
cruft::point<S,T>
sample (cruft::extent<S,T> shape, GeneratorT &&gen)
{
cruft::point<S,T> p;
for (size_t i = 0; i < S; ++i)
p[i] = cruft::random::uniform (0, shape[i], gen);
p[i] = cruft::random::uniform (T{0}, shape[i], gen);
return p;
}