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 zero-pole vectors and false otherwise.
21 
22 Author: Lukas Reichlin <lukas.reichlin@gmail.com>
23 Created: October 2015
24 Version: 0.1
25 
26 */
27 
28 #include <octave/oct.h>
29 #include "config.h"
30 
31 // PKG_ADD: autoload ("is_zp_vector", "__control_helper_functions__.oct");
32 DEFUN_DLD (is_zp_vector, args, nargout,
33    "-*- texinfo -*-\n\
34 @deftypefn {Loadable Function} {} is_zp_vector (@var{a}, @dots{})\n\
35 Return true if all arguments are zero-pole vectors and false otherwise.\n\
36 @var{[]} is a valid zero-pole vector.\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
53                 || (args(i).rows () > 1 && args(i).columns () > 1)
54                 || ! args(i).OV_ISNUMERIC ()
55                 || ! (args(i).OV_ISCOMPLEX () || args(i).OV_ISREAL()))
56             {
57                 retval = false;
58                 break;
59             }
60         }
61     }
62 
63     return retval;
64 }
65