Skip to content
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

multi-dimensional indexing question #111

Closed
rsc opened this issue May 9, 2022 · 3 comments · Fixed by #112
Closed

multi-dimensional indexing question #111

rsc opened this issue May 9, 2022 · 3 comments · Fixed by #112

Comments

@rsc
Copy link
Contributor

rsc commented May 9, 2022

Originally posted by @fumin in #28 (comment):

Why does (5 5 rho iota 25)[3 2; 1 2 3] return the following?

11 12
13  6
 7  8

I was expecting

11 12 13 
6 7  8

which is also what's returned by https://tryapl.org/ with the expression (5 5 ⍴ ⍳ 25)[3 2; 1 2 3].

Below is my investigation
(5 5 rho iota 25)[3 2; 1]
11 6

(5 5 rho iota 25)[3 2; 1 2]
11 12
 6  7

(5 5 rho iota 25)[3 2; 1 2 3]
11 12
13  6
 7  8
@rsc
Copy link
Contributor Author

rsc commented May 9, 2022

Definitely a bug. Will look into a fix.

rsc added a commit to rsc/ivy that referenced this issue May 9, 2022
The right-to-left evaluation order for indexes was causing the
accumulation of the shape to end up reversed. Fix that by doing
an additional reverse after the loop.

Fixes robpike#111.
rsc added a commit to rsc/ivy that referenced this issue May 9, 2022
The right-to-left evaluation order for indexes was causing the
accumulation of the shape to end up reversed. Fix that by doing
an additional reverse after the loop.

Fixes robpike#111.
@rsc
Copy link
Contributor Author

rsc commented May 9, 2022

Sent #112 with a fix.

@fumin
Copy link

fumin commented May 10, 2022

Thanks @rsc , I confirm #112 works for all the variants I can think of.
It's also good to see the internals of ivy in this change in action, enlightening! : )

robpike pushed a commit that referenced this issue May 10, 2022
The right-to-left evaluation order for indexes was causing the
accumulation of the shape to end up reversed. Fix that by doing
an additional reverse after the loop.

Fixes #111.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants