47 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
50 const auto numRows =
static_cast<int32>(inArray.
numRows());
54 uniqueIndices.
begin(),
55 [numRows](
auto index) noexcept ->
int32
57 if constexpr (type_traits::is_ndarray_signed_int_v<Indices>)
61 index = std::max(index + numRows, int32{ 0 });
64 if (index > numRows - 1)
69 return static_cast<int32>(index);
71 uniqueIndices =
unique(uniqueIndices);
73 std::vector<NdArray<dtype>> splits{};
74 splits.reserve(uniqueIndices.size() + 1);
76 const auto cSlice = inArray.cSlice();
78 for (
const auto index : uniqueIndices)
87 splits.push_back(inArray(
Slice(lowerIdx, index), cSlice));
93 if (lowerIdx < numRows - 1)
95 splits.push_back(inArray(
Slice(lowerIdx, numRows), cSlice));
99 splits.push_back(inArray(-1, cSlice));
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
size_type numRows() const noexcept
Definition NdArrayCore.hpp:3553
iterator begin() noexcept
Definition NdArrayCore.hpp:1311
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
A Class for slicing into NdArrays.
Definition Slice.hpp:45
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:776
Definition Cartesian.hpp:39
NdArray< dtype > unique(const NdArray< dtype > &inArray)
Definition unique.hpp:52
std::int32_t int32
Definition Types.hpp:36
std::vector< NdArray< dtype > > vsplit(const NdArray< dtype > &inArray, const Indices &indices)
Definition vsplit.hpp:48