1 ## Copyright (C) 2008-2012 David Bateman
3 ## This file is part of Octave.
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.
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.
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/>.
20 ## @deftypefn {Function File} {@var{idx} =} subsindex (@var{a})
21 ## Convert an object to an index vector. When @var{a} is a class object
22 ## defined with a class constructor, then @code{subsindex} is the
23 ## overloading method that allows the conversion of this class object to
24 ## a valid indexing vector. It is important to note that
25 ## @code{subsindex} must return a zero-based real integer vector of the
26 ## class "double". For example, if the class constructor
30 ## function b = myclass (a)
31 ## b = class (struct ("a", a), "myclass");
37 ## then the @code{subsindex} function
41 ## function idx = subsindex (a)
42 ## idx = double (a.a) - 1.0;
48 ## can then be used as follows
59 ## @seealso{class, subsref, subsasgn}
62 function idx = subsindex (a)
63 error ("subsindex: not defined for class \"%s\"", class(a));