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
extremeValue.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <algorithm>
31#include <random>
32#include <string>
33
36#include "NumCpp/Core/Shape.hpp"
37#include "NumCpp/NdArray.hpp"
39
40namespace nc::random
41{
42 namespace detail
43 {
44 //============================================================================
45 // Method Description:
53 template<typename dtype, typename GeneratorType = std::mt19937>
55 {
57
58 if (inA <= 0)
59 {
60 THROW_INVALID_ARGUMENT_ERROR("input a must be greater than zero.");
61 }
62
63 if (inB <= 0)
64 {
65 THROW_INVALID_ARGUMENT_ERROR("input b must be greater than zero.");
66 }
67
68 std::extreme_value_distribution<dtype> dist(inA, inB);
69 return dist(generator);
70 }
71
72 //============================================================================
73 // Method Description:
83 template<typename dtype, typename GeneratorType = std::mt19937>
85 {
87
88 if (inA <= 0)
89 {
90 THROW_INVALID_ARGUMENT_ERROR("input a must be greater than zero.");
91 }
92
93 if (inB <= 0)
94 {
95 THROW_INVALID_ARGUMENT_ERROR("input b must be greater than zero.");
96 }
97
99
100 std::extreme_value_distribution<dtype> dist(inA, inB);
101
102 std::for_each(returnArray.begin(),
103 returnArray.end(),
104 [&generator, &dist](dtype& value) -> void { value = dist(generator); });
105
106 return returnArray;
107 }
108 } // namespace detail
109
110 //============================================================================
111 // Method Description:
118 template<typename dtype>
120 {
121 return detail::extremeValue<dtype>(generator_, inA, inB);
122 }
123
124 //============================================================================
125 // Method Description:
134 template<typename dtype>
136 {
137 return detail::extremeValue<dtype>(generator_, inShape, inA, inB);
138 }
139} // namespace nc::random
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
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
dtype extremeValue(GeneratorType &generator, dtype inA=1, dtype inB=1)
Definition extremeValue.hpp:54
Definition Random/bernoulli.hpp:41
dtype extremeValue(dtype inA=1, dtype inB=1)
Definition extremeValue.hpp:119
std::mt19937_64 generator_
generator function
Definition generator.hpp:35
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59