Mercurial > octave-nkf
annotate doc/interpreter/set.txi @ 20614:10ec79b47808
use new string_value method to handle value extraction errors
* __voronoi__.cc, chol.cc, colamd.cc, fftw.cc:
Use new string_value method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 08 Oct 2015 18:15:56 -0400 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
1 @c Copyright (C) 1996-2015 John W. Eaton |
7018 | 2 @c |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
9 @c |
7018 | 10 @c Octave is distributed in the hope that it will be useful, but WITHOUT |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
14 @c |
7018 | 15 @c You should have received a copy of the GNU General Public License |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
3294 | 18 |
4167 | 19 @node Sets |
3294 | 20 @chapter Sets |
21 | |
19037
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
22 Octave has a number of functions for managing sets of data. A set is defined |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
23 as a collection of unique elements and is typically represented by a vector of |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
24 numbers sorted in ascending order. Any vector or matrix can be converted to a |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
25 set by removing duplicates through the use of the @code{unique} function. |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
26 However, it isn't necessary to explicitly create a set as all of the functions |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
27 which operate on sets will convert their input to a set before proceeding. |
3294 | 28 |
6741 | 29 @DOCSTRING(unique) |
30 | |
31 @menu | |
9032
349616d9c38e
Cleanup top-level documentation menu in octave.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
32 * Set Operations:: |
6741 | 33 @end menu |
34 | |
35 @node Set Operations | |
36 @section Set Operations | |
6550 | 37 |
19037
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
38 Octave supports several basic set operations. Octave can compute the union, |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 intersection, and difference of two sets. Octave also supports the |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 @emph{Exclusive Or} set operation. |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 The functions for set operations all work in the same way by accepting two |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 input sets and returning a third set. As an example, assume that @code{a} and |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 @code{b} contains two sets, then |
6741 | 45 |
46 @example | |
19037
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
47 union (a, b) |
6741 | 48 @end example |
49 | |
50 @noindent | |
51 computes the union of the two sets. | |
52 | |
19037
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
53 Finally, determining whether elements belong to a set can be done with the |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
54 @code{ismember} function. Because sets are ordered this operation is very |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
55 efficient and is of order O(log2(n)) which is preferable to the @code{find} |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
56 function which is of order O(n). |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
57 |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
58 @DOCSTRING(intersect) |
6502 | 59 |
3368 | 60 @DOCSTRING(union) |
3294 | 61 |
6502 | 62 @DOCSTRING(setdiff) |
63 | |
64 @DOCSTRING(setxor) | |
12213
d5f50ea57869
Add powerset function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
65 |
19037
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 @DOCSTRING(ismember) |
d00f6b09258f
Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
67 |
12213
d5f50ea57869
Add powerset function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
68 @DOCSTRING(powerset) |