NumCpp  2.11.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
stack.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <initializer_list>
31 #include <string>
32 #include <vector>
33 
35 #include "NumCpp/Core/Types.hpp"
38 #include "NumCpp/NdArray.hpp"
39 
40 namespace nc
41 {
42  namespace detail
43  {
44  //============================================================================
45  // Method Description:
55  template<typename dtype, typename Iterator>
56  NdArray<dtype> stack(Iterator begin, Iterator end, Axis inAxis)
57  {
58  switch (inAxis)
59  {
60  case Axis::ROW:
61  {
62  return row_stack<dtype>(begin, end);
63  }
64  case Axis::COL:
65  {
66  return column_stack<dtype>(begin, end);
67  }
68  default:
69  {
70  THROW_INVALID_ARGUMENT_ERROR("inAxis must be either ROW or COL.");
71  return {}; // getting rid of compiler warning
72  }
73  }
74  }
75  } // namespace detail
76 
77  //============================================================================
78  // Method Description:
87  template<typename dtype>
88  NdArray<dtype> stack(std::initializer_list<NdArray<dtype>> inArrayList, Axis inAxis = Axis::NONE)
89  {
90  return detail::stack<dtype>(inArrayList.begin(), inArrayList.end(), inAxis);
91  }
92 
93  //============================================================================
94  // Method Description:
103  template<typename dtype>
104  NdArray<dtype> stack(std::vector<NdArray<dtype>> inArrayList, Axis inAxis = Axis::NONE)
105  {
106  return detail::stack<dtype>(inArrayList.begin(), inArrayList.end(), inAxis);
107  }
108 } // 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:138
NdArray< dtype > stack(Iterator begin, Iterator end, Axis inAxis)
Definition: stack.hpp:56
Definition: Cartesian.hpp:40
NdArray< dtype > stack(std::initializer_list< NdArray< dtype >> inArrayList, Axis inAxis=Axis::NONE)
Definition: stack.hpp:88
Axis
Enum To describe an axis.
Definition: Types.hpp:47