3431
|
1 ## Copyright (C) 1997 Kai P. Mueller |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
5016
|
20 ## @deftypefn {Function File} {@var{retval} =} is_abcd (@var{a}, @var{b}, @var{c}, @var{d}) |
3431
|
21 ## Returns @var{retval} = 1 if the dimensions of @var{a}, @var{b}, |
|
22 ## @var{c}, @var{d} are compatible, otherwise @var{retval} = 0 with an |
|
23 ## appropriate diagnostic message printed to the screen. The matrices |
5016
|
24 ## @var{b}, @var{c}, or @var{d} may be omitted. |
3431
|
25 ## @end deftypefn |
5053
|
26 ## |
3431
|
27 ## @seealso{abcddim} |
|
28 |
|
29 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
30 ## Created: November 4, 1997 |
|
31 ## based on is_controllable.m of Scottedward Hodel |
|
32 |
|
33 function retval = is_abcd (a, b, c, d) |
|
34 |
|
35 retval = 0; |
|
36 switch (nargin) |
|
37 case (1) |
|
38 ## A only |
|
39 [na, ma] = size(a); |
|
40 if (na != ma) |
|
41 disp("Matrix A ist not square.") |
|
42 endif |
|
43 case (2) |
|
44 ## A, B only |
|
45 [na, ma] = size(a); [nb, mb] = size(b); |
|
46 if (na != ma) |
|
47 disp("Matrix A ist not square.") |
|
48 return; |
|
49 endif |
|
50 if (na != nb) |
|
51 disp("A and B column dimension different.") |
|
52 return; |
|
53 endif |
|
54 case (3) |
|
55 ## A, B, C only |
|
56 [na, ma] = size(a); [nb, mb] = size(b); [nc, mc] = size(c); |
|
57 if (na != ma) |
|
58 disp("Matrix A ist not square.") |
|
59 return; |
|
60 endif |
|
61 if (na != nb) |
|
62 disp("A and B column dimensions not compatible.") |
|
63 return; |
|
64 endif |
|
65 if (ma != mc) |
|
66 disp("A and C row dimensions not compatible.") |
|
67 return; |
|
68 endif |
|
69 case (4) |
|
70 ## all matrices A, B, C, D |
|
71 [na, ma] = size(a); [nb, mb] = size(b); |
|
72 [nc, mc] = size(c); [nd, md] = size(d); |
|
73 if (na != ma) |
|
74 disp("Matrix A ist not square.") |
|
75 return; |
|
76 endif |
|
77 if (na != nb) |
|
78 disp("A and B column dimensions not compatible.") |
|
79 return; |
|
80 endif |
|
81 if (ma != mc) |
|
82 disp("A and C row dimensions not compatible.") |
|
83 return; |
|
84 endif |
|
85 if (mb != md) |
|
86 disp("B and D row dimensions not compatible.") |
|
87 return; |
|
88 endif |
|
89 if (nc != nd) |
|
90 disp("C and D column dimensions not compatible.") |
|
91 return; |
|
92 endif |
|
93 otherwise |
|
94 usage("retval = is_abcd(a [, b, c, d])") |
|
95 endswitch |
|
96 ## all tests passed, signal ok. |
|
97 retval = 1; |
|
98 endfunction |