# HG changeset patch # User jwe # Date 1158027818 0 # Node ID 82a73f5dadd90ad6b8439ea81dd21c13d54d9db5 # Parent ae09df27153f1ff0c4818b4c3004c0952b24a1bf [project @ 2006-09-12 02:23:37 by jwe] diff -r ae09df27153f -r 82a73f5dadd9 scripts/ChangeLog --- a/scripts/ChangeLog Tue Sep 12 02:15:47 2006 +0000 +++ b/scripts/ChangeLog Tue Sep 12 02:23:38 2006 +0000 @@ -1,3 +1,7 @@ +2006-09-11 Luis F. Ortiz + + * general/shiftdim.m: Use permute instead of reshape. + 2006-09-05 Alexander Barth * miscellaneous/parseparams.m: New function. diff -r ae09df27153f -r 82a73f5dadd9 scripts/general/shiftdim.m --- a/scripts/general/shiftdim.m Tue Sep 12 02:15:47 2006 +0000 +++ b/scripts/general/shiftdim.m Tue Sep 12 02:23:38 2006 +0000 @@ -37,9 +37,9 @@ ## @group ## x = ones (1, 2, 3); ## size (shiftdim (x, -1)) -## @result{} [2, 3, 1] +## @result{} [1, 1, 2, 3] ## size (shiftdim (x, 1)) -## @result{} [1, 1, 2, 3] +## @result{} [2, 3] ## [b, ns] = shiftdim (x); ## @result{} b = [1, 1, 1; 1, 1, 1] ## @result{} ns = 1 @@ -77,7 +77,9 @@ singleton_dims = ones (1, -n); y = reshape (x, [singleton_dims, orig_dims]); elseif (n > 0) - y = reshape (x, [orig_dims(n+1:nd), orig_dims(1:n)]); + ## We need permute here instead of reshape to shift values in a + ## compatible way. + y = permute (x, [n+1:ndims(x) 1:n]); else y = x; endif