-
I get leading zeros in arrays once they are returned to Python, and I know that these errant zeros don't exist on the C++ side (at least where I print out the vector elements). m.def(
"eigh",
[](slate::HermitianMatrix<double> &A)
{
std::vector<blas::real_type<double>> eps(A.m());
slate::heev(A, eps);
auto rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0){
for(auto i = 0; i < eps.size(); i++) {
std::cout << i << " " << eps[i] << std::endl;
if (i > 5)
break;
}
}
auto size = eps.size();
size_t shape[1] = {size};
return nb::ndarray<nb::numpy, double, nb::shape<nb::any>>(eps.data(), 1, shape);
}
// nb::rv_policy::copy
); This is what code looks like on the C++ side of things. I've included the full code snippet here since the last time I omitted things, the omitted details turned out to be important... On running this from the python side, here is approximately the pattern of error I see:
The I've been trying to sort this out for the past few days by looking at the docs and trying to see if I've missed anything, and I've not made much progress. Any help or pointers to specfic parts of the docs that may be helpful with this is greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Please read the nd-array documentation carefully with respect to the |
Beta Was this translation helpful? Give feedback.
Hi,
I've had a look at the documentation and have written up a potential solution. However the solution 'looks not great' which is my best feeling about it. I understand that this is an aesthetic/best practices question, with potentially no obvious right answer.