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