Mercurial > hg > octave-nkf
changeset 5182:5b361aa47dff
[project @ 2005-03-03 06:21:47 by jwe]
author | jwe |
---|---|
date | Thu, 03 Mar 2005 06:21:47 +0000 |
parents | 41cd70503c72 |
children | cfd451656707 |
files | scripts/general/isequal.m scripts/general/sortrows.m scripts/set/ismember.m scripts/set/setdiff.m scripts/strings/strmatch.m |
diffstat | 5 files changed, 30 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/isequal.m +++ b/scripts/general/isequal.m @@ -17,8 +17,11 @@ ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -## isequal(x1, x2, ...) -## true if all parts of x1, x2, ... are equal +## -*- texinfo -*- +## @deftypefn {Function File} {} isequal (@var{x1}, @var{x2}, @dots{}, @var{xN}) +## Return true if all parts of @var{x1}, @var{x2}, @dots{}, @var{xN} are +## equal. +## @end deftypefn ## Author: Paul Kienzle ## Adapted-by: jwe
--- a/scripts/general/sortrows.m +++ b/scripts/general/sortrows.m @@ -17,15 +17,12 @@ ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -## B = sortrows (A) -## returns matrix with rows sorted "lexicographically" -## -## B = sortrows(A, c) -## returns matrix with rows sorted according to the order of the -## columns specified in c. -## -## Set implicit_str_to_num_ok and implicit_num_to_str_ok to 1 if you -## use this for string sorting and octave 2.1.50 or earlier. +## -*- texinfo -*- +## @deftypefn {Function File} {} sortrows (@var{a}, @var{c}) +## Sort the rows of the matrix @var{a} according to the order of the +## columns specified in @var{c}. If @var{c} is omitted, a +## lexicographical sort is used. +## @end deftypefn ## Author: Daniel Calvelo, Paul Kienzle ## Adapted-by: jwe
--- a/scripts/set/ismember.m +++ b/scripts/set/ismember.m @@ -18,11 +18,9 @@ ## 02111-1307, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} ismember(@var{A}, @var{S}) -## +## @deftypefn {Function File} {} ismember (@var{A}, @var{S}) ## Return a matrix the same shape as @var{A} which has 1 if ## @code{A(i,j)} is in @var{S} or 0 if it isn't. -## ## @end deftypefn ## @seealso{unique, union, intersect, setxor, setdiff}
--- a/scripts/set/setdiff.m +++ b/scripts/set/setdiff.m @@ -18,12 +18,10 @@ ## 02111-1307, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} setdiff(@var{a}, @var{b}) -## -## Return the elements in @var{a} but not in @var{b}, sorted in ascending -## order. If @var{a} and @var{b} are both column vectors return a column -## vector, otherwise return a row vector. -## +## @deftypefn {Function File} {} setdiff (@var{a}, @var{b}) +## Return the elements in @var{a} but not in @var{b}, sorted in +## ascending order. If @var{a} and @var{b} are both column vectors +## return a column vector, otherwise return a row vector. ## @end deftypefn ## @seealso{unique, union, intersect, setxor, ismember} @@ -38,13 +36,13 @@ c = unique (a); if (! isempty (c) && ! isempty (b)) - ## form a and b into combined set + ## Form a and b into combined set. b = unique (b); [dummy, idx] = sort ([c(:); b(:)]); - ## eliminate those elements of a that are the same as in b + ## Eliminate those elements of a that are the same as in b. n = length (dummy); c(idx(find (dummy(1:n-1) == dummy(2:n)))) = []; - ## reshape if necessary + ## Reshape if necessary. if (size (c, 1) != 1 && size (b, 1) == 1) c = c.'; endif
--- a/scripts/strings/strmatch.m +++ b/scripts/strings/strmatch.m @@ -18,11 +18,14 @@ ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -## usage: strmatch(s, A [, 'exact']) -## Determines which entries of A match string s. A can be a string matrix -## or a cell array of strings. If 'exact' is not given, then s only needs -## to match A up to the length of s. Null characters match blanks. -## Results are returned as a column vector. +## -*- texinfo -*- +## @deftypefn {Function File} {} strmatch (@var{s}, @var{a}, "exact") +## Return true for entries of @var{a} that match the string @var{s}. +## The second argument @var{a} may be a string matrix or a cell array of +## strings. If the third argument @code{"exact"} is not given, then +## @var{s} only needs to match @var{a} up to the length of @var{s}. Nul +## characters match blanks. Results are returned as a column vector. +## @end deftypefn ## Author: Paul Kienzle, Alois Schloegl ## Adapted-by: jwe @@ -40,12 +43,12 @@ if (nargin > 2) for k = 1:nel match(k) = strcmp (s, A{k}); - end + endfor else for k = 1:nel match(k) = strncmp (s, A{k}, length (s)); - end - end + endfor + endif idx = find (match); elseif (length (s) > nc) idx = [];