11#ifndef GUDHI_RANDOM__H_
12#define GUDHI_RANDOM__H_
22 Random() : gen_(rd_()) {}
23 Random(std::uint_fast32_t seed) : gen_(seed) {}
25 template <
typename Type>
26 Type
get(
const Type& min = 0,
const Type& max = 1) {
27 if constexpr (std::is_floating_point_v<Type>) {
28 std::uniform_real_distribution<Type> dis(min, max);
30 }
else if constexpr (std::is_integral_v<Type>) {
31 std::uniform_int_distribution<Type> dis(min, max);
36 template <
typename Type>
37 std::vector<Type> get_range(std::size_t nbr,
const Type& min = 0,
const Type& max = 1) {
38 std::vector<Type> result(nbr);
39 if constexpr (std::is_floating_point_v<Type>) {
40 std::uniform_real_distribution<Type> dis(min, max);
41 std::generate(result.begin(), result.end(), [&]() { return dis(gen_); });
42 }
else if constexpr (std::is_integral_v<Type>) {
43 std::uniform_int_distribution<Type> dis(min, max);
44 std::generate(result.begin(), result.end(), [&]() { return dis(gen_); });
51 inline static std::random_device rd_;
constexpr auto & get(Gudhi::persistence_matrix::Persistence_interval< Dimension, Event_value > &i) noexcept
Partial specialization of get for Gudhi::persistence_matrix::Persistence_interval.
Definition: persistence_interval.h:199
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14