NumCpp  2.6.2
A Templatized Header Only C++ Implementation of the Python NumPy Library
permutation.hpp
Go to the documentation of this file.
1 
28 #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:
51  template<typename dtype>
52  NdArray<dtype> permutation(dtype inValue)
53  {
55 
56  NdArray<dtype> returnArray = arange(inValue);
57  std::shuffle(returnArray.begin(), returnArray.end(), generator_);
58  return returnArray;
59  }
60 
61  //============================================================================
62  // Method Description:
72  template<typename dtype>
74  {
76 
77  NdArray<dtype> returnArray(inArray);
78  std::shuffle(returnArray.begin(), returnArray.end(), generator_);
79  return returnArray;
80  }
81  } // namespace random
82 } // 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:1558
iterator begin() noexcept
Definition: NdArrayCore.hpp:1214
NdArray< dtype > permutation(dtype inValue)
Definition: permutation.hpp:52
static std::mt19937_64 generator_
generator function
Definition: generator.hpp:39
void shuffle(NdArray< dtype > &inArray)
Definition: shuffle.hpp:48
Definition: Coordinate.hpp:45
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition: arange.hpp:60