-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve Strided Arrays interface documentation with "user-defined" example #32560
Comments
I am reading through the manual (it is great! :) ) and this is the first time I got stumped. I don't get it, at all. It says the strides are in memory, but then in the example the strides are in the values. The benefit is not clear at all either. |
What is the URL of that example? |
The link is the one you shared above. I am probably misunderstanding the whole concept tbh (I don't have a CS background). The example is: 1:5 # not strided (there is no storage associated with this array.)
Vector(1:5) # is strided with strides (1,)
A = [1 5; 2 6; 3 7; 4 8] # is strided with strides (1,4)
V = view(A, 1:2, :) # is strided with strides (1,4)
V = view(A, 1:2:3, 1:2) # is strided with strides (2,4)
V = view(A, [1,2,4], :) # is not strided, as the spacing between rows is not fixed. |
The strides documented there are the related to the spacings of elements in memory: |
That example helps a lot! Since the "stride" in values is different from the stride (in memory). Thanks, I finally get it! I think an example where the values have no obvious pattern (e.g. using The other thing I realize now and I was missing is that I think those two changes would go a long way to help people who are seeing this concept for the first time (like me). And then, as you mention, a real example of how this is useful would be good. |
The documentation for
Strided Array
interfaces needs a "user-defined" example.https://docs.julialang.org/en/latest/manual/interfaces/#man-interface-strided-arrays-1
(Updated url: https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-strided-arrays)
The text there says "A typical example of a user-defined strided array is one that wraps a standard Array with additional structure." But the only examples given are pre-existing data types. I made my own attempt at a strided array and it works, but matrix multiplication operations with it seem to be no faster than for a generic
AbstractArray
leaving me wondering what was the benefit of endowing my data type with astrides()
method. Having a "typical example" where addingstrides()
is beneficial would be very useful in the manual, even if just a URL pointing to some package that uses it.This is especially subtle here because "user-defined" might be read as meaning that one can define a subtype of a
StridedArray
, but I found out the hard way that one cannot because it is aUnion
type. (Mentioning that limitation explicitly in the manual would be good.)I realize there is ongoing work to improve the
docstring
here #28144 and to improve the reference section of the manual here #26150.And there are many open topics related to improving the stride interface #30432 JuliaLang/LinearAlgebra.jl#186 and general discussions about the array hierarchy #987.
I am also aware of the Strided.jl package, but its documentation also does not give any examples of user-defined strided arrays, only wrappers around preexisting array types.
I would have submitted PR instead of a new issue if I had a compelling example.
The text was updated successfully, but these errors were encountered: