changeset 5984:82a73f5dadd9

[project @ 2006-09-12 02:23:37 by jwe]
author jwe
date Tue, 12 Sep 2006 02:23:38 +0000
parents ae09df27153f
children 5f662c1cfbbe
files scripts/ChangeLog scripts/general/shiftdim.m
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2006-09-11  Luis F. Ortiz  <lortiz@interactivesupercomputing.com>
+
+	* general/shiftdim.m: Use permute instead of reshape.
+
 2006-09-05  Alexander Barth  <abarth93@users.sourceforge.net>
 
 	* miscellaneous/parseparams.m: New function.
--- a/scripts/general/shiftdim.m
+++ b/scripts/general/shiftdim.m
@@ -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