Mercurial > hg > octave-nkf
annotate examples/paramdemo.cc @ 16123:a484e39d1f22
maint: move function definition in lex.ll
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 12:43:36 -0500 |
parents | 460a3c6d8bf1 |
children | be41c30bcb44 |
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) | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
10 print_usage (); |
6580 | 11 else if (nargout != 0) |
12 error ("paramdemo: function has no output arguments"); | |
13 else | |
14 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
15 NDArray m = args(0).array_value (); |
6580 | 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"; | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
21 if (m.any_element_is_inf_or_nan ()) |
6580 | 22 octave_stdout << " includes Inf or NaN values\n"; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
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"; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
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 } |