NumCpp  1.0
A C++ implementation of the Python Numpy library
permutation.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
34 
35 #include <algorithm>
36 
37 namespace nc
38 {
39  namespace random
40  {
41  //============================================================================
42  // Method Description:
52  template<typename dtype>
53  NdArray<dtype> permutation(dtype inValue)
54  {
56 
57  NdArray<dtype> returnArray = arange(inValue);
58  std::shuffle(returnArray.begin(), returnArray.end(), generator_);
59  return returnArray;
60  }
61 
62  //============================================================================
63  // Method Description:
73  template<typename dtype>
75  {
77 
78  NdArray<dtype> returnArray(inArray);
79  std::shuffle(returnArray.begin(), returnArray.end(), generator_);
80  return returnArray;
81  }
82  }
83 }
StaticAsserts.hpp
nc::random::permutation
NdArray< dtype > permutation(dtype inValue)
Definition: permutation.hpp:53
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
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:1435
nc
Definition: Coordinate.hpp:45
nc::random::generator_
static std::mt19937_64 generator_
generator function
Definition: generator.hpp:40
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091
nc::arange
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition: arange.hpp:61