[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
permute doesn't delete singletons
From: |
John W. Eaton |
Subject: |
permute doesn't delete singletons |
Date: |
Thu, 5 May 2005 13:27:05 -0400 |
On 5-May-2005, Tom Holroyd wrote:
| Trailing singleton dimensions are automatically removed, right? Like,
|
| octave:67> x=zeros(10,3,1);
| octave:68> size(x)
| ans =
|
| 10 3
|
| But if I do:
|
| octave:75> x=zeros(10,1,2);
| octave:76> z=permute(x,[3,1,2]);
| octave:77> size(z)
| ans =
|
| 2 10 1
|
| I get a result with a trailing singleton dimension. I'm porting some
| MATLAB code that expects the result of permute above to be size 2 10,
| which it is under MATLAB. Can permute be changed to remove the
| singleton dimension?
Please try the following patch.
Thanks,
jwe
liboctave/ChangeLog:
2005-05-05 John W. Eaton <address@hidden>
* Array.cc (Array<T>::permute): Call chop_trailing_singletons on
retval before return.
Index: liboctave/Array.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/liboctave/Array.cc,v
retrieving revision 1.124.2.6
diff -u -r1.124.2.6 Array.cc
--- liboctave/Array.cc 5 May 2005 16:25:02 -0000 1.124.2.6
+++ liboctave/Array.cc 5 May 2005 17:19:06 -0000
@@ -488,6 +488,8 @@
increment_index (old_idx, dv);
}
+ retval.chop_trailing_singletons ();
+
return retval;
}
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------