Mercurial > hg > octave-avbm
changeset 4739:7bd3748e2735
[project @ 2004-02-05 18:53:18 by jwe]
author | jwe |
---|---|
date | Thu, 05 Feb 2004 18:53:18 +0000 |
parents | c9e5b9fa7b17 |
children | 65f30438c2a3 |
files | src/ChangeLog src/data.cc |
diffstat | 2 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-02-05 John W. Eaton <jwe@bevo.che.wisc.edu> + + * data.cc (Freshape): Chop trailing singletons from new dimensions. + 2004-02-03 John W. Eaton <jwe@bevo.che.wisc.edu> * error.cc (defun_usage_message): Only accept one arg, a const
--- a/src/data.cc +++ b/src/data.cc @@ -1342,8 +1342,21 @@ return retval; } + // Remove trailing singletons in new_size, but leave at least 2 + // elements. + int n = new_size.length (); + while (n > 2) + { + if (new_size(n-1) == 1) + n--; + else + break; + } + + new_size.resize (n); + if (n < 2) { error ("reshape: expecting size to be vector with at least 2 elements");