1 /* 2 3 Copyright (C) 2009-2016 Lukas F. Reichlin 4 5 This file is part of LTI Syncope. 6 7 LTI Syncope is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 LTI Syncope is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. 19 20 Return true if all arguments are matrices and false otherwise. 21 22 Author: Lukas Reichlin <lukas.reichlin@gmail.com> 23 Created: June 2012 24 Version: 0.2 25 26 */ 27 28 #include <octave/oct.h> 29 #include "config.h" 30 31 // PKG_ADD: autoload ("is_matrix", "__control_helper_functions__.oct"); 32 DEFUN_DLD (is_matrix, args, nargout, 33 "-*- texinfo -*-\n\ 34 @deftypefn {Loadable Function} {} is_matrix (@var{a}, @dots{})\n\ 35 Return true if all arguments are matrices and false otherwise.\n\ 36 @var{[]} is a valid matrix.\n\ 37 Avoid nasty stuff like @code{true = isreal (\"a\")}\n\ 38 @seealso{is_real_matrix, is_real_square_matrix, is_real_vector, is_real_scalar}\n\ 39 @end deftypefn") 40 { 41 octave_value retval = true; 42 octave_idx_type nargin = args.length (); 43 44 if (nargin == 0) 45 { 46 print_usage (); 47 } 48 else 49 { 50 for (octave_idx_type i = 0; i < nargin; i++) 51 { 52 if (args(i).ndims () != 2 || ! args(i).OV_ISNUMERIC () 53 || ! (args(i).OV_ISCOMPLEX () || args(i).OV_ISREAL ())) 54 { 55 retval = false; 56 break; 57 } 58 } 59 } 60 61 return retval; 62 } 63