49 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
52 const auto numCols =
static_cast<int32>(inArray.
numCols());
56 uniqueIndices.
begin(),
57 [numCols](
auto index) noexcept ->
int32
59 if constexpr (type_traits::is_ndarray_signed_int_v<Indices>)
63 index = std::max(index + numCols, int32{ 0 });
66 if (
static_cast<int32>(index) > numCols - 1)
71 return static_cast<int32>(index);
73 uniqueIndices =
unique(uniqueIndices);
75 std::vector<NdArray<dtype>> splits{};
76 splits.reserve(uniqueIndices.size() + 1);
78 const auto rSlice = inArray.rSlice();
80 for (
const auto index : uniqueIndices)
85 splits.push_back(NdArray<dtype>(Shape(inArray.numRows(), 0)));
90 splits.push_back(inArray(rSlice, Slice(lowerIdx, index)));
96 if (lowerIdx < numCols - 1)
98 splits.push_back(inArray(rSlice, Slice(lowerIdx, numCols)));
102 splits.push_back(inArray(rSlice, -1));
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
size_type numCols() const noexcept
Definition: NdArrayCore.hpp:3465
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775
Definition: Cartesian.hpp:40
std::vector< NdArray< dtype > > hsplit(const NdArray< dtype > &inArray, const Indices &indices)
Definition: hsplit.hpp:50
NdArray< dtype > unique(const NdArray< dtype > &inArray)
Definition: unique.hpp:53
std::int32_t int32
Definition: Types.hpp:36