Closed conradjones closed 2 years ago
I'm seeing different behaviour from NumCpp for Numpy for zeros, is this expected ?
import numpy v = numpy.zeros(8) print(v)
outputs
[0. 0. 0. 0. 0. 0. 0. 0.]
auto w = nc::zeros<float>(len); std::cout << w << "\n";
[[0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ]]
That's correct, see the documentation here.
If you would like a 1D array then you can use either of the other two overloads for zeros() as documented here.
zeros()
auto w = nc::zeros<float>(1, len); // rows and cols size overload
or
auto w = nc::zeros<float>({1, len}); // Shape overload
I'm seeing different behaviour from NumCpp for Numpy for zeros, is this expected ?
import numpy v = numpy.zeros(8) print(v)
outputs
[0. 0. 0. 0. 0. 0. 0. 0.]
auto w = nc::zeros<float>(len); std::cout << w << "\n";
outputs
[[0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ] [0, 0, 0, 0, 0, 0, 0, 0, ]]