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

bug in setindex! for subarray #4383

Closed
Jutho opened this issue Sep 27, 2013 · 1 comment
Closed

bug in setindex! for subarray #4383

Jutho opened this issue Sep 27, 2013 · 1 comment

Comments

@Jutho
Copy link
Contributor

Jutho commented Sep 27, 2013

I suppose the following should work

A=randn(3,3,3)
As=slice(A,:,1,:)
As[:,:]=randn(3,3)

It gives however an error, apparently because the index translation that happens in the subarray setindex! method does not reshape the 3x3 matrix into a 3x1x3 array.

@ivarne
Copy link
Sponsor Member

ivarne commented Sep 27, 2013

It looks like this issue has been discussed multiple times before #4048 and #3262, but never gotten a solution that everybody is confortable with.

A quick fix would be to do the reshape manually

As[:,:]=reshape(randn(3,3),(3,1,3))

JeffBezanson added a commit that referenced this issue Dec 28, 2013
…#4383

this rule ignores singleton dimensions, and allows the last dimension of
one side to match all trailing dimensions of the other.
JeffBezanson added a commit that referenced this issue Dec 28, 2013
…#4383

this rule ignores singleton dimensions, and allows the last dimension of
one side to match all trailing dimensions of the other.
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

No branches or pull requests

2 participants