]> gitweb.michael.orlitzky.com - octave.git/blob - optimization/test_functions/extended_powell_hessian1.m
972e690da5d83c0d667fff69a2169b3ade8b12bf
[octave.git] / optimization / test_functions / extended_powell_hessian1.m
1 function H = extended_powell_hessian1(x)
2 ##
3 ## The Hessian of the extended Powell function. See
4 ## extended_powell1.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 / 4;
18 H = zeros(n, n);
19
20 % The extended Powell is simply a sum of Powell
21 % applications.
22 for k = [ 1 : m ]
23 y1 = x(4*k - 3);
24 y2 = x(4*k - 2);
25 y3 = x(4*k - 1);
26 y4 = x(4*k);
27
28 H_k = powell_hessian(y1, y2, y3, y4);
29
30 for i = [ 1 : 4 ]
31 for j = [ 1 : 4 ]
32 H(4*(k-1) + i, 4*(k-1) + j) = ...
33 H(4*(k-1) + i, 4*(k-1) + j) + H_k(i,j);
34 end
35 end
36
37 end
38 end