-
Notifications
You must be signed in to change notification settings - Fork 17
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
Additional functionality for offsets in index expressions #6 #12
base: master
Are you sure you want to change the base?
Conversation
I would be happy to add documentation and tests. |
Actually, I think this convention for determining the allocation size is still not quite clean, let me think about it a little more. |
Documentation for the offsets would be greatly appreciated! |
Yes, I agree. Cross-referencing from your examples in #6 (comment) I think I would prefer: X = randn(10)
@einsum A[i] := X[i-5]
@test size(A) == (5,)
@test all(A .== X[6:end]) Does that make sense? Thanks so much for catching my oversights! |
Hey Alex, that would be an option but then there would be a marked difference between the behavior of a pre-allocated array (in which case I don't think we should shift the LHS indices) and a non-pre-allocated array. |
What are the desired rules for pre-allocated arrays? B = collect(1:10)
# produce errors?
A = zeros(5)
@einsum A[i] = B[i+5]
@einsum A[i] = B[i-5]
# legal?
A = zeros(10)
@einsum A[i] = B[i+5]
A == [6, 7, 8, 9, 10, 0, 0, 0, 0, 0]
A = zeros(10)
@einsum A[i] = B[i-5]
A == [0, 0, 0, 0, 0, 1, 2, 3, 4, 5] If this is the case, then I guess it would make sense to allocate Side note. This is silly, but would be kind of cool to support this: B = collect(1:10)
A = zeros(10)
@einsum A[i] = B[i>>5]
A == [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
@einsum A[i] = B[i<<2]
A == [3, 4, 5, 6, 7, 8, 9, 10, 1, 2] |
In case someone is watching this: index shifts of the form |
This introduces additional capabilities for handling multiple different offsets for RHS index expressions as well as a modified convention for un-allocated negative indices.