examples/paramdemo.cc
Go to the documentation of this file.00001 /* 00002 00003 Copyright (C) 2006, 2007 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 as published by the Free Software Foundation; either 00010 version 3 of the License, or (at your option) any later 00011 version. 00012 00013 Octave is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty 00015 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 See the GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public 00019 License along with Octave; see the file COPYING. If not, 00020 see <http://www.gnu.org/licenses/>. 00021 00022 */ 00023 00024 #include <octave/oct.h> 00025 00026 DEFUN_DLD (paramdemo, args, nargout, 00027 "Parameter Check Demo.") 00028 { 00029 int nargin = args.length (); 00030 octave_value retval; 00031 00032 if (nargin != 1) 00033 print_usage(); 00034 else if (nargout != 0) 00035 error ("paramdemo: function has no output arguments"); 00036 else 00037 { 00038 NDArray m = args(0).array_value(); 00039 double min_val = -10.0; 00040 double max_val = 10.0; 00041 octave_stdout << "Properties of input array:\n"; 00042 if (m.any_element_is_negative ()) 00043 octave_stdout << " includes negative values\n"; 00044 if (m.any_element_is_inf_or_nan()) 00045 octave_stdout << " includes Inf or NaN values\n"; 00046 if (m.any_element_not_one_or_zero()) 00047 octave_stdout << 00048 " includes other values than 1 and 0\n"; 00049 if (m.all_elements_are_int_or_inf_or_nan()) 00050 octave_stdout << 00051 " includes only int, Inf or NaN values\n"; 00052 if (m.all_integers (min_val, max_val)) 00053 octave_stdout << 00054 " includes only integers in [-10,10]\n"; 00055 } 00056 return retval; 00057 }