-
-
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
Support pointer(A::PermDimsArray) if parent(A) supports it #20385
Conversation
Don't you also need |
0ae10c0
to
c1d04f7
Compare
It seems like we have to have However, if you're calling a C routine that wants one memory layout and Julia wants a different one, you will likely want to pass the C routine function foo{T}(::Type{T}, width, height)
A = Matrix{T}(width, height) # not height, width
ccall(:fill_matrix, Void, (blah blah), A, strides(A))
PermutedDimsArray(A, (2,1))
end You wouldn't want to pass |
@timholy, if you have a C routine that accepts a pointer and sizes and strides, surely you would want the permuted strides if you are passing the permuted dims? e.g. suppose you have # call C function: void init_matrix(double*a, int n1, int n2, int stride1, int stride2)
init_matrix!(M::AbstractMatrix{Cdouble}) =
ccall(:init_matrix, Void, (Ptr{Cdouble},Cint,Cint,Cint,Cint), M, size(M)..., strides(M)...) and then you want to pass
|
Yes, all that's fine. But if the C code is flexible enough to accept general strides, I don't understand why you wouldn't want to use an In any event, this already implements all of your list except |
c1d04f7
to
2bc83ca
Compare
@timholy, I was thinking of generic code that accepts any AbstractArray, and you happen to have a permuted-dims array for some other reason that you want to pass. |
Useful for wrapping certain C routines, where the storage order differs from Julia's.