annotate doc/interpreter/set.txi @ 20595:c1a6c31ac29a

eliminate more simple uses of error_state * ov-classdef.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 00:20:02 -0400
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
2 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
3 @c This file is part of Octave.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
4 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
5 @c Octave is free software; you can redistribute it and/or modify it
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
6 @c under the terms of the GNU General Public License as published by the
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
7 @c Free Software Foundation; either version 3 of the License, or (at
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
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
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
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
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
15 @c You should have received a copy of the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
16 @c along with Octave; see the file COPYING. If not, see
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
17 @c <http://www.gnu.org/licenses/>.
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
18
4167
aae05d51353c [project @ 2002-11-12 02:52:50 by jwe]
jwe
parents: 3439
diff changeset
19 @node Sets
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
20 @chapter Sets
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
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
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
28
6741
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
29 @DOCSTRING(unique)
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
30
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
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
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
33 @end menu
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
34
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
35 @node Set Operations
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
36 @section Set Operations
6550
1b7a6061a05d [project @ 2007-04-20 07:40:26 by jwe]
jwe
parents: 6502
diff changeset
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
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
45
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
46 @example
19037
d00f6b09258f Overhaul functions in scripts/set directory.
Rik <rik@octave.org>
parents: 17744
diff changeset
47 union (a, b)
6741
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
48 @end example
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
49
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
50 @noindent
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
51 computes the union of the two sets.
00116015904d [project @ 2007-06-18 16:07:14 by jwe]
jwe
parents: 6550
diff changeset
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
6ab0a8767780 [project @ 2007-04-06 03:32:06 by jwe]
jwe
parents: 4167
diff changeset
59
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3294
diff changeset
60 @DOCSTRING(union)
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
61
6502
6ab0a8767780 [project @ 2007-04-06 03:32:06 by jwe]
jwe
parents: 4167
diff changeset
62 @DOCSTRING(setdiff)
6ab0a8767780 [project @ 2007-04-06 03:32:06 by jwe]
jwe
parents: 4167
diff changeset
63
6ab0a8767780 [project @ 2007-04-06 03:32:06 by jwe]
jwe
parents: 4167
diff changeset
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)