-
-
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
RFC: Drop dimensions indexed by scalars #13612
Conversation
AppVeyor failure looks like #9572. |
@@ -121,7 +121,10 @@ function A_ldiv_B!{T}(D::Diagonal{T}, V::AbstractMatrix{T}) | |||
if d == zero(T) | |||
throw(SingularException(i)) | |||
end | |||
V[i,:] *= inv(d) | |||
d⁻¹ = inv(d) |
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.
Very cute
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.
🐨
@mbauman Would you rebase this one. I think we should consider merging this soon such that people will start using it. |
Done. |
Thanks for keeping it rolling here |
Okay to merge this? |
Sure, let's give it a shot. |
Sorry I've not had time to review this. Looks fine to me. As you noted, it depends on a lot more splatting (esp in checksize), but all that is O(1) and not O(N) in the array elements. So I'm fine with seeing how it goes (and it might be further incentive to fix the splatting penalty), though if you've run any benchmarks it might be interesting to learn more about any performance hits. |
RFC: Drop dimensions indexed by scalars
Should we also drop the scalar dimension for This breaks the equivalence between julia> a = rand(2, 2)
2x2 Array{Float64,2}:
0.377862 0.85667
0.0177678 0.695366
julia> a[2, 1:2] == sub(a, 2, 1:2)
false |
|
Are there plans to adapt |
In JuliaLang#13612 I converted checksize from a generated function to a recursive lispy definition, but the methods are too complicated to be automatically inlined. Manually adding the inline annotation fixes this performance regression JuliaLang#14594. Master is now faster than 0.4.0 on most of the array perf tests.
I don't think it has been discussed. Can you explain further? |
Currently, Line 1217 in dc5c974
|
I'm not sure I agree that those two design decisions are coupled. Meaning, I don't think it's inconsistent for It's so common to say Xnorm = X ./ maximum(X, 2) that it would be a shame to make that any harder. (And dropping dimensions definitely does make that harder.) When you want to drop the dimensions, it's easier than ever to do so. |
I agree – I would prefer that reductions keep reduced dimensions for exactly this reason. |
I kind of agree for the monadic case, for a dyadic mapslices function the current scheme does not translate well. I now recall why I noted this, I have even RFC #13317 but I forgot about it. Maybe someone could comment there? Some feedback would be appreciated. |
I think this should be moved to the "Breaking Changes" part of the NEWS file. This just caused silently incorrect results in one of my packages (Hadamard.jl) |
that have non-Int indices, introduced by #13612 and which has caused `make -C test/perf` to fail for the last 9 months searchsortedfirst does not have methods for general Integer indices
that have non-Int indices, introduced by #13612 and which has caused `make -C test/perf` to fail for the last 9 months searchsortedfirst does not have methods for general Integer indices
Hello, For Is there a dimkeepingtype(x) = false
dimkeepingtype(x::Vector) = true
dimkeepingtype(x::Range) = true
dimkeepingtype(x::BitVector) = true that tells me if an index type |
Can't you add the missing |
Thanks. But I do not really understand the logic in Somewhat related, I saw that in Julia-0.5 the dimension of a sliced array is the sum of the dimensions of the indices. That is great, but I don't really know yet how to come up with dimension and index names, with cases like |
I don't know about precedence in other languages, but perhaps you can take some inspiration from AxisArrays:
|
Thanks, that is indeed a useful way of naming the dimensions. For the names of the indexes along the dimensions, though, things are more complicated. I think I will opt for copying the names of the indexes of the indexing array (if this has Further challenges will occur when indexing a |
that have non-Int indices, introduced by JuliaLang#13612 and which has caused `make -C test/perf` to fail for the last 9 months searchsortedfirst does not have methods for general Integer indices
This is the first step towards APL indexing semantics. It does not yet allow indexing with multiple multi-dimensional arrays (the new feature with the catchy "rank of the result is the sum of the rank of the indices" semantic); it simply drops all scalar dimensions (a major breaking change).
There is an interesting interaction between these array semantics and transposes that I didn't fully appreciate until looking at this more in-depth. The tricky part about APL indexing is that it loses the orientation of row vectors, and so we can no longer define complex matrix multiplication in terms of slices directly:
A[1,:] * B[:,1]
an illegal(n,) × (n,)
operation.dot(A[1,:], B[:,1])
andA[1,:]' * B[:,1]
erroneously conjugate the row.Working with complex row slices becomes a little dicier. When do you conjugate? Or (c)transpose?
Fortunately, the behavior here is a strict superset of our current indexing rules. You can explicitly request that the shapes of the slices be maintained in both dimensions:
A[1:1,:] * B[:,1:1]
if you wish to use the result as a linear algebra construct.