You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a method for initializing a NumPy array with zero values, passing its reference to another function, and then returning the results?
This is the code I'm working on; however, I'm not sure if it's correct:
#include<pybind11/pybind11.h>
#include<pybind11/numpy.h>
#include"foo2.h"namespacepy= pybind11;
py::array_t<double> foo1(py::array_t<double, py::array::c_style | py::array::forcecast> signal)
{
// Accessing the data pointer of the input numpy arrayauto signal_data = signal.mutable_data(); // Mutable (non-const) pointer to the data of the NumPy array// Initialize output array and data pointersauto output = py::array_t<double>(signal.size());
output[py::make_tuple(py::ellipsis())] = 0.0; // Set all values of the array to zeroauto output_data = output.mutable_data();
// Running another functionfoo2(signal_data, output_data);
return output;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
Is there a method for initializing a NumPy array with zero values, passing its reference to another function, and then returning the results?
This is the code I'm working on; however, I'm not sure if it's correct:
Does this approach make sense?
Thank you,
Beta Was this translation helpful? Give feedback.
All reactions