From: Michael Orlitzky Date: Thu, 7 Mar 2013 01:04:11 +0000 (-0500) Subject: Add length checks to the wood functions, and fix wood_hessian1(). X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=8ed65c4235284698686734be82a9f073b90694d4;p=octave.git Add length checks to the wood functions, and fix wood_hessian1(). --- diff --git a/optimization/test_functions/wood1.m b/optimization/test_functions/wood1.m index 6c3f319..c34de26 100644 --- a/optimization/test_functions/wood1.m +++ b/optimization/test_functions/wood1.m @@ -4,5 +4,9 @@ function f = wood1(x) ## instead of four distinct arguments. See wood.m for more ## information. ## - f = wood(x(1), x(2), x(3), x(4)); + if (length(x) == 4) + f = wood(x(1), x(2), x(3), x(4)); + else + f = NA; + end end diff --git a/optimization/test_functions/wood_gradient1.m b/optimization/test_functions/wood_gradient1.m index 0191f54..eabccc9 100644 --- a/optimization/test_functions/wood_gradient1.m +++ b/optimization/test_functions/wood_gradient1.m @@ -4,5 +4,9 @@ function g = wood_gradient1(x) ## 4-vector instead of four distinct arguments. See wood_gradient.m ## for more information. ## - g = wood_gradient(x(1), x(2), x(3), x(4)); + if (length(x) == 4) + g = wood_gradient(x(1), x(2), x(3), x(4)); + else + g = NA; + end end diff --git a/optimization/test_functions/wood_hessian1.m b/optimization/test_functions/wood_hessian1.m index 60d9854..106cb40 100644 --- a/optimization/test_functions/wood_hessian1.m +++ b/optimization/test_functions/wood_hessian1.m @@ -4,21 +4,9 @@ function H = wood_hessian1(x) ## 4-vector instead of four distinct arguments. See wood_hessian.m ## for more information. ## - H = zeros(4,4); - H(1,1) = 1200*x(1)^2 - 400*x(2) + 2; - H(1,2) = -400*x(1); - H(1,3) = 0; - H(1,4) = 0; - H(2,1) = H(1,2); - H(2,2) = 220.2; - H(2,3) = 0; - H(2,4) = 19.8; - H(3,1) = H(1,3); - H(3,2) = H(2,3); - H(3,3) = 1080*x(3)^2 - 360*x(4) + 2; - H(3,4) = -360*x(3); - H(4,1) = H(1,4); - H(4,2) = H(2,4); - H(4,3) = H(3,4); - H(4,4) = 200.2; + if (length(x) == 4) + H = wood_hessian(x(1), x(2), x(3), x(4)); + else + H = NA; + end end