Mercurial > hg > octave-nkf
comparison scripts/optimization/fminunc.m @ 13305:63463570d9fe
Add %!endfunction block keyword to test.m
test.m: Accept, but don't process, %!endfunction block keyword
* structfun.m, fminunc.m, fsolve.m, sqp.m, unwrap.m, test.m: Close %!function
declarations with %!endfunction. Until Bug #34497 (unable to clear command line
functions from user workspace) is fixed, use Octave reserved namespace for test
functions.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Oct 2011 07:25:07 -0700 |
parents | b9a89ca0fb75 |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
13304:e1524d82f8e0 | 13305:63463570d9fe |
---|---|
357 elseif (any (isnan (fx(:)))) | 357 elseif (any (isnan (fx(:)))) |
358 error ("fminunc:isnan", "fminunc: NaN value encountered"); | 358 error ("fminunc:isnan", "fminunc: NaN value encountered"); |
359 endif | 359 endif |
360 endfunction | 360 endfunction |
361 | 361 |
362 %!function f = rosenb (x) | 362 %!function f = __rosenb (x) |
363 %! n = length (x); | 363 %! n = length (x); |
364 %! f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2); | 364 %! f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2); |
365 %!endfunction | |
365 %!test | 366 %!test |
366 %! [x, fval, info, out] = fminunc (@rosenb, [5, -5]); | 367 %! [x, fval, info, out] = fminunc (@__rosenb, [5, -5]); |
367 %! tol = 2e-5; | 368 %! tol = 2e-5; |
368 %! assert (info > 0); | 369 %! assert (info > 0); |
369 %! assert (x, ones (1, 2), tol); | 370 %! assert (x, ones (1, 2), tol); |
370 %! assert (fval, 0, tol); | 371 %! assert (fval, 0, tol); |
371 %!test | 372 %!test |
372 %! [x, fval, info, out] = fminunc (@rosenb, zeros (1, 4)); | 373 %! [x, fval, info, out] = fminunc (@__rosenb, zeros (1, 4)); |
373 %! tol = 2e-5; | 374 %! tol = 2e-5; |
374 %! assert (info > 0); | 375 %! assert (info > 0); |
375 %! assert (x, ones (1, 4), tol); | 376 %! assert (x, ones (1, 4), tol); |
376 %! assert (fval, 0, tol); | 377 %! assert (fval, 0, tol); |
377 | 378 |