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