52 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
55 if constexpr (type_traits::is_ndarray_signed_int_v<Indices>)
57 const auto arraySize = inArray.
size();
60 [arraySize](
auto& value)
69 auto indices =
unique(inIndices);
71 std::vector<dtype> values;
72 values.reserve(indices.size());
73 for (
int32 i = 0; i < static_cast<int32>(inArray.size()); ++i)
75 if (std::binary_search(indices.begin(), indices.end(), i))
80 values.push_back(inArray[i]);
83 return NdArray<dtype>(values);
94 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
97 const auto arrayRows =
static_cast<int32>(inArray.
numRows());
98 if constexpr (type_traits::is_ndarray_signed_int_v<Indices>)
102 [arrayRows](
auto& value)
111 auto indices =
unique(inIndices);
116 [arrayRows, &indicesSize](
const auto& value)
118 if constexpr (std::is_signed_v<decltype(value)>)
120 if (value >= 0 && value < arrayRows)
127 if (value < arrayRows)
134 const auto arrayCols =
static_cast<int32>(inArray.numCols());
135 NdArray<dtype> returnArray(arrayRows - indicesSize, arrayCols);
138 for (
int32 row = 0; row < arrayRows; ++row)
140 if (std::binary_search(indices.begin(), indices.end(), row))
145 for (
int32 col = 0; col < arrayCols; ++col)
147 returnArray(rowCounter, col) = inArray(row, col);
164 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
167 const auto arrayCols =
static_cast<int32>(inArray.
numCols());
168 if constexpr (type_traits::is_ndarray_signed_int_v<Indices>)
172 [arrayCols](
auto& value)
181 auto indices =
unique(inIndices);
186 [arrayCols, &indicesSize](
const auto& value)
188 if constexpr (std::is_signed_v<decltype(value)>)
190 if (value >= 0 && value < arrayCols)
197 if (value < arrayCols)
204 const auto arrayRows =
static_cast<int32>(inArray.numRows());
205 NdArray<dtype> returnArray(arrayRows, arrayCols - indicesSize);
208 for (
int32 col = 0; col < arrayCols; ++col)
210 if (std::binary_search(indices.begin(), indices.end(), col))
215 for (
int32 row = 0; row < arrayRows; ++row)
217 returnArray(row, colCounter) = inArray(row, col);
236 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
270 template<
typename dtype>
292 std::vector<int32> indices;
293 for (
auto i = inIndicesSlice.
start; i < inIndicesSlice.
stop; i += inIndicesSlice.
step)
295 indices.push_back(i);
310 template<
typename dtype>
#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
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
size_type numCols() const noexcept
Definition: NdArrayCore.hpp:3465
size_type numRows() const noexcept
Definition: NdArrayCore.hpp:3477
A Class for slicing into NdArrays.
Definition: Slice.hpp:45
int32 step
Definition: Slice.hpp:50
int32 start
Definition: Slice.hpp:48
void makePositiveAndValidate(uint32 inArraySize)
Definition: Slice.hpp:142
int32 stop
Definition: Slice.hpp:49
NdArray< dtype > deleteColumnIndices(const NdArray< dtype > &inArray, Indices inIndices)
Definition: deleteIndices.hpp:165
NdArray< dtype > deleteRowIndices(const NdArray< dtype > &inArray, Indices inIndices)
Definition: deleteIndices.hpp:95
NdArray< dtype > deleteFlatIndices(const NdArray< dtype > &inArray, Indices inIndices)
Definition: deleteIndices.hpp:53
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:225
Definition: Cartesian.hpp:40
NdArray< dtype > deleteIndices(const NdArray< dtype > &inArray, int32 inIndex, Axis inAxis=Axis::NONE)
Definition: deleteIndices.hpp:311
Axis
Enum To describe an axis.
Definition: Enums.hpp:36
NdArray< dtype > unique(const NdArray< dtype > &inArray)
Definition: unique.hpp:53
std::int32_t int32
Definition: Types.hpp:36
std::uint32_t uint32
Definition: Types.hpp:40