NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
take.hpp
Go to the documentation of this file.
1
28#pragma once
29
31#include "NumCpp/Core/Types.hpp"
32#include "NumCpp/NdArray.hpp"
33
34namespace nc
35{
36 //============================================================================
37 // Method Description:
47 template<typename dtype, typename Indices, type_traits::ndarray_int_concept<Indices> = 0>
49 {
50 switch (inAxis)
51 {
52 case Axis::NONE:
53 {
54 return inArray[inIndices];
55 }
56 case Axis::ROW:
57 {
58 return inArray(inIndices, inArray.cSlice());
59 }
60 case Axis::COL:
61 {
62 return inArray(inArray.rSlice(), inIndices);
63 }
64 default:
65 {
66 THROW_INVALID_ARGUMENT_ERROR("Unimplemented axis type.");
67 return {}; // get rid of compiler warning
68 }
69 }
70 }
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
Axis
Enum To describe an axis.
Definition Enums.hpp:36
NdArray< dtype > take(const NdArray< dtype > &inArray, const Indices &inIndices, Axis inAxis=Axis::NONE)
Definition take.hpp:48
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59