NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
place.hpp
Go to the documentation of this file.
1
28#pragma once
29
31#include "NumCpp/NdArray.hpp"
32
33namespace nc
34{
35 //============================================================================
36 // Method Description:
46 template<typename dtype>
48 {
49 if (mask.size() != arr.size())
50 {
51 THROW_INVALID_ARGUMENT_ERROR("Input arguments 'arr' and 'mask' must have the same size.");
52 }
53
54 if (vals.isempty())
55 {
56 return;
57 }
58
59 auto valIdx = 0;
60 for (decltype(arr.size()) i = 0; i < arr.size(); ++i)
61 {
62 if (mask[i])
63 {
64 arr[i] = vals[valIdx++ % vals.size()];
65 }
66 }
67 }
68} // namespace nc
#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
Definition Cartesian.hpp:40
void place(NdArray< dtype > &arr, const NdArray< bool > &mask, const NdArray< dtype > &vals)
Definition place.hpp:47
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59