Mercurial > hg > octave-nkf
annotate examples/paramdemo.cc @ 9932:6cb30a539481
untabify files in examples directory
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 07 Dec 2009 14:53:20 -0500 |
parents | 4295d634797d |
children | db1f49eaba6b |
rev | line source |
---|---|
6580 | 1 #include <octave/oct.h> |
2 | |
7081 | 3 DEFUN_DLD (paramdemo, args, nargout, |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
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 << |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
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 << |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
28 " includes only int, Inf or NaN values\n"; |
6580 | 29 if (m.all_integers (min_val, max_val)) |
7081 | 30 octave_stdout << |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
31 " includes only integers in [-10,10]\n"; |
6580 | 32 } |
33 return retval; | |
34 } |