[Changeset] Re: Subscripted assignment issue
John W. Eaton
jwe at bevo.che.wisc.edu
Wed Mar 26 14:51:57 CDT 2008
On 26-Mar-2008, David Bateman wrote:
| Ok, here is the updated changeset that also addresses the case
|
| a(1,:,:,:) = reshape(1:4,[1,1,4])
|
| It seems that how matlab handles cases like the above is that
|
| 1) If the number of element defined by the indices on the LHS (colon
| counts as 1) is 1, and
| 2) There are as many colons on the LHS as dimensions on the RHS, then
| 3) Copy the dimensions of the RHS into the colons on the LHS, else
| 4) The vector is assigned in the direction of the first colon.
|
| Note that this is strange as consider
|
| clear a; a(1,:,:,:) = reshape(1:4,[1,1,4])
|
| against
|
| clear a; a(1,:,:,:) = reshape(1:4,[1,4,1])
|
| In the first case it results in a vector along the 4th dimension,
| whereas in the second case the trailing singleton is dropped on the RHS
| before the assignment and therefore the result of the second assignment
| is a row vector.
|
| The changeset implements the above behavior, refactors some of the test
| code to be make it easier to find failing tests and adds additional
| tests. Please rollback my previous changeset before applying this one.
OK. Since I had already applied other cahnges and pushed them to my
public archive, I couldn't easily roll back your previous patch so I
generated a diff with just the additional changes add applied that as
a separate patch to the default branch. I applied the combined
changes to the release-3-0-x branch.
Thanks,
jwe
More information about the Bug-octave
mailing list