Open jonlachmann opened 1 month ago
This was caused by changes made in #767.
A potential solution for this would be to provide checked conversion, see #789.
Checked conversion is computationally heavy and introduces iterations over input vector, unlike any other type conversion we have. I'd suggest to just reinterprer &[i32]
as &[u32]
with optional runtime check. That way the validation tax will clearly be visible in your code.
FYI @CGMossa bedore you merge anything
Checked conversion is computationally heavy and introduces iterations over input vector, unlike any other type conversion we have. I'd suggest to just reinterprer
&[i32]
as&[u32]
with optional runtime check. That way the validation tax will clearly be visible in your code.FYI @CGMossa bedore you merge anything
Thanks. I'm well aware of your concern about semantics and the API. I've made a PR where I have put this conversion somewhere else that seems more appropriate. Please comment there as to what you think.
For what it's worth, I don't think checking one sign-bit is that costly, however, I fully agree that it should not reside in AsTypedSlice
.
In my package I have the following code which takes a dgC-matrix from the Matrix R package and creates a sparse matrix in faer which does not copy the data, but instead creates a reference to it:
This does not work in the latest version of extendr as support for u32 slices was removed. The solution (provided by @CGMossa) is to modify the code as follows, it may not be the best solution in terms of type safety etc. but it works. If it would be possible to provide a full function for handling sparse matrices from Matrix, that would be awesome, as that is probably a not too uncommon use case.