annotate examples/code/paramdemo.cc @ 20595:c1a6c31ac29a

eliminate more simple uses of error_state * ov-classdef.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 00:20:02 -0400
parents 2f8500ca91d3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6580
d2bb3b8a8d20 [project @ 2007-04-25 22:19:03 by dbateman]
dbateman
parents:
diff changeset
1 #include <octave/oct.h>
d2bb3b8a8d20 [project @ 2007-04-25 22:19:03 by dbateman]
dbateman
parents:
diff changeset
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
d2bb3b8a8d20 [project @ 2007-04-25 22:19:03 by dbateman]
dbateman
parents:
diff changeset
4 {
20578
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
5 if (args.length () != 1)
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
6 print_usage ();
6580
d2bb3b8a8d20 [project @ 2007-04-25 22:19:03 by dbateman]
dbateman
parents:
diff changeset
7
20578
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
8 if (nargout != 0)
16867
be41c30bcb44 Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents: 14846
diff changeset
9 error ("paramdemo: OUTPUT argument required");
20578
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
10
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
11 NDArray m = args(0).array_value ();
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
12
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
13 double min_val = -10.0;
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
14 double max_val = 10.0;
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
15
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
16 octave_stdout << "Properties of input array:\n";
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
17
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
18 if (m.any_element_is_negative ())
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
19 octave_stdout << " includes negative values\n";
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
20
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
21 if (m.any_element_is_inf_or_nan ())
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
22 octave_stdout << " includes Inf or NaN values\n";
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
23
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
24 if (m.any_element_not_one_or_zero ())
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
25 octave_stdout << " includes other values than 1 and 0\n";
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
26
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
27 if (m.all_elements_are_int_or_inf_or_nan ())
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
28 octave_stdout << " includes only int, Inf or NaN values\n";
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
29
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
30 if (m.all_integers (min_val, max_val))
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
31 octave_stdout << " includes only integers in [-10,10]\n";
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
32
2f8500ca91d3 eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents: 19067
diff changeset
33 return octave_value ();
6580
d2bb3b8a8d20 [project @ 2007-04-25 22:19:03 by dbateman]
dbateman
parents:
diff changeset
34 }