Mercurial > hg > octave-nkf
annotate examples/paramdemo.cc @ 12288:f07e6b4d34c7 release-3-4-x
Add function compare_versions to documentation.
Update docstrings for surrounding functions in manual.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 29 Jan 2011 16:54:14 -0800 |
parents | 23385f2c90b7 |
children | 460a3c6d8bf1 |
rev | line source |
---|---|
6580 | 1 #include <octave/oct.h> |
2 | |
12254 | 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()) | |
12254 | 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()) |
12254 | 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)) |
12254 | 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 } |