NumCpp  2.8.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
uniform.hpp
Go to the documentation of this file.
1 #pragma once
29 
33 
34 namespace nc
35 {
36  namespace random
37  {
38  namespace detail
39  {
40  //============================================================================
41  // Method Description:
55  template<typename dtype, typename GeneratorType = std::mt19937>
56  dtype uniform(GeneratorType& generator, dtype inLow, dtype inHigh)
57  {
58  STATIC_ASSERT_FLOAT(dtype);
59 
60  return detail::randFloat(generator, inLow, inHigh);
61  }
62 
63  //============================================================================
64  // Method Description:
79  template<typename dtype, typename GeneratorType = std::mt19937>
80  NdArray<dtype> uniform(GeneratorType& generator, const Shape& inShape, dtype inLow, dtype inHigh)
81  {
82  STATIC_ASSERT_FLOAT(dtype);
83 
84  return detail::randFloat(generator, inShape, inLow, inHigh);
85  }
86  } // namespace detail
87 
88  //============================================================================
89  // Method Description:
102  template<typename dtype>
103  dtype uniform(dtype inLow, dtype inHigh)
104  {
105  return detail::uniform(generator_, inLow, inHigh);
106  }
107 
108  //============================================================================
109  // Method Description:
123  template<typename dtype>
124  NdArray<dtype> uniform(const Shape& inShape, dtype inLow, dtype inHigh)
125  {
126  return detail::uniform(generator_, inShape, inLow, inHigh);
127  }
128  } // namespace random
129 } // namespace nc
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:45
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
dtype randFloat(GeneratorType &generator, dtype inLow, dtype inHigh=0.0)
Definition: randFloat.hpp:63
dtype uniform(GeneratorType &generator, dtype inLow, dtype inHigh)
Definition: uniform.hpp:56
static std::mt19937_64 generator_
generator function
Definition: generator.hpp:37
dtype uniform(dtype inLow, dtype inHigh)
Definition: uniform.hpp:103
Definition: Coordinate.hpp:45