7019
|
1 /* |
|
2 |
7081
|
3 Copyright (C) 2006, 2007 John W. Eaton |
7019
|
4 |
|
5 This file is part of Octave. |
|
6 |
7081
|
7 Octave is free software; you can redistribute it and/or |
|
8 modify it under the terms of the GNU General Public License |
|
9 as published by the Free Software Foundation; either |
|
10 version 3 of the License, or (at your option) any later |
|
11 version. |
7019
|
12 |
7081
|
13 Octave is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty |
|
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
16 See the GNU General Public License for more details. |
7019
|
17 |
7081
|
18 You should have received a copy of the GNU General Public |
|
19 License along with Octave; see the file COPYING. If not, |
|
20 see <http://www.gnu.org/licenses/>. |
7019
|
21 |
|
22 */ |
|
23 |
6580
|
24 #include <octave/oct.h> |
|
25 |
7081
|
26 DEFUN_DLD (paramdemo, args, nargout, |
|
27 "Parameter Check Demo.") |
6580
|
28 { |
|
29 int nargin = args.length (); |
|
30 octave_value retval; |
|
31 |
|
32 if (nargin != 1) |
|
33 print_usage(); |
|
34 else if (nargout != 0) |
|
35 error ("paramdemo: function has no output arguments"); |
|
36 else |
|
37 { |
|
38 NDArray m = args(0).array_value(); |
|
39 double min_val = -10.0; |
|
40 double max_val = 10.0; |
|
41 octave_stdout << "Properties of input array:\n"; |
|
42 if (m.any_element_is_negative ()) |
|
43 octave_stdout << " includes negative values\n"; |
|
44 if (m.any_element_is_inf_or_nan()) |
|
45 octave_stdout << " includes Inf or NaN values\n"; |
|
46 if (m.any_element_not_one_or_zero()) |
7081
|
47 octave_stdout << |
|
48 " includes other values than 1 and 0\n"; |
6580
|
49 if (m.all_elements_are_int_or_inf_or_nan()) |
7081
|
50 octave_stdout << |
|
51 " includes only int, Inf or NaN values\n"; |
6580
|
52 if (m.all_integers (min_val, max_val)) |
7081
|
53 octave_stdout << |
|
54 " includes only integers in [-10,10]\n"; |
6580
|
55 } |
|
56 return retval; |
|
57 } |