Mercurial > hg > octave-lyh
annotate scripts/optimization/__all_opts__.m @ 17535:c12c688a35ed default tip lyh
Fix warnings
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Fri, 27 Sep 2013 17:43:27 +0800 |
parents | b81b9d079515 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13044
diff
changeset
|
1 ## Copyright (C) 2009-2012 VZLU Prague |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 ## |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 ## |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 ## |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 ## |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
20 ## @deftypefn {Function File} {@var{names} =} __all_opts__ (@dots{}) |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
21 ## Undocumented internal function. |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 ## @end deftypefn |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
24 ## Query all options from all known optimization functions and return a |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
25 ## list of possible values. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
26 |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 function names = __all_opts__ (varargin) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
28 |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 persistent saved_names = {}; |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 |
8652 | 31 ## do not clear this function |
32 mlock (); | |
33 | |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 ## guard against recursive calls. |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 persistent recursive = false; |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 |
8652 | 37 if (recursive) |
38 names = {}; | |
39 elseif (nargin == 0) | |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
40 names = saved_names; |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 else |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 ## query all options from all known functions. These will call optimset, |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 ## which will in turn call us, but we won't answer. |
8652 | 44 recursive = true; |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 names = saved_names; |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 for i = 1:nargin |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 try |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
48 opts = optimset (varargin{i}); |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 fn = fieldnames (opts).'; |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
50 names = [names, fn]; |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
51 catch |
17344
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
52 ## throw the error as a warning. |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
53 warning (lasterr ()); |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 end_try_catch |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
55 endfor |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
56 names = unique (names); |
11249
6cd1e62b6616
fix internal sorting in __all_opts__ (bug 31392)
Jaroslav Hajek <highegg@gmail.com>
parents:
8812
diff
changeset
|
57 [lnames, idx] = unique (tolower (names)); |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
58 if (length (lnames) < length (names)) |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
59 ## This is bad. |
8664 | 60 error ("__all_opts__: duplicate options with inconsistent case"); |
11249
6cd1e62b6616
fix internal sorting in __all_opts__ (bug 31392)
Jaroslav Hajek <highegg@gmail.com>
parents:
8812
diff
changeset
|
61 else |
6cd1e62b6616
fix internal sorting in __all_opts__ (bug 31392)
Jaroslav Hajek <highegg@gmail.com>
parents:
8812
diff
changeset
|
62 names = names(idx); |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
63 endif |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
64 saved_names = names; |
8652 | 65 recursive = false; |
8647
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 endif |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 endfunction |
06f5dd901f30
implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 |
13044
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
70 |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
71 ## No test needed for internal helper function. |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
72 %!assert (1) |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
73 |