6580
|
1 #include <octave/oct.h> |
|
2 |
|
3 DEFUN_DLD (paramdemo, args, nargout, "Parameter Check Demo.") |
|
4 { |
|
5 int nargin = args.length (); |
|
6 octave_value retval; |
|
7 |
|
8 if (nargin != 1) |
|
9 print_usage(); |
|
10 else if (nargout != 0) |
|
11 error ("paramdemo: function has no output arguments"); |
|
12 else |
|
13 { |
|
14 NDArray m = args(0).array_value(); |
|
15 double min_val = -10.0; |
|
16 double max_val = 10.0; |
|
17 octave_stdout << "Properties of input array:\n"; |
|
18 if (m.any_element_is_negative ()) |
|
19 octave_stdout << " includes negative values\n"; |
|
20 if (m.any_element_is_inf_or_nan()) |
|
21 octave_stdout << " includes Inf or NaN values\n"; |
|
22 if (m.any_element_not_one_or_zero()) |
|
23 octave_stdout << " includes other values than 1 and 0\n"; |
|
24 if (m.all_elements_are_int_or_inf_or_nan()) |
|
25 octave_stdout << " includes only int, Inf or NaN values\n"; |
|
26 if (m.all_integers (min_val, max_val)) |
|
27 octave_stdout << " includes only integers in [-10,10]\n"; |
|
28 } |
|
29 return retval; |
|
30 } |