]> gitweb.michael.orlitzky.com - octave.git/blob - optimization/test_functions/extended_rosenbrock_hessian1.m
Replace ##-style comments with %-style comments in all non-test code.
[octave.git] / optimization / test_functions / extended_rosenbrock_hessian1.m
1 function H = extended_rosenbrock_hessian1(x)
2 %
3 % The Hessian of the extended Rosenbrock function. See
4 % extended_rosenbrock1.m for more information.
5 %
6 % Since the number of arguments is variable, we take a vector
7 % instead of its individual components.
8 %
9 n = length(x);
10
11 if (odd(n))
12 % 'm' below must be an integer.
13 H = NA;
14 return;
15 end
16
17 m = n / 2;
18 H = zeros(n, n);
19
20 % The extended Rosenbrock is simply a sum of Rosenbrock
21 % applications.
22 for k = [ 1 : m ]
23 y1 = x(2*k - 1);
24 y2 = x(2*k);
25
26 H_k = rosenbrock_hessian(y1, y2);
27
28 H(2*k - 1, 2*k - 1) = H(2*k - 1, 2*k - 1) + H_k(1,1);
29 H(2*k - 1, 2*k) = H(2*k - 1, 2*k) + H_k(1,2);
30 H(2*k, 2*k - 1) = H(2*k, 2*k - 1) + H_k(2,1);
31 H(2*k, 2*k) = H(2*k, 2*k) + H_k(2,2);
32 end
33 end