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 -*- |
3500
|
20 ## @deftypefn {Function File} {} 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 |
|
24 ## b, c, or d may be omitted. |
|
25 ## @end deftypefn |
|
26 ## @seealso{abcddim} |
|
27 |
|
28 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
29 ## Created: November 4, 1997 |
|
30 ## based on is_controllable.m of Scottedward Hodel |
|
31 |
|
32 function retval = is_abcd (a, b, c, d) |
|
33 |
|
34 retval = 0; |
|
35 switch (nargin) |
|
36 case (1) |
|
37 ## A only |
|
38 [na, ma] = size(a); |
|
39 if (na != ma) |
|
40 disp("Matrix A ist not square.") |
|
41 endif |
|
42 case (2) |
|
43 ## A, B only |
|
44 [na, ma] = size(a); [nb, mb] = size(b); |
|
45 if (na != ma) |
|
46 disp("Matrix A ist not square.") |
|
47 return; |
|
48 endif |
|
49 if (na != nb) |
|
50 disp("A and B column dimension different.") |
|
51 return; |
|
52 endif |
|
53 case (3) |
|
54 ## A, B, C only |
|
55 [na, ma] = size(a); [nb, mb] = size(b); [nc, mc] = size(c); |
|
56 if (na != ma) |
|
57 disp("Matrix A ist not square.") |
|
58 return; |
|
59 endif |
|
60 if (na != nb) |
|
61 disp("A and B column dimensions not compatible.") |
|
62 return; |
|
63 endif |
|
64 if (ma != mc) |
|
65 disp("A and C row dimensions not compatible.") |
|
66 return; |
|
67 endif |
|
68 case (4) |
|
69 ## all matrices A, B, C, D |
|
70 [na, ma] = size(a); [nb, mb] = size(b); |
|
71 [nc, mc] = size(c); [nd, md] = size(d); |
|
72 if (na != ma) |
|
73 disp("Matrix A ist not square.") |
|
74 return; |
|
75 endif |
|
76 if (na != nb) |
|
77 disp("A and B column dimensions not compatible.") |
|
78 return; |
|
79 endif |
|
80 if (ma != mc) |
|
81 disp("A and C row dimensions not compatible.") |
|
82 return; |
|
83 endif |
|
84 if (mb != md) |
|
85 disp("B and D row dimensions not compatible.") |
|
86 return; |
|
87 endif |
|
88 if (nc != nd) |
|
89 disp("C and D column dimensions not compatible.") |
|
90 return; |
|
91 endif |
|
92 otherwise |
|
93 usage("retval = is_abcd(a [, b, c, d])") |
|
94 endswitch |
|
95 ## all tests passed, signal ok. |
|
96 retval = 1; |
|
97 endfunction |