7017
|
1 ## Copyright (C) 2006, 2007 John W. Eaton |
7016
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
|
18 |
5590
|
19 %% Automatically generated from DejaGNU files |
|
20 |
|
21 %% test/octave.test/nonlin/fsolve-1.m |
|
22 %!function retval = f (p) |
|
23 %! x = p(1); |
|
24 %! y = p(2); |
|
25 %! z = p(3); |
|
26 %! retval = zeros (3, 1); |
|
27 %! retval(1) = sin(x) + y**2 + log(z) - 7; |
|
28 %! retval(2) = 3*x + 2**y -z**3 + 1; |
|
29 %! retval(3) = x + y + z - 5; |
|
30 %!test |
|
31 %! x_opt = [ 0.599054; |
|
32 %! 2.395931; |
|
33 %! 2.005014 ]; |
|
34 %! tol = 1.0e-5; |
|
35 %! [x, info] = fsolve ("f", [ 0.5, 2.0, 2.5 ]); |
|
36 %! val = f (x); |
|
37 %! info_bad = (info != 1); |
|
38 %! solution_bad = sum (abs (x - x_opt) > tol); |
|
39 %! value_bad = sum (abs (val) > tol); |
|
40 %! if (info_bad) |
|
41 %! printf_assert ("info bad\n"); |
|
42 %! else |
|
43 %! printf_assert ("info good\n"); |
|
44 %! endif |
|
45 %! if (solution_bad) |
|
46 %! printf_assert ("solution bad\n"); |
|
47 %! else |
|
48 %! printf_assert ("solution good\n"); |
|
49 %! endif |
|
50 %! if (value_bad) |
|
51 %! printf_assert ("value bad\n"); |
|
52 %! else |
|
53 %! printf_assert ("value good\n"); |
|
54 %! endif |
|
55 %! assert(prog_output_assert("info good\nsolution good\nvalue good")); |
|
56 |
|
57 %% test/octave.test/nonlin/fsolve-2.m |
|
58 %!function retval = f (p) |
|
59 %! x = p(1); |
|
60 %! y = p(2); |
|
61 %! z = p(3); |
|
62 %! w = p(4); |
|
63 %! retval = zeros (4, 1); |
|
64 %! retval(1) = 3*x + 4*y + exp (z + w) - 1.007; |
|
65 %! retval(2) = 6*x - 4*y + exp (3*z + w) - 11; |
|
66 %! retval(3) = x^4 - 4*y^2 + 6*z - 8*w - 20; |
|
67 %! retval(4) = x^2 + 2*y^3 + z - w - 4; |
|
68 %!test |
|
69 %! x_opt = [ -0.767297326653401; |
|
70 %! 0.590671081117440; |
|
71 %! 1.47190018629642; |
|
72 %! -1.52719341133957 ]; |
|
73 %! tol = 1.0e-5; |
|
74 %! [x, info] = fsolve ("f", [-1, 1, 2, -1]); |
|
75 %! val = f (x); |
|
76 %! info_bad = (info != 1); |
|
77 %! solution_bad = sum (abs (x - x_opt) > tol); |
|
78 %! value_bad = sum (abs (val) > tol); |
|
79 %! if (info_bad) |
|
80 %! printf_assert ("info bad\n"); |
|
81 %! else |
|
82 %! printf_assert ("info good\n"); |
|
83 %! endif |
|
84 %! if (solution_bad) |
|
85 %! printf_assert ("solution bad\n"); |
|
86 %! else |
|
87 %! printf_assert ("solution good\n"); |
|
88 %! endif |
|
89 %! if (value_bad) |
|
90 %! printf_assert ("value bad\n"); |
|
91 %! else |
|
92 %! printf_assert ("value good\n"); |
|
93 %! endif |
|
94 %! assert(prog_output_assert("info good\nsolution good\nvalue good")); |
|
95 |
|
96 %% test/octave.test/nonlin/fsolve_options-1.m |
|
97 %!test |
|
98 %! fsolve_options ("tolerance", eps); |
|
99 %! assert(fsolve_options ("tolerance") == eps); |
|
100 |
|
101 %% test/octave.test/nonlin/fsolve_options-3.m |
5751
|
102 %!error <Invalid call to fsolve_options.*> fsolve_options ("foo", 1, 2); |
5590
|
103 |