Mercurial > octave-nkf
comparison examples/code/paramdemo.cc @ 20578:2f8500ca91d3
eliminate error_state from example files
* addtwomatrices.cc, celldemo.cc, embedded.cc, fortrandemo.cc,
funcdemo.cc, globaldemo.cc, helloworld.cc, make_int.cc, paramdemo.cc,
stringdemo.cc, structdemo.cc, unwinddemo.cc:
Eliminate use of global error_state variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 03 Oct 2015 16:05:27 -0400 |
parents | c8240a60dd01 |
children |
comparison
equal
deleted
inserted
replaced
20577:c547458dc10e | 20578:2f8500ca91d3 |
---|---|
1 #include <octave/oct.h> | 1 #include <octave/oct.h> |
2 | 2 |
3 DEFUN_DLD (paramdemo, args, nargout, "Parameter Check Demo") | 3 DEFUN_DLD (paramdemo, args, nargout, "Parameter Check Demo") |
4 { | 4 { |
5 octave_value retval; | 5 if (args.length () != 1) |
6 int nargin = args.length (); | 6 print_usage (); |
7 | 7 |
8 if (nargin != 1) | 8 if (nargout != 0) |
9 print_usage (); | |
10 else if (nargout != 0) | |
11 error ("paramdemo: OUTPUT argument required"); | 9 error ("paramdemo: OUTPUT argument required"); |
12 else | 10 |
13 { | 11 NDArray m = args(0).array_value (); |
14 NDArray m = args(0).array_value (); | 12 |
15 double min_val = -10.0; | 13 double min_val = -10.0; |
16 double max_val = 10.0; | 14 double max_val = 10.0; |
17 octave_stdout << "Properties of input array:\n"; | 15 |
18 if (m.any_element_is_negative ()) | 16 octave_stdout << "Properties of input array:\n"; |
19 octave_stdout << " includes negative values\n"; | 17 |
20 if (m.any_element_is_inf_or_nan ()) | 18 if (m.any_element_is_negative ()) |
21 octave_stdout << " includes Inf or NaN values\n"; | 19 octave_stdout << " includes negative values\n"; |
22 if (m.any_element_not_one_or_zero ()) | 20 |
23 octave_stdout << " includes other values than 1 and 0\n"; | 21 if (m.any_element_is_inf_or_nan ()) |
24 if (m.all_elements_are_int_or_inf_or_nan ()) | 22 octave_stdout << " includes Inf or NaN values\n"; |
25 octave_stdout << " includes only int, Inf or NaN values\n"; | 23 |
26 if (m.all_integers (min_val, max_val)) | 24 if (m.any_element_not_one_or_zero ()) |
27 octave_stdout << " includes only integers in [-10,10]\n"; | 25 octave_stdout << " includes other values than 1 and 0\n"; |
28 } | 26 |
29 return retval; | 27 if (m.all_elements_are_int_or_inf_or_nan ()) |
28 octave_stdout << " includes only int, Inf or NaN values\n"; | |
29 | |
30 if (m.all_integers (min_val, max_val)) | |
31 octave_stdout << " includes only integers in [-10,10]\n"; | |
32 | |
33 return octave_value (); | |
30 } | 34 } |