5590
|
1 %% Automatically generated from DejaGNU files |
|
2 |
|
3 %% test/octave.test/nonlin/fsolve-1.m |
|
4 %!function retval = f (p) |
|
5 %! x = p(1); |
|
6 %! y = p(2); |
|
7 %! z = p(3); |
|
8 %! retval = zeros (3, 1); |
|
9 %! retval(1) = sin(x) + y**2 + log(z) - 7; |
|
10 %! retval(2) = 3*x + 2**y -z**3 + 1; |
|
11 %! retval(3) = x + y + z - 5; |
|
12 %!test |
|
13 %! x_opt = [ 0.599054; |
|
14 %! 2.395931; |
|
15 %! 2.005014 ]; |
|
16 %! tol = 1.0e-5; |
|
17 %! [x, info] = fsolve ("f", [ 0.5, 2.0, 2.5 ]); |
|
18 %! val = f (x); |
|
19 %! info_bad = (info != 1); |
|
20 %! solution_bad = sum (abs (x - x_opt) > tol); |
|
21 %! value_bad = sum (abs (val) > tol); |
|
22 %! if (info_bad) |
|
23 %! printf_assert ("info bad\n"); |
|
24 %! else |
|
25 %! printf_assert ("info good\n"); |
|
26 %! endif |
|
27 %! if (solution_bad) |
|
28 %! printf_assert ("solution bad\n"); |
|
29 %! else |
|
30 %! printf_assert ("solution good\n"); |
|
31 %! endif |
|
32 %! if (value_bad) |
|
33 %! printf_assert ("value bad\n"); |
|
34 %! else |
|
35 %! printf_assert ("value good\n"); |
|
36 %! endif |
|
37 %! assert(prog_output_assert("info good\nsolution good\nvalue good")); |
|
38 |
|
39 %% test/octave.test/nonlin/fsolve-2.m |
|
40 %!function retval = f (p) |
|
41 %! x = p(1); |
|
42 %! y = p(2); |
|
43 %! z = p(3); |
|
44 %! w = p(4); |
|
45 %! retval = zeros (4, 1); |
|
46 %! retval(1) = 3*x + 4*y + exp (z + w) - 1.007; |
|
47 %! retval(2) = 6*x - 4*y + exp (3*z + w) - 11; |
|
48 %! retval(3) = x^4 - 4*y^2 + 6*z - 8*w - 20; |
|
49 %! retval(4) = x^2 + 2*y^3 + z - w - 4; |
|
50 %!test |
|
51 %! x_opt = [ -0.767297326653401; |
|
52 %! 0.590671081117440; |
|
53 %! 1.47190018629642; |
|
54 %! -1.52719341133957 ]; |
|
55 %! tol = 1.0e-5; |
|
56 %! [x, info] = fsolve ("f", [-1, 1, 2, -1]); |
|
57 %! val = f (x); |
|
58 %! info_bad = (info != 1); |
|
59 %! solution_bad = sum (abs (x - x_opt) > tol); |
|
60 %! value_bad = sum (abs (val) > tol); |
|
61 %! if (info_bad) |
|
62 %! printf_assert ("info bad\n"); |
|
63 %! else |
|
64 %! printf_assert ("info good\n"); |
|
65 %! endif |
|
66 %! if (solution_bad) |
|
67 %! printf_assert ("solution bad\n"); |
|
68 %! else |
|
69 %! printf_assert ("solution good\n"); |
|
70 %! endif |
|
71 %! if (value_bad) |
|
72 %! printf_assert ("value bad\n"); |
|
73 %! else |
|
74 %! printf_assert ("value good\n"); |
|
75 %! endif |
|
76 %! assert(prog_output_assert("info good\nsolution good\nvalue good")); |
|
77 |
|
78 %% test/octave.test/nonlin/fsolve_options-1.m |
|
79 %!test |
|
80 %! fsolve_options ("tolerance", eps); |
|
81 %! assert(fsolve_options ("tolerance") == eps); |
|
82 |
|
83 %% test/octave.test/nonlin/fsolve_options-2.m |
5751
|
84 %!error <Invalid call to fsolve_options.*> fsolve_options (); |
5590
|
85 |
|
86 %% test/octave.test/nonlin/fsolve_options-3.m |
5751
|
87 %!error <Invalid call to fsolve_options.*> fsolve_options ("foo", 1, 2); |
5590
|
88 |