Mercurial > hg > octave-nkf
changeset 10692:b32a0214a464
Use > 1 test to find first non-singleton dimension rather than != 1.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 09 Jun 2010 07:29:33 -0700 |
parents | e0ba186b242b |
children | d95a6e491a6c |
files | scripts/ChangeLog scripts/general/accumdim.m scripts/general/flipdim.m |
diffstat | 3 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,20 +1,26 @@ -2010-06-03 Rik <octave@nomad.inbox5.com> +2010-06-09 Rik <octave@nomad.inbox5.com> + + * general/flipdim.m, general/accumdim.m: Use > 1 test to find + first non-singleton dimension rather than != 1. + +2010-06-08 Rik <octave@nomad.inbox5.com> * general/cumtrapz.m, general/postpad.m, general/prepad.m, general/shift.m, general/trapz.m, signal/unwrap.m: Use common method to find first non-singleton dimension. -2010-06-03 Rik <octave@nomad.inbox5.com> + +2010-06-08 Rik <octave@nomad.inbox5.com> * general/rotdim.m: Modify function to use same variable names as documentation. -2010-06-03 Rik <octave@nomad.inbox5.com> +2010-06-08 Rik <octave@nomad.inbox5.com> * general/cart2pol.m, general/cart2sph.m, general/pol2cart.m, general/sph2cart.m: Add option to operate on column matrix of coordinates. -2010-06-03 Rik <octave@nomad.inbox5.com> +2010-06-08 Rik <octave@nomad.inbox5.com> * general/arrayfun.m, general/cart2pol.m, general/cart2sph.m, general/idivide.m, general/logspace.m, general/sph2cart.m,
--- a/scripts/general/accumdim.m +++ b/scripts/general/accumdim.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} accumdim (@var{subs}, @var{vals}, @var{dim}, @var{sz}, @var{func}, @var{fillval}) +## @deftypefn {Function File} {} accumdim (@var{subs}, @var{vals}, @var{dim}, @var{n}, @var{func}, @var{fillval}) ## Create an array by accumulating the slices of an array into the ## positions defined by their subscripts along a specified dimension. ## The subscripts are defined by the index vector @var{subs}. @@ -63,7 +63,7 @@ endif if (! isvector (subs)) - error ("accumdim: subs must be a subscript vector"); + error ("accumdim: SUBS must be a subscript vector"); elseif (! isindex (subs)) # creates index cache error ("accumdim: indices must be positive integers"); else @@ -71,16 +71,16 @@ if (n == 0) n = m; elseif (n < m) - error ("accumdim: index out of range") + error ("accumdim: N index out of range") endif endif 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"); + error ("accumdim: DIM must be a valid dimension"); elseif (dim > length (sz)) sz(end+1:dim) = 1; endif
--- a/scripts/general/flipdim.m +++ b/scripts/general/flipdim.m @@ -18,9 +18,11 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} flipdim (@var{x}, @var{dim}) +## @deftypefn {Function File} {} flipdim (@var{x}) +## @deftypefnx {Function File} {} flipdim (@var{x}, @var{dim}) ## Return a copy of @var{x} flipped about the dimension @var{dim}. -## For example +## @var{dim} defaults to the first non-singleton dimension. +## For example, ## ## @example ## @group @@ -43,13 +45,13 @@ nd = ndims (x); if (nargin == 1) ## Find the first non-singleton dimension. - dim = find (size (x) != 1, 1); + 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 valid dimension"); + error ("flipdim: DIM must be an integer and a valid dimension"); endif endif