Mercurial > hg > octave-nkf
annotate scripts/optimization/private/__fdjac__.m @ 17530:0f45d9dd8107
test: Fix 4 failing plot demos.
* scripts/plot/legend.m: Demo #11, use 'h' for returned handle.
* scripts/plot/plot.m: Fix typo "lenths" -> "lengths".
* scripts/plot/ribbon.m: Remove unnecessary call to meshgrid now
that sombrero returns meshgridded data.
* scripts/plot/trimesh.m: Set colormap so plot is always reproducible.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 01 Oct 2013 15:39:20 -0700 |
parents | 72c96de7a403 |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1 ## Copyright (C) 2008-2012 Jaroslav Hajek |
9902
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 ## |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 ## |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 ## |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 ## |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10201
diff
changeset
|
20 ## @deftypefn {Function File} {} __fdjac__ (@var{fcn}, @var{x}, @var{fvec}, @var{err}) |
9902
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
21 ## Undocumented internal function. |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 ## @end deftypefn |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 |
10201
5c66978f3fdf
support TypicalX and AutoScaling in fsolve/fminunc, don't autoscale by default
Jaroslav Hajek <highegg@gmail.com>
parents:
9902
diff
changeset
|
24 function fjac = __fdjac__ (fcn, x, fvec, typicalx, cdif, err = 0) |
9902
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 if (cdif) |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 err = (max (eps, err)) ^ (1/3); |
10201
5c66978f3fdf
support TypicalX and AutoScaling in fsolve/fminunc, don't autoscale by default
Jaroslav Hajek <highegg@gmail.com>
parents:
9902
diff
changeset
|
27 h = typicalx*err; |
9902
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 fjac = zeros (length (fvec), numel (x)); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 for i = 1:numel (x) |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 x1 = x2 = x; |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 x1(i) += h(i); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
32 x2(i) -= h(i); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
33 fjac(:,i) = (fcn (x1)(:) - fcn (x2)(:)) / (x1(i) - x2(i)); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 endfor |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 else |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 err = sqrt (max (eps, err)); |
10201
5c66978f3fdf
support TypicalX and AutoScaling in fsolve/fminunc, don't autoscale by default
Jaroslav Hajek <highegg@gmail.com>
parents:
9902
diff
changeset
|
37 h = typicalx*err; |
9902
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
38 fjac = zeros (length (fvec), numel (x)); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
39 for i = 1:numel (x) |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
40 x1 = x; |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 x1(i) += h(i); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 fjac(:,i) = (fcn (x1)(:) - fvec) / (x1(i) - x(i)); |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 endfor |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
44 endif |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 endfunction |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 |
2929c453af8f
omissions from 9899:9f25290a35e8
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
48 |