1 ## Copyright (C) 2010, 2011 Olaf Till <olaf.till@uni-jena.de>
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 3 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
16 function [mc, vc, f_gencstr, df_gencstr, user_df] = \
17 __collect_constraints__ (cstr, do_cstep, context)
19 mc = vc = f_gencstr = df_gencstr = [];
22 if (isempty (cstr)) return; endif
24 if (ismatrix (tp = cstr{1}) || isstruct (tp))
27 if ((tp = length (cstr)) > 2)
35 lid = 0; # no linear constraints
37 if ((len = length (cstr)) > 1)
38 if (ismatrix (c = cstr{2}) || isstruct (c))
54 if (! isempty (f_gencstr))
55 if (ischar (f_gencstr))
56 f_gencstr = str2func (f_gencstr);
58 f_gencstr = @ (varargin) \
59 tf_gencstr (f_gencstr, varargin{:});
63 error ("both complex step derivative chosen and user Jacobian function specified for %s", context);
65 if (ischar (df_gencstr))
66 df_gencstr = str2func (df_gencstr);
68 df_gencstr = @ (p, func, idx, hook) \
69 df_gencstr (p, idx, hook);
72 df_gencstr = @ (p, func, idx, hook) jacobs (p, func, hook);
74 __dfdp__ = @ __dfdp__; # for bug #31484 (Octave <= 3.2.4)
75 df_gencstr = @ (p, func, idx, hook) __dfdp__ (p, func, hook);
82 function ret = tf_gencstr (f, varargin) # varargin: p[, idx[, info]]
84 ## necessary since user function f_gencstr might return [] or a row
87 if (isempty (ret = f (varargin{:})))
89 elseif (columns (ret) > 1)