50 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
55 const auto arraySize = inArray.
size();
58 [arraySize](
auto& value)
67 auto indices =
unique(inIndices);
69 std::vector<dtype> values;
70 values.reserve(indices.size());
71 for (
int32 i = 0; i < static_cast<int32>(inArray.size()); ++i)
73 if (std::binary_search(indices.begin(), indices.end(), i))
78 values.push_back(inArray[i]);
81 return NdArray<dtype>(values);
92 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
95 const auto arrayRows =
static_cast<int32>(inArray.
numRows());
100 [arrayRows](
auto& value)
109 auto indices =
unique(inIndices);
112 std::for_each(indices.begin(),
114 [arrayRows, &indicesSize](
const auto& value)
116 if constexpr (std::is_signed_v<decltype(value)>)
118 if (value >= 0 && value < arrayRows)
125 if (value < arrayRows)
132 const auto arrayCols =
static_cast<int32>(inArray.numCols());
133 NdArray<dtype> returnArray(arrayRows - indicesSize, arrayCols);
136 for (int32 row = 0; row < arrayRows; ++row)
138 if (std::binary_search(indices.begin(), indices.end(), row))
143 for (int32 col = 0; col < arrayCols; ++col)
145 returnArray(rowCounter, col) = inArray(row, col);
162 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
165 const auto arrayCols =
static_cast<int32>(inArray.
numCols());
170 [arrayCols](
auto& value)
179 auto indices =
unique(inIndices);
182 std::for_each(indices.begin(),
184 [arrayCols, &indicesSize](
const auto& value)
186 if constexpr (std::is_signed_v<decltype(value)>)
188 if (value >= 0 && value < arrayCols)
195 if (value < arrayCols)
202 const auto arrayRows =
static_cast<int32>(inArray.numRows());
203 NdArray<dtype> returnArray(arrayRows, arrayCols - indicesSize);
206 for (int32 col = 0; col < arrayCols; ++col)
208 if (std::binary_search(indices.begin(), indices.end(), col))
213 for (int32 row = 0; row < arrayRows; ++row)
215 returnArray(row, colCounter) = inArray(row, col);
234 template<
typename dtype,
typename Indices, type_traits::ndarray_
int_concept<Indices> = 0>
268 template<
typename dtype>
290 std::vector<int32> indices;
291 for (
auto i = inIndicesSlice.
start; i < inIndicesSlice.
stop; i += inIndicesSlice.
step)
293 indices.push_back(i);
308 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:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
size_type numCols() const noexcept
Definition NdArrayCore.hpp:3541
size_type numRows() const noexcept
Definition NdArrayCore.hpp:3553
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
Definition column_stack.hpp:40
NdArray< dtype > deleteColumnIndices(const NdArray< dtype > &inArray, Indices inIndices)
Definition deleteIndices.hpp:163
NdArray< dtype > deleteRowIndices(const NdArray< dtype > &inArray, Indices inIndices)
Definition deleteIndices.hpp:93
NdArray< dtype > deleteFlatIndices(const NdArray< dtype > &inArray, Indices inIndices)
Definition deleteIndices.hpp:51
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition StlAlgorithms.hpp:226
constexpr bool is_ndarray_signed_int_v
Definition NdArrayCore.hpp:120
Definition Cartesian.hpp:39
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
NdArray< dtype > unique(const NdArray< dtype > &inArray)
Definition unique.hpp:52
std::int32_t int32
Definition Types.hpp:36
NdArray< dtype > deleteIndices(const NdArray< dtype > &inArray, const Indices &inIndices, Axis inAxis=Axis::NONE)
Definition deleteIndices.hpp:235
@ SHELL
Definition Enums.hpp:58
std::uint32_t uint32
Definition Types.hpp:40