Mercurial > octave-nkf
comparison scripts/deprecated/create_set.m @ 12728:a17269b1148f stable
maint: undo unintended change removing deprecated functions
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 09 Jun 2011 13:35:10 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
12727:40b16bb69fec | 12728:a17269b1148f |
---|---|
1 ## Copyright (C) 1994-2011 John W. Eaton | |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} create_set (@var{x}) | |
21 ## @deftypefnx {Function File} {} create_set (@var{x}, "rows") | |
22 ## This function has been deprecated. Use unique instead. | |
23 ## @end deftypefn | |
24 | |
25 ## Return a row vector containing the unique values in @var{x}, sorted in | |
26 ## ascending order. For example, | |
27 ## | |
28 ## @example | |
29 ## @group | |
30 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ]) | |
31 ## @result{} [ 1, 2, 3, 4 ] | |
32 ## @end group | |
33 ## @end example | |
34 ## | |
35 ## If the optional second input argument is the string "rows" each row of | |
36 ## the matrix @var{x} will be considered an element of set. For example, | |
37 ## @example | |
38 ## @group | |
39 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ], "rows") | |
40 ## @result{} 1 2 | |
41 ## 3 4 | |
42 ## 4 2 | |
43 ## @end group | |
44 ## @end example | |
45 ## @seealso{union, intersect, complement, unique} | |
46 | |
47 ## Author: jwe | |
48 | |
49 ## Deprecated in version 3.2 | |
50 | |
51 function y = create_set (x, rows_opt) | |
52 | |
53 persistent warned = false; | |
54 if (! warned) | |
55 warned = true; | |
56 warning ("Octave:deprecated-function", | |
57 "create_set is obsolete and will be removed from a future version of Octave, please use unique instead"); | |
58 endif | |
59 | |
60 if (nargin < 1 || nargin > 2) | |
61 print_usage (); | |
62 endif | |
63 | |
64 if (nargin == 1) | |
65 y = unique (x)(:)'; | |
66 elseif (strcmpi (rows_opt, "rows")) | |
67 y = unique (x, "rows"); | |
68 else | |
69 error ("create_set: expecting \"rows\" as second argument"); | |
70 endif | |
71 | |
72 endfunction | |
73 | |
74 %!assert(all (all (create_set ([1, 2, 3, 4, 2, 4]) == [1, 2, 3, 4]))); | |
75 %!assert(all (all (create_set ([1, 2; 3, 4; 2, 4]) == [1, 2, 3, 4]))); | |
76 %!assert(all (all (create_set ([1; 2; 3; 4; 2; 4]) == [1, 2, 3, 4]))); | |
77 %!assert(isempty (create_set ([]))); | |
78 %!error create_set (1, 2); | |
79 |