#ifndef PYTHONIC_NUMPY_RANDOM_RANDINT_HPP #define PYTHONIC_NUMPY_RANDOM_RANDINT_HPP #include "pythonic/include/numpy/random/randint.hpp" #include "pythonic/include/numpy/random/generator.hpp" #include "pythonic/types/ndarray.hpp" #include "pythonic/types/tuple.hpp" #include "pythonic/utils/functor.hpp" #include PYTHONIC_NS_BEGIN namespace numpy { namespace random { template typename std::enable_if::value, types::ndarray>::type randint(long min, long max, pS const &shape) { types::ndarray result{shape, types::none_type()}; std::uniform_int_distribution distribution{min, max - 1}; std::generate(result.fbegin(), result.fend(), [&]() { return distribution(details::generator); }); return result; } template typename std::enable_if::value, types::ndarray>>::type randint(long min, long max, pS const &shape) { return randint(min, max, types::pshape{shape}); } template auto randint(long max, types::none_type, pS const &shape) -> decltype(randint(0, max, shape)) { return randint(0, max, shape); } auto randint(long min, long max, long size) -> decltype(randint(min, max, types::array{{size}})) { return randint(min, max, types::array{{size}}); } long randint(long max, types::none_type) { return std::uniform_int_distribution{0, max - 1}(details::generator); } long randint(long min, long max) { return std::uniform_int_distribution{min, max - 1}(details::generator); } } } PYTHONIC_NS_END #endif