Mercurial > hg > octave-lyh
annotate examples/paramdemo.cc @ 17499:7c14949789ab
Fully single type support & clean the code
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Thu, 26 Sep 2013 04:37:36 +0800 |
parents | be41c30bcb44 |
children |
rev | line source |
---|---|
6580 | 1 #include <octave/oct.h> |
2 | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
3 DEFUN_DLD (paramdemo, args, nargout, "Parameter Check Demo") |
6580 | 4 { |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
5 octave_value retval; |
6580 | 6 int nargin = args.length (); |
7 | |
8 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
|
9 print_usage (); |
6580 | 10 else if (nargout != 0) |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
11 error ("paramdemo: OUTPUT argument required"); |
6580 | 12 else |
13 { | |
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
|
14 NDArray m = args(0).array_value (); |
6580 | 15 double min_val = -10.0; |
16 double max_val = 10.0; | |
17 octave_stdout << "Properties of input array:\n"; | |
18 if (m.any_element_is_negative ()) | |
19 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
|
20 if (m.any_element_is_inf_or_nan ()) |
6580 | 21 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
|
22 if (m.any_element_not_one_or_zero ()) |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
23 octave_stdout << " 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
|
24 if (m.all_elements_are_int_or_inf_or_nan ()) |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
25 octave_stdout << " includes only int, Inf or NaN values\n"; |
6580 | 26 if (m.all_integers (min_val, max_val)) |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
27 octave_stdout << " includes only integers in [-10,10]\n"; |
6580 | 28 } |
29 return retval; | |
30 } |