Mercurial > octave
annotate src/DLD-FUNCTIONS/balance.cc @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | a4f482e66b65 |
children | 01f703952eff |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 John W. Eaton |
4 Copyright (C) 2008-2009 Jaroslav Hajek | |
2928 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2928 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2928 | 21 |
22 */ | |
23 | |
3911 | 24 // Author: A. S. Hodel <scotte@eng.auburn.edu> |
2928 | 25 |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
30 #include <string> | |
31 | |
32 #include "CmplxAEPBAL.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
33 #include "fCmplxAEPBAL.h" |
2928 | 34 #include "dbleAEPBAL.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
35 #include "floatAEPBAL.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
36 #include "CmplxGEPBAL.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
37 #include "fCmplxGEPBAL.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
38 #include "dbleGEPBAL.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
39 #include "floatGEPBAL.h" |
4153 | 40 #include "quit.h" |
2928 | 41 |
42 #include "defun-dld.h" | |
43 #include "error.h" | |
3181 | 44 #include "f77-fcn.h" |
2928 | 45 #include "gripes.h" |
46 #include "oct-obj.h" | |
47 #include "utils.h" | |
48 | |
49 DEFUN_DLD (balance, args, nargout, | |
3548 | 50 "-*- texinfo -*-\n\ |
10840 | 51 @deftypefn {Loadable Function} {@var{aa} =} balance (@var{a}, @var{opt})\n\ |
3372 | 52 @deftypefnx {Loadable Function} {[@var{dd}, @var{aa}] =} balance (@var{a}, @var{opt})\n\ |
9048
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
53 @deftypefnx {Loadable Function} {[@var{d}, @var{p}, @var{aa}] =} balance (@var{a}, @var{opt})\n\ |
3402 | 54 @deftypefnx {Loadable Function} {[@var{cc}, @var{dd}, @var{aa}, @var{bb}] =} balance (@var{a}, @var{b}, @var{opt})\n\ |
2928 | 55 \n\ |
7096 | 56 Compute @code{aa = dd \\ a * dd} in which @code{aa} is a matrix whose\n\ |
57 row and column norms are roughly equal in magnitude, and\n\ | |
58 @code{dd} = @code{p * d}, in which @code{p} is a permutation\n\ | |
3372 | 59 matrix and @code{d} is a diagonal matrix of powers of two. This allows\n\ |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
10155
diff
changeset
|
60 the equilibration to be computed without round-off. Results of\n\ |
3372 | 61 eigenvalue calculation are typically improved by balancing first.\n\ |
2928 | 62 \n\ |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
63 If two output values are requested, @code{balance} returns \n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9048
diff
changeset
|
64 the diagonal @code{d} and the permutation @code{p} separately as vectors. \n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
65 In this case, @code{dd = eye(n)(:,p) * diag (d)}, where @code{n} is the\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
66 matrix size. \n\ |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
67 \n\ |
7096 | 68 If four output values are requested, compute @code{aa = cc*a*dd} and\n\ |
69 @code{bb = cc*b*dd)}, in which @code{aa} and @code{bb} have non-zero\n\ | |
3372 | 70 elements of approximately the same magnitude and @code{cc} and @code{dd}\n\ |
71 are permuted diagonal matrices as in @code{dd} for the algebraic\n\ | |
72 eigenvalue problem.\n\ | |
73 \n\ | |
7096 | 74 The eigenvalue balancing option @code{opt} may be one of:\n\ |
2928 | 75 \n\ |
3372 | 76 @table @asis\n\ |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
77 @item @code{\"noperm\"}, @code{\"S\"}\n\ |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
78 Scale only; do not permute.\n\ |
3372 | 79 \n\ |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
80 @item @code{\"noscal\"}, @code{\"P\"}\n\ |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
81 Permute only; do not scale.\n\ |
3372 | 82 @end table\n\ |
2928 | 83 \n\ |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
84 Algebraic eigenvalue balancing uses standard @sc{lapack} routines.\n\ |
3372 | 85 \n\ |
86 Generalized eigenvalue problem balancing uses Ward's algorithm\n\ | |
87 (SIAM Journal on Scientific and Statistical Computing, 1981).\n\ | |
88 @end deftypefn") | |
2928 | 89 { |
90 octave_value_list retval; | |
91 | |
92 int nargin = args.length (); | |
93 | |
94 if (nargin < 1 || nargin > 3 || nargout < 0 || nargout > 4) | |
95 { | |
5823 | 96 print_usage (); |
2928 | 97 return retval; |
98 } | |
99 | |
3181 | 100 // determine if it's AEP or GEP |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
101 bool AEPcase = nargin == 1 || args(1).is_string (); |
2928 | 102 |
3181 | 103 // problem dimension |
5275 | 104 octave_idx_type nn = args(0).rows (); |
2928 | 105 |
3181 | 106 if (nn != args(0).columns()) |
3185 | 107 { |
108 gripe_square_matrix_required ("balance"); | |
109 return retval; | |
110 } | |
2928 | 111 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
112 bool isfloat = args(0).is_single_type () || |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
113 (! AEPcase && args(1).is_single_type()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
114 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
115 bool complex_case = (args(0).is_complex_type () || |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
116 (! AEPcase && args(1).is_complex_type ())); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
117 |
2928 | 118 // Extract argument 1 parameter for both AEP and GEP. |
119 Matrix aa; | |
120 ComplexMatrix caa; | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
121 FloatMatrix faa; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
122 FloatComplexMatrix fcaa; |
3185 | 123 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
124 if (isfloat) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
125 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
126 if (complex_case) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
127 fcaa = args(0).float_complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
128 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
129 faa = args(0).float_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
130 } |
3185 | 131 else |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
132 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
133 if (complex_case) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
134 caa = args(0).complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
135 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
136 aa = args(0).matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
137 } |
3185 | 138 |
139 if (error_state) | |
140 return retval; | |
2928 | 141 |
142 // Treat AEP/GEP cases. | |
3185 | 143 if (AEPcase) |
144 { | |
145 // Algebraic eigenvalue problem. | |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
146 bool noperm = false, noscal = false; |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
147 if (nargin > 1) |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
148 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
149 std::string a1s = args(1).string_value (); |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
150 noperm = a1s == "noperm" || a1s == "S"; |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
151 noscal = a1s == "noscal" || a1s == "P"; |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
152 } |
3185 | 153 |
154 // balance the AEP | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
155 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
156 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
157 if (complex_case) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
158 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
159 FloatComplexAEPBALANCE result (fcaa, noperm, noscal); |
2928 | 160 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
161 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
162 retval(0) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
163 else if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
164 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
165 retval(1) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
166 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
167 } |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
168 else |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
169 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
170 retval(2) = result.balanced_matrix (); |
9048
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
171 retval(0) = result.scaling_vector (); |
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
172 retval(1) = result.permuting_vector (); |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
173 } |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
174 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
175 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
176 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
177 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
178 FloatAEPBALANCE result (faa, noperm, noscal); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
179 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
180 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
181 retval(0) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
182 else if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
183 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
184 retval(1) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
185 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
186 } |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
187 else |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
188 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
189 retval(2) = result.balanced_matrix (); |
9048
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
190 retval(0) = result.scaling_vector (); |
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
191 retval(1) = result.permuting_vector (); |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
192 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
193 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
194 } |
3181 | 195 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
196 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
197 if (complex_case) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
198 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
199 ComplexAEPBALANCE result (caa, noperm, noscal); |
3185 | 200 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
201 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
202 retval(0) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
203 else if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
204 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
205 retval(1) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
206 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
207 } |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
208 else |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
209 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
210 retval(2) = result.balanced_matrix (); |
9048
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
211 retval(0) = result.scaling_vector (); |
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
212 retval(1) = result.permuting_vector (); |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
213 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
214 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
215 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
216 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
217 AEPBALANCE result (aa, noperm, noscal); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
218 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
219 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
220 retval(0) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
221 else if (nargout == 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
222 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
223 retval(1) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
224 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
225 } |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
226 else |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
227 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
228 retval(2) = result.balanced_matrix (); |
9048
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
229 retval(0) = result.scaling_vector (); |
867d5d1aed06
swap out args in balance for M*b compat
Jaroslav Hajek <highegg@gmail.com>
parents:
8386
diff
changeset
|
230 retval(1) = result.permuting_vector (); |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
231 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
232 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
233 } |
3181 | 234 } |
235 else | |
236 { | |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
237 std::string bal_job; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
238 if (nargout == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
239 warning ("balance: used GEP, should have two output arguments"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
240 |
3185 | 241 // Generalized eigenvalue problem. |
242 if (nargin == 2) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
243 bal_job = "B"; |
3185 | 244 else if (args(2).is_string ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
245 bal_job = args(2).string_value (); |
3185 | 246 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
247 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
248 error ("balance: GEP argument 3 must be a string"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
249 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
250 } |
3185 | 251 |
252 if ((nn != args(1).columns ()) || (nn != args(1).rows ())) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
253 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
254 gripe_nonconformant (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
255 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
256 } |
3185 | 257 |
258 Matrix bb; | |
259 ComplexMatrix cbb; | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
260 FloatMatrix fbb; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
261 FloatComplexMatrix fcbb; |
3185 | 262 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
263 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
264 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
265 if (complex_case) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
266 fcbb = args(1).float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
267 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
268 fbb = args(1).float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
269 } |
3185 | 270 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
271 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
272 if (complex_case) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
273 cbb = args(1).complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
274 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
275 bb = args(1).matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
276 } |
4153 | 277 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
278 // balance the GEP |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
279 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
280 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
281 if (complex_case) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
282 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
283 FloatComplexGEPBALANCE result (fcaa, fcbb, bal_job); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
284 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
285 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
286 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
287 case 4: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
288 retval(3) = result.balanced_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
289 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
290 case 3: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
291 retval(2) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
292 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
293 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
294 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
295 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
296 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
297 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
298 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
299 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
300 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
301 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
302 error ("balance: invalid number of output arguments"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
303 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
304 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
305 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
306 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
307 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
308 FloatGEPBALANCE result (faa, fbb, bal_job); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
309 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
310 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
311 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
312 case 4: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
313 retval(3) = result.balanced_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
314 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
315 case 3: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
316 retval(2) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
317 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
318 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
319 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
320 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
321 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
322 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
323 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
324 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
325 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
326 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
327 error ("balance: invalid number of output arguments"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
328 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
329 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
330 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
331 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
332 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
333 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
334 if (complex_case) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
335 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
336 ComplexGEPBALANCE result (caa, cbb, bal_job); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
337 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
338 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
339 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
340 case 4: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
341 retval(3) = result.balanced_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
342 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
343 case 3: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
344 retval(2) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
345 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
346 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
347 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
348 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
349 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
350 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
351 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
352 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
353 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
354 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
355 error ("balance: invalid number of output arguments"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
356 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
357 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
358 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
359 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
360 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
361 GEPBALANCE result (aa, bb, bal_job); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
362 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
363 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
364 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
365 case 4: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
366 retval(3) = result.balanced_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
367 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
368 case 3: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
369 retval(2) = result.balanced_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
370 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
371 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
372 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
373 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
374 retval(1) = result.balancing_matrix2 (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
375 // fall through |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
376 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
377 retval(0) = result.balancing_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
378 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
379 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
380 error ("balance: invalid number of output arguments"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
381 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
382 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
383 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9821
diff
changeset
|
384 } |
2928 | 385 } |
3185 | 386 |
2928 | 387 return retval; |
388 } |