NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
stack.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <initializer_list>
31#include <vector>
32
36#include "NumCpp/NdArray.hpp"
37
38namespace nc
39{
40 namespace detail
41 {
42 //============================================================================
43 // Method Description:
53 template<typename dtype, typename Iterator>
54 NdArray<dtype> stack(Iterator begin, Iterator end, Axis inAxis)
55 {
56 switch (inAxis)
57 {
58 case Axis::ROW:
59 {
60 return row_stack<dtype>(begin, end);
61 }
62 case Axis::COL:
63 {
64 return column_stack<dtype>(begin, end);
65 }
66 default:
67 {
68 THROW_INVALID_ARGUMENT_ERROR("inAxis must be either ROW or COL.");
69 return {}; // getting rid of compiler warning
70 }
71 }
72 }
73 } // namespace detail
74
75 //============================================================================
76 // Method Description:
85 template<typename dtype>
86 NdArray<dtype> stack(std::initializer_list<NdArray<dtype>> inArrayList, Axis inAxis = Axis::NONE)
87 {
88 return detail::stack<dtype>(inArrayList.begin(), inArrayList.end(), inAxis);
89 }
90
91 //============================================================================
92 // Method Description:
101 template<typename dtype>
102 NdArray<dtype> stack(std::vector<NdArray<dtype>> inArrayList, Axis inAxis = Axis::NONE)
103 {
104 return detail::stack<dtype>(inArrayList.begin(), inArrayList.end(), inAxis);
105 }
106} // 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:135
Definition column_stack.hpp:40
NdArray< dtype > stack(Iterator begin, Iterator end, Axis inAxis)
Definition stack.hpp:54
NdArray< dtype > row_stack(Iterator begin, Iterator end)
Definition row_stack.hpp:52
NdArray< dtype > column_stack(Iterator begin, Iterator end)
Definition column_stack.hpp:52
Definition Cartesian.hpp:39
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
NdArray< dtype > stack(std::initializer_list< NdArray< dtype > > inArrayList, Axis inAxis=Axis::NONE)
Definition stack.hpp:86