Mercurial > hg > octave-lyh
annotate scripts/deprecated/create_set.m @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 0c7b0049c023 |
children | be55736a0783 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1994, 1996, 1997, 1999, 2000, 2004, 2005, 2006, 2007, |
2 ## 2008, 2009 John W. Eaton | |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
2303 | 19 |
3368 | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} create_set (@var{x}) | |
7344 | 22 ## @deftypefnx{Function File} {} create_set (@var{x}, "rows") |
8887 | 23 ## This function has been deprecated. Use unique instead. |
24 ## @end deftypefn | |
25 | |
3368 | 26 ## Return a row vector containing the unique values in @var{x}, sorted in |
27 ## ascending order. For example, | |
3426 | 28 ## |
3368 | 29 ## @example |
30 ## @group | |
7344 | 31 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ]) |
3368 | 32 ## @result{} [ 1, 2, 3, 4 ] |
33 ## @end group | |
34 ## @end example | |
7344 | 35 ## |
36 ## If the optional second input argument is the string "rows" each row of | |
37 ## the matrix @var{x} will be considered an element of set. For example, | |
38 ## @example | |
39 ## @group | |
40 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ], "rows") | |
41 ## @result{} 1 2 | |
42 ## 3 4 | |
43 ## 4 2 | |
44 ## @end group | |
45 ## @end example | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7411
diff
changeset
|
46 ## @seealso{union, intersect, complement, unique} |
3368 | 47 |
2314 | 48 ## Author: jwe |
49 | |
8888
0c7b0049c023
mark create_set as deprecated in 3.2, not 3.0
John W. Eaton <jwe@octave.org>
parents:
8887
diff
changeset
|
50 ## Deprecated in version 3.2 |
8887 | 51 |
7344 | 52 function y = create_set (x, rows_opt) |
559 | 53 |
8887 | 54 persistent warned = false; |
55 if (! warned) | |
56 warned = true; | |
57 warning ("Octave:deprecated-function", | |
58 "create_set is obsolete and will be removed from a future version of Octave, please use unique instead"); | |
59 endif | |
60 | |
7344 | 61 if (nargin < 1 || nargin > 2) |
6046 | 62 print_usage (); |
559 | 63 endif |
7344 | 64 |
65 if (nargin == 1) | |
8887 | 66 y = unique (x)(:)'; |
7344 | 67 elseif (strcmpi (rows_opt, "rows")) |
68 y = unique (x, "rows"); | |
559 | 69 else |
7344 | 70 error ("create_set: expecting \"rows\" as second argument"); |
559 | 71 endif |
2325 | 72 |
559 | 73 endfunction |
7411 | 74 |
8887 | 75 %!assert(all (all (create_set ([1, 2, 3, 4, 2, 4]) == [1, 2, 3, 4]))); |
7411 | 76 %!assert(all (all (create_set ([1, 2; 3, 4; 2, 4]) == [1, 2, 3, 4]))); |
77 %!assert(all (all (create_set ([1; 2; 3; 4; 2; 4]) == [1, 2, 3, 4]))); | |
78 %!assert(isempty (create_set ([]))); | |
79 %!error create_set (1, 2); | |
80 |