NumCpp  2.4.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:
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
StaticAsserts.hpp
nc::random::permutation
NdArray< dtype > permutation(dtype inValue)
Definition: permutation.hpp:52
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::random::shuffle
void shuffle(NdArray< dtype > &inArray)
Definition: shuffle.hpp:48
generator.hpp
nc::NdArray< dtype >
NdArray.hpp
nc::NdArray::end
iterator end() noexcept
Definition: NdArrayCore.hpp:1431
nc
Definition: Coordinate.hpp:44
nc::random::generator_
static std::mt19937_64 generator_
generator function
Definition: generator.hpp:39
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087
nc::arange
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition: arange.hpp:60