Mercurial > hg > octave-nkf
annotate examples/code/paramdemo.cc @ 20741:dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
* Canvas.cc, Canvas.h, Figure.cc, gl-render.h,
graphics.cc, ov-fcn-handle.cc, ov-java.cc, Range.cc, CmplxCHOL.cc,
dbleCHOL.cc, floatCHOL.cc: Eliminate trailing whitespace and tabs used
for indentation.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 01 Oct 2015 12:50:00 -0400 |
parents | c8240a60dd01 |
children | 2f8500ca91d3 |
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 } |