Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayView implementation #36

Open
JErnestoMtz opened this issue Jun 14, 2023 · 1 comment
Open

ArrayView implementation #36

JErnestoMtz opened this issue Jun 14, 2023 · 1 comment

Comments

@JErnestoMtz
Copy link
Owner

I really wanted to avoid implementing ArrayView for Ndarr due to the unavoidable unsafe code. But at the end of the day it is a well tested strategy, and it will help a lot to improve the performance of many operations. But most importantly, if we want to eventually implement mutable slicing, I think there is no other way.

The idea of an ArrayView as far as I understand it, is sort of a reference to a Ndarr. It holds a pointer to the beginning of the Ndarr data, the shape and stride that can be calculated with the shape itself.

struct ArrayView<'a, T, R: Unsigned> {
    data: *const T,
    shape: Dim<R>,
    strides: Vec<usize>,
    _phantom: PhantomData<&'a T>,
}
@DeliciousHair
Copy link
Contributor

unsafe is fine, just need to make sure the API to it is safe :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants