48 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
51 const auto numRows =
static_cast<int32>(inArray.
numRows());
55 uniqueIndices.
begin(),
56 [numRows](
auto index) noexcept ->
int32
58 if constexpr (type_traits::is_ndarray_signed_int_v<Indices>)
62 index = std::max(index + numRows, int32{ 0 });
65 if (index > numRows - 1)
70 return static_cast<int32>(index);
72 uniqueIndices =
unique(uniqueIndices);
74 std::vector<NdArray<dtype>> splits{};
75 splits.reserve(uniqueIndices.size() + 1);
77 const auto cSlice = inArray.cSlice();
79 for (
const auto index : uniqueIndices)
83 splits.push_back(NdArray<dtype>(Shape(0, inArray.numCols())));
88 splits.push_back(inArray(Slice(lowerIdx, index), cSlice));
94 if (lowerIdx < numRows - 1)
96 splits.push_back(inArray(Slice(lowerIdx, numRows), cSlice));
100 splits.push_back(inArray(-1, cSlice));
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
size_type numRows() const noexcept
Definition: NdArrayCore.hpp:3477
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
NdArray< dtype > unique(const NdArray< dtype > &inArray)
Definition: unique.hpp:53
std::int32_t int32
Definition: Types.hpp:36
std::vector< NdArray< dtype > > vsplit(const NdArray< dtype > &inArray, const Indices &indices)
Definition: vsplit.hpp:49