-
-
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
abstractarray.jl: hcat/vcat/cat are not sufficiently abstract? #7865
Comments
We have gone back and forth on this a bit. At one point we changed most of the I only see two that do not use block access:
|
It seems to me that the |
As for
Consider what would happen, for instance, if So this is probably an appropriate default implementation for |
The https://github.com/JuliaLang/julia/blob/master/base/abstractarray.jl#L582 |
Ah yes, you're right. I think I just misread. For any Fortran ordering or compressed column storage format, this should work fine. Not so much for compressed row storage or other format that's not optimized for column wise access, but then we're basically back to my more esoteric issue similar to |
Nice. Thanks! |
I just ran into some of these issues and posted about it over on julia-users.
Given the intent to allow
AbstractArray
to be extremely flexible, some of the default implementations seem unnecessarily specialized and potentially very inefficient. For instance, in theory,hcat
andvcat
are justcat(2,...)
andcat(1,...)
, perhaps with some exceptions to handle scalars thrown in. So anAbstractArray
implementation could be nothing but a direct reference tocat
. Instead,hcat
andvcat
(for example) have the following specializations:I can totally understand why these specializations are worthwhile for DenseArray objects. For instance, in the first three of these specalizations, you can take advantage of the fact that with Fortran ordering the input matrices will be laid out sequentially with no interleaving. And indeed, if you look at the implementation of these methods, the implementations are taking advantage of this fact.
But what happens if the concrete matrix uses C ordering, or perhaps some sort of novel/compressed/distributed storage method? These implementations be suboptimal---and not just because of the layout assumption, but also because they use straight for-loops or list comprehensions to move elements one element at a time. Again, for Array objects, those loops are going to be nice and tight when compiled down. But consider how inefficient that is for sparse matrices, for instance.
I would suggest, therefore, that
The text was updated successfully, but these errors were encountered: