Mercurial > octave-nkf
annotate examples/paramdemo.cc @ 16088:b29b10fbb744 stable release-3-6-4
Version 3.6.4 released.
* configure.ac (AC_INIT): Version is now 3.6.4.
(OCTAVE_RELEASE_DATE): Now 2013-02-21.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Feb 2013 15:17:54 -0500 |
parents | db1f49eaba6b |
children | 460a3c6d8bf1 |
rev | line source |
---|---|
6580 | 1 #include <octave/oct.h> |
2 | |
12174 | 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()) | |
12174 | 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()) |
12174 | 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)) |
12174 | 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 } |