annotate scripts/general/subsindex.m @ 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 7503499a252b
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: 17744
diff changeset
1 ## Copyright (C) 2008-2015 David Bateman
8154
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
20 ## @deftypefn {Function File} {@var{idx} =} subsindex (@var{a})
20193
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
21 ## Convert an object to an index vector.
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
22 ##
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
23 ## When @var{a} is a class object defined with a class constructor, then
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
24 ## @code{subsindex} is the overloading method that allows the conversion of
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
25 ## this class object to a valid indexing vector. It is important to note that
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
26 ## @code{subsindex} must return a zero-based real integer vector of the class
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
27 ## @qcode{"double"}. For example, if the class constructor
8154
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
29 ## @example
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 ## @group
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
31 ## function b = myclass (a)
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
32 ## b = class (struct ("a", a), "myclass");
8154
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 ## endfunction
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
34 ## @end group
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
35 ## @end example
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
37 ## @noindent
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
38 ## then the @code{subsindex} function
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
39 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 ## @example
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
41 ## @group
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
42 ## function idx = subsindex (a)
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
43 ## idx = double (a.a) - 1.0;
8154
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
44 ## endfunction
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
45 ## @end group
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
46 ## @end example
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 ## @noindent
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
49 ## can then be used as follows
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
51 ## @example
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 ## @group
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 ## a = myclass (1:4);
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
54 ## b = 1:10;
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 ## b(a)
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 ## @result{} 1 2 3 4
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 ## @end group
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
58 ## @end example
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
59 ##
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
60 ## @seealso{class, subsref, subsasgn}
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
61 ## @end deftypefn
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
62
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
63 function idx = subsindex (a)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
64 error ("subsindex: not defined for class \"%s\"", class (a));
8154
265a821f6555 Add subsindex and ismethod functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
65 endfunction
11264
79b77d71d01e subsindex.m: Fix typo in doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 9245
diff changeset
66