]> gitweb.michael.orlitzky.com - octave.git/commitdiff
Add the powell_hessian() and powell_hessian1() functions.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 7 Mar 2013 01:28:49 +0000 (20:28 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 7 Mar 2013 01:28:49 +0000 (20:28 -0500)
optimization/test_functions/powell_hessian.m [new file with mode: 0644]
optimization/test_functions/powell_hessian1.m [new file with mode: 0644]

diff --git a/optimization/test_functions/powell_hessian.m b/optimization/test_functions/powell_hessian.m
new file mode 100644 (file)
index 0000000..48cc390
--- /dev/null
@@ -0,0 +1,27 @@
+function H = powell_hessian(x1, x2, x3, x4)
+  ##
+  ## The Hessian of the Powell function. See powell.m for more
+  ## information.
+  ##
+  H = zeros(4,4);
+
+  H(1,1) = 120*(x1 - x4)^2 + 2;
+  H(1,2) = 20;
+  H(1,3) = 0;
+  H(1,4) = -120*(x1 - x4)^2;
+
+  H(2,1) = H(1,2);
+  H(2,2) = 12*(x2 - 2*x3)^2 + 200;
+  H(2,3) = -24*(x2 - 2*x3)^2;
+  H(2,4) = 0;
+
+  H(3,1) = H(1,3);
+  H(3,2) = H(1,3);
+  H(3,3) = 48*(x2 - 2*x3)^2 + 10;
+  H(3,4) = -10;
+
+  H(4,1) = H(1,4);
+  H(4,2) = H(2,4);
+  H(4,3) = H(3,4);
+  H(4,4) = 120*(x1 - x4)^2 + 10;
+end
diff --git a/optimization/test_functions/powell_hessian1.m b/optimization/test_functions/powell_hessian1.m
new file mode 100644 (file)
index 0000000..b11d7f8
--- /dev/null
@@ -0,0 +1,12 @@
+function H = powell_hessian1(x)
+  ##
+  ## A version of the powell_hessian() function which takes a column
+  ## 4-vector instead of four distinct arguments. See powell_hessian.m
+  ## for more information.
+  ##
+  if (length(x) == 4)
+    H = powell_hessian(x(1), x(2), x(3), x(4));
+  else
+    H = NA;
+  end
+end