NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
randN.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <algorithm>
31#include <random>
32
34#include "NumCpp/Core/Shape.hpp"
35#include "NumCpp/NdArray.hpp"
37
38namespace nc::random
39{
40 namespace detail
41 {
42 //============================================================================
43 // Method Description:
52 template<typename dtype, typename GeneratorType = std::mt19937>
54 {
56
57 std::normal_distribution<dtype> dist;
58 return dist(generator);
59 }
60
61 //============================================================================
62 // Method Description:
73 template<typename dtype, typename GeneratorType = std::mt19937>
75 {
77
79
80 std::normal_distribution<dtype> dist;
81
82 std::for_each(returnArray.begin(),
83 returnArray.end(),
84 [&generator, &dist](dtype& value) -> void { value = dist(generator); });
85
86 return returnArray;
87 }
88 } // namespace detail
89
90 //============================================================================
91 // Method Description:
99 template<typename dtype>
101 {
102 return detail::randN<dtype>(generator_);
103 }
104
105 //============================================================================
106 // Method Description:
116 template<typename dtype>
118 {
119 return detail::randN<dtype>(generator_, inShape);
120 }
121} // namespace nc::random
#define STATIC_ASSERT_FLOAT(dtype)
Definition StaticAsserts.hpp:50
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
Definition Random/bernoulli.hpp:41
std::mt19937_64 generator_
generator function
Definition generator.hpp:35
dtype randN()
Definition randN.hpp:100
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59