Mercurial > hg > octave-terminal
changeset 10790:01f1643dfbb1
fix flipdim with trailing singleton dims
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 15 Jul 2010 12:15:14 +0200 |
parents | 6f640ed5bb93 |
children | 3140cb7a05a1 |
files | scripts/ChangeLog scripts/general/accumdim.m scripts/general/flipdim.m |
diffstat | 3 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-07-15 Jaroslav Hajek <highegg@gmail.com> + + * general/flipdim.m: Suuport flipping about trailing singleton + dimension. + 2010-07-14 Ben Abbott <bpabbott@mac.com> * plot/__gnuplot_print__.m: Fix broken options "-orientation",
--- a/scripts/general/accumdim.m +++ b/scripts/general/accumdim.m @@ -78,7 +78,7 @@ sz = size (val); if (nargin < 3) - [~, dim] = max (sz > 1); # first non-singleton dim + [~, dim] = max (sz != 1); # first non-singleton dim elseif (! isindex (dim)) error ("accumdim: DIM must be a valid dimension"); elseif (dim > length (sz))
--- a/scripts/general/flipdim.m +++ b/scripts/general/flipdim.m @@ -45,17 +45,12 @@ nd = ndims (x); if (nargin == 1) ## Find the first non-singleton dimension. - dim = find (size (x) > 1, 1); - if (isempty (dim)) - dim = 1; - endif - else - if (! (isscalar (dim) && isindex (dim, nd))) - error ("flipdim: DIM must be an integer and a valid dimension"); - endif + [~, dim] = min (size (x) != 1); + elseif (! (isscalar (dim) && isindex (dim))) + error ("flipdim: DIM must be a positive integer"); endif - idx(1:nd) = {':'}; + idx(1:max(nd, dim)) = {':'}; idx{dim} = size (x, dim):-1:1; y = x(idx{:});