-
-
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
Array docs: Clarify DenseArray vs. "strided" #26085
Conversation
Dense Arrays absolutely must be contiguously arranged in memory. This attempts to make documentation match the current reality.
Cc: @dlfivefifty — since you wrote the strided array interface section I think it'd be nice to get your eyes on this. |
doc/src/manual/arrays.md
Outdated
to call a wider range of BLAS and LAPACK functions by passing them either [`Array`](@ref) or | ||
`SubArray` objects, and thus saving inefficiencies from memory allocation and copying. | ||
A "strided" array is stored in memory and has its elements are laid out in regular offsets such that | ||
it can be passed to external C and Fortran functions that expect this memory layout. Strided arrays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... such that an instance with an isbitstype
eltype can be passed ...?
I think it should be renamed |
Yeah, we can tackle a renaming separately. This is just aiming to get the documentation correct. |
We can tackle more general definitions later.
doc/src/manual/arrays.md
Outdated
`StridedVector` and `StridedMatrix` are convenient aliases defined to make it possible for Julia | ||
to call a wider range of BLAS and LAPACK functions by passing them either [`Array`](@ref) or | ||
`SubArray` objects, and thus saving inefficiencies from memory allocation and copying. | ||
A "strided" array is stored in memory and has its elements are laid out in regular offsets such that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be either "and has its elements laid out" or "and its elements are laid out".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you!
The reason I think it should be renamed is that it actually changes the meaning of |
must define a [`strides(A)`](@ref) method that returns a tuple of "strides" for each dimension; a | ||
provided [`stride(A,k)`](@ref) method accesses the `k`th element within this tuple. Increasing the | ||
index of dimension `k` by `1` should increase the index `i` of [`getindex(A,i)`](@ref) by | ||
[`stride(A,k)`](@ref). If a pointer conversion method [`Base.unsafe_convert(Ptr{T}, A)`](@ref) is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true? Is getindex(A,i)
a way to directly access elements based on offsets from stride calculations, or is it really still linear indexing that assumes getindex(A,i_1,i_2,...) == getindex(A, i_1 + size(A,1)*(i_2-1) + ...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, you're right, thank you. getindex
is totally and completely decoupled from strides.
I just came across this "clarification" PR. I agree with @dlfivefifty that it is a change in meaning rather than a clarification. The previous meaning (which was initially slated to be called The new meaning still works for all the |
I’m not sure which change started changing the meaning here, but it wasn’t this one. I believe the problem was that all the Base DenseArrays happened to be contiguous, and so it just gradually became the expectation. |
Oh, yeah, this actually started with me trying to reclaim the meaning of There are lots of things you can drag me for from 6 years ago — I have plenty of other regrets that my own brain won't let me forget. I don't think this one needs to be added to that pile. |
Dense Arrays absolutely must be contiguously arranged in memory. This attempts to make documentation match the current reality.