NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
permutation.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/NdArray.hpp"
33 
34 #include <algorithm>
35 
36 namespace nc
37 {
38  namespace random
39  {
40  //============================================================================
41  // Method Description:
49  template<typename dtype>
50  NdArray<dtype> permutation(dtype inValue)
51  {
53 
54  NdArray<dtype> returnArray = arange(inValue);
55  std::shuffle(returnArray.begin(), returnArray.end(), generator_);
56  return returnArray;
57  }
58 
59  //============================================================================
60  // Method Description:
68  template<typename dtype>
70  {
72 
73  NdArray<dtype> returnArray(inArray);
74  std::shuffle(returnArray.begin(), returnArray.end(), generator_);
75  return returnArray;
76  }
77  } // namespace random
78 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
iterator end() noexcept
Definition: NdArrayCore.hpp:1474
iterator begin() noexcept
Definition: NdArrayCore.hpp:1166
NdArray< dtype > permutation(dtype inValue)
Definition: permutation.hpp:50
static std::mt19937_64 generator_
generator function
Definition: generator.hpp:39
void shuffle(NdArray< dtype > &inArray)
Definition: shuffle.hpp:47
Definition: Coordinate.hpp:45
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition: arange.hpp:59