]> Creatis software - CreaPhase.git/blob - octave_packages/optim-1.2.0/dfxpdp.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / optim-1.2.0 / dfxpdp.m
1 %% Copyright (C) 2010, 2011 Olaf Till <i7tiol@t-online.de>
2 %%
3 %% This program is free software; you can redistribute it and/or modify it under
4 %% the terms of the GNU General Public License as published by the Free Software
5 %% Foundation; either version 3 of the License, or (at your option) any later
6 %% version.
7 %%
8 %% This program is distributed in the hope that it will be useful, but WITHOUT
9 %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 %% details.
12 %%
13 %% You should have received a copy of the GNU General Public License along with
14 %% this program; if not, see <http://www.gnu.org/licenses/>.
15
16 %% function jac = dfxpdp (x, p, func[, hook])
17 %%
18 %% Returns Jacobian of func (p, x) with respect to p with finite
19 %% differencing. The optional argument hook is a structure which can
20 %% contain the following fields at the moment:
21 %%
22 %% hook.f: value of func(p, x) for p and x as given in the arguments
23 %%
24 %% hook.diffp: positive vector of fractional steps from given p in
25 %% finite differencing (actual steps may be smaller if bounds are
26 %% given). The default is .001 * ones (size (p));
27 %%
28 %% hook.diff_onesided: logical vector, indexing elements of p for
29 %% which only one-sided differences should be computed (faster); even
30 %% if not one-sided, differences might not be exactly central if
31 %% bounds are given. The default is false (size (p)).
32 %%
33 %% hook.fixed: logical vector, indexing elements of p for which zero
34 %% should be returned instead of the guessed partial derivatives
35 %% (useful in optimization if some parameters are not optimized, but
36 %% are 'fixed').
37 %%
38 %% hook.lbound, hook.ubound: vectors of lower and upper parameter
39 %% bounds (or -Inf or +Inf, respectively) to be respected in finite
40 %% differencing. The consistency of bounds is not checked.
41
42 function ret = dfxpdp (varargin)
43
44   %% This is an interface to __dfdp__.m.
45
46   if (ischar (varargin{3}))
47     varargin{3} = @ (p) str2func (varargin{3}) ...
48         (p, varargin{1});
49   else
50     varargin{3} = @ (p) varargin{3} (p, varargin{1});
51   end
52
53   ret = __dfdp__ (varargin{2:end});