X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=optimization%2Ftest_functions%2Fextended_powell_gradient1.m;fp=optimization%2Ftest_functions%2Fextended_powell_gradient1.m;h=7cc7aabf2980c2b3e65f791d631644f6db240b10;hp=0000000000000000000000000000000000000000;hb=30c26967dbc89131a09979fa8937eac0ef7a73b4;hpb=120959c85ebb6544fa0a00c3d1c3f8941e7da3e0 diff --git a/optimization/test_functions/extended_powell_gradient1.m b/optimization/test_functions/extended_powell_gradient1.m new file mode 100644 index 0000000..7cc7aab --- /dev/null +++ b/optimization/test_functions/extended_powell_gradient1.m @@ -0,0 +1,35 @@ +function g = extended_powell_gradient1(x) + ## + ## The gradient of the extended Powell function. See + ## extended_powell1.m for more information. + ## + ## Since the number of arguments is variable, we take a vector + ## instead of its individual components. + ## + n = length(x); + + if (odd(n)) + ## 'm' below must be an integer. + g = NA; + return; + end + + m = n / 4; + g = zeros(n, 1); + + % The extended Powell is simply a sum of Powell + % applications. + for k = [ 1 : m ] + y1 = x(4*k - 3); + y2 = x(4*k - 2); + y3 = x(4*k - 1); + y4 = x(4*k); + + g_k = powell_gradient(y1, y2, y3, y4); + + for i = [ 1 : 4 ] + g(4*(k-1) + i) = g(4*(k-1) + i) + g_k(i); + end + + end +end