NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
split.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <vector>
31 
35 #include "NumCpp/NdArray.hpp"
36 
37 namespace nc
38 {
39  //============================================================================
40  // Method Description:
51  template<typename dtype>
52  std::vector<NdArray<dtype>>
53  split(const NdArray<dtype>& inArray, const NdArray<int32>& indices, Axis inAxis = Axis::ROW)
54  {
55  switch (inAxis)
56  {
57  case Axis::ROW:
58  {
59  return vsplit(inArray, indices);
60  }
61  case Axis::COL:
62  {
63  return hsplit(inArray, indices);
64  }
65  default:
66  {
67  THROW_INVALID_ARGUMENT_ERROR("input inAxis must be either Axis::ROW or Axis::COL");
68  }
69  }
70 
71  return {}; // get rid of compiler warning
72  }
73 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
Definition: Coordinate.hpp:45
std::vector< NdArray< dtype > > split(const NdArray< dtype > &inArray, const NdArray< int32 > &indices, Axis inAxis=Axis::ROW)
Definition: split.hpp:53
std::vector< NdArray< dtype > > vsplit(const NdArray< dtype > &inArray, const NdArray< int32 > &indices)
Definition: vsplit.hpp:49
Axis
Enum To describe an axis.
Definition: Types.hpp:47
std::vector< NdArray< dtype > > hsplit(const NdArray< dtype > &inArray, const NdArray< int32 > &indices)
Definition: hsplit.hpp:49