Mercurial > octave
annotate src/DLD-FUNCTIONS/schur.cc @ 11553:01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Use same variable names in error() strings and in documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 16 Jan 2011 22:13:23 -0800 |
parents | fd0a3ac60b0e |
children | 12df7854fa7c |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2928 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <string> | |
28 | |
29 #include "CmplxSCHUR.h" | |
30 #include "dbleSCHUR.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
31 #include "fCmplxSCHUR.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
32 #include "floatSCHUR.h" |
2928 | 33 |
34 #include "defun-dld.h" | |
35 #include "error.h" | |
36 #include "gripes.h" | |
37 #include "oct-obj.h" | |
38 #include "utils.h" | |
39 | |
10617
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
40 template <class Matrix> |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
41 static octave_value |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
42 mark_upper_triangular (const Matrix& a) |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
43 { |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
44 octave_value retval = a; |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
45 |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
46 octave_idx_type n = a.rows (); |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
47 assert (a.columns () == n); |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
48 |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
49 const typename Matrix::element_type zero = typename Matrix::element_type (); |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
50 |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
51 for (octave_idx_type i = 0; i < n; i++) |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
52 if (a(i,i) == zero) |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
53 return retval; |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
54 |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
55 retval.matrix_type (MatrixType::Upper); |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
56 |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
57 return retval; |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
58 } |
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
59 |
2928 | 60 DEFUN_DLD (schur, args, nargout, |
3548 | 61 "-*- texinfo -*-\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
62 @deftypefn {Loadable Function} {@var{S} =} schur (@var{A})\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
63 @deftypefnx {Loadable Function} {@var{S} =} schur (@var{A}, \"complex\")\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 @deftypefnx {Loadable Function} {[@var{U}, @var{S}] =} schur (@var{A}, @var{opt})\n\ |
3372 | 65 @cindex Schur decomposition\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
66 The Schur@tie{}decomposition is used to compute eigenvalues of a\n\ |
3372 | 67 square matrix, and has applications in the solution of algebraic\n\ |
68 Riccati equations in control (see @code{are} and @code{dare}).\n\ | |
69 @code{schur} always returns\n\ | |
70 @tex\n\ | |
71 $S = U^T A U$\n\ | |
72 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
73 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
74 @code{@var{S} = @var{U}' * @var{A} * @var{U}}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
75 @end ifnottex\n\ |
3372 | 76 where\n\ |
77 @tex\n\ | |
78 $U$\n\ | |
79 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
80 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
81 @var{U}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
82 @end ifnottex\n\ |
3372 | 83 is a unitary matrix\n\ |
84 @tex\n\ | |
85 ($U^T U$ is identity)\n\ | |
86 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
87 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
88 (@code{@var{U}'* @var{U}} is identity)\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
89 @end ifnottex\n\ |
3372 | 90 and\n\ |
91 @tex\n\ | |
92 $S$\n\ | |
93 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
94 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
95 @var{S}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
96 @end ifnottex\n\ |
3372 | 97 is upper triangular. The eigenvalues of\n\ |
98 @tex\n\ | |
99 $A$ (and $S$)\n\ | |
100 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
101 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
102 @var{A} (and @var{S})\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
103 @end ifnottex\n\ |
3372 | 104 are the diagonal elements of\n\ |
105 @tex\n\ | |
5555 | 106 $S$.\n\ |
3372 | 107 @end tex\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
108 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
109 @var{S}.\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
110 @end ifnottex\n\ |
3372 | 111 If the matrix\n\ |
112 @tex\n\ | |
113 $A$\n\ | |
114 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
115 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
116 @var{A}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
117 @end ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
118 is real, then the real Schur@tie{}decomposition is computed, in which the\n\ |
3372 | 119 matrix\n\ |
120 @tex\n\ | |
121 $U$\n\ | |
122 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
123 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
124 @var{U}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
125 @end ifnottex\n\ |
3372 | 126 is orthogonal and\n\ |
127 @tex\n\ | |
128 $S$\n\ | |
129 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
130 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
131 @var{S}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
132 @end ifnottex\n\ |
3372 | 133 is block upper triangular\n\ |
134 with blocks of size at most\n\ | |
135 @tex\n\ | |
136 $2\\times 2$\n\ | |
137 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
138 @ifnottex\n\ |
3372 | 139 @code{2 x 2}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
140 @end ifnottex\n\ |
3600 | 141 along the diagonal. The diagonal elements of\n\ |
3372 | 142 @tex\n\ |
143 $S$\n\ | |
144 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
145 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
146 @var{S}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
147 @end ifnottex\n\ |
3372 | 148 (or the eigenvalues of the\n\ |
149 @tex\n\ | |
150 $2\\times 2$\n\ | |
151 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
152 @ifnottex\n\ |
3372 | 153 @code{2 x 2}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
154 @end ifnottex\n\ |
3372 | 155 blocks, when\n\ |
156 appropriate) are the eigenvalues of\n\ | |
157 @tex\n\ | |
158 $A$\n\ | |
159 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
160 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
161 @var{A}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
162 @end ifnottex\n\ |
3372 | 163 and\n\ |
164 @tex\n\ | |
165 $S$.\n\ | |
166 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
167 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
168 @var{S}.\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
169 @end ifnottex\n\ |
2928 | 170 \n\ |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
171 A complex decomposition may be forced by passing \"complex\" as @var{opt}.\n\ |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
172 \n\ |
3372 | 173 The eigenvalues are optionally ordered along the diagonal according to\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
174 the value of @var{opt}. @code{@var{opt} = \"a\"} indicates that all\n\ |
3372 | 175 eigenvalues with negative real parts should be moved to the leading\n\ |
176 block of\n\ | |
177 @tex\n\ | |
178 $S$\n\ | |
179 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
180 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
181 @var{S}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
182 @end ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
183 (used in @code{are}), @code{@var{opt} = \"d\"} indicates that all eigenvalues\n\ |
3372 | 184 with magnitude less than one should be moved to the leading block of\n\ |
185 @tex\n\ | |
186 $S$\n\ | |
187 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
188 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
189 @var{S}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
190 @end ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
191 (used in @code{dare}), and @code{@var{opt} = \"u\"}, the default, indicates\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
192 that no ordering of eigenvalues should occur. The leading\n\ |
3372 | 193 @tex\n\ |
194 $k$\n\ | |
195 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
196 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
197 @var{k}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
198 @end ifnottex\n\ |
3372 | 199 columns of\n\ |
200 @tex\n\ | |
201 $U$\n\ | |
202 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
203 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
204 @var{U}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
205 @end ifnottex\n\ |
3372 | 206 always span the\n\ |
207 @tex\n\ | |
208 $A$-invariant\n\ | |
209 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
210 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
211 @var{A}-invariant\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
212 @end ifnottex\n\ |
3372 | 213 subspace corresponding to the\n\ |
214 @tex\n\ | |
215 $k$\n\ | |
216 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
217 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
218 @var{k}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
219 @end ifnottex\n\ |
3372 | 220 leading eigenvalues of\n\ |
221 @tex\n\ | |
222 $S$.\n\ | |
223 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
224 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
225 @var{S}.\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
226 @end ifnottex\n\ |
3372 | 227 @end deftypefn") |
2928 | 228 { |
229 octave_value_list retval; | |
230 | |
231 int nargin = args.length (); | |
232 | |
233 if (nargin < 1 || nargin > 2 || nargout > 2) | |
234 { | |
5823 | 235 print_usage (); |
2928 | 236 return retval; |
237 } | |
238 | |
239 octave_value arg = args(0); | |
240 | |
3523 | 241 std::string ord; |
2928 | 242 |
243 if (nargin == 2) | |
244 { | |
245 ord = args(1).string_value (); | |
246 | |
247 if (error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
248 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
249 error ("schur: second argument must be a string"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
250 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
251 } |
2928 | 252 } |
253 | |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
254 bool force_complex = false; |
2928 | 255 |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
256 if (ord == "complex") |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
257 { |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
258 force_complex = true; |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
259 ord = std::string (); |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
260 } |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
261 else |
2928 | 262 { |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
263 char ord_char = ord.empty () ? 'U' : ord[0]; |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
264 |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
265 if (ord_char != 'U' && ord_char != 'A' && ord_char != 'D' |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
266 && ord_char != 'u' && ord_char != 'a' && ord_char != 'd') |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
267 { |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
268 warning ("schur: incorrect ordered schur argument `%c'", |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
269 ord.c_str ()); |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
270 return retval; |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
271 } |
2928 | 272 } |
273 | |
5275 | 274 octave_idx_type nr = arg.rows (); |
275 octave_idx_type nc = arg.columns (); | |
2928 | 276 |
277 if (nr != nc) | |
278 { | |
279 gripe_square_matrix_required ("schur"); | |
280 return retval; | |
281 } | |
282 | |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
283 if (! arg.is_numeric_type ()) |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
284 gripe_wrong_type_arg ("schur", arg); |
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
285 else if (arg.is_single_type ()) |
2928 | 286 { |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
287 if (! force_complex && arg.is_real_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
288 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
289 FloatMatrix tmp = arg.float_matrix_value (); |
2928 | 290 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
291 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
292 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
293 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
294 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
295 FloatSCHUR result (tmp, ord, false); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
296 retval(0) = result.schur_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
297 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
298 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
299 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
300 FloatSCHUR result (tmp, ord, true); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
301 retval(1) = result.schur_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
302 retval(0) = result.unitary_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
303 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
304 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
305 } |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
306 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
307 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
308 FloatComplexMatrix ctmp = arg.float_complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
309 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
310 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
311 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
312 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
313 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
314 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
315 FloatComplexSCHUR result (ctmp, ord, false); |
10617
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
316 retval(0) = mark_upper_triangular (result.schur_matrix ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
317 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
318 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
319 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
320 FloatComplexSCHUR result (ctmp, ord, true); |
10617
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
321 retval(1) = mark_upper_triangular (result.schur_matrix ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
322 retval(0) = result.unitary_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
323 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
324 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
325 } |
2928 | 326 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
327 else |
2928 | 328 { |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
329 if (! force_complex && arg.is_real_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
330 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
331 Matrix tmp = arg.matrix_value (); |
2928 | 332 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
333 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
334 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
335 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
336 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
337 SCHUR result (tmp, ord, false); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
338 retval(0) = result.schur_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
339 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
340 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
341 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
342 SCHUR result (tmp, ord, true); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
343 retval(1) = result.schur_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
344 retval(0) = result.unitary_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
345 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
346 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
347 } |
10607
f7501986e42d
make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
348 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
349 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
350 ComplexMatrix ctmp = arg.complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
351 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
352 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
353 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
354 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
355 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
356 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
357 ComplexSCHUR result (ctmp, ord, false); |
10617
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
358 retval(0) = mark_upper_triangular (result.schur_matrix ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
359 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
360 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
361 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
362 ComplexSCHUR result (ctmp, ord, true); |
10617
9c9e07f5eb1c
make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents:
10607
diff
changeset
|
363 retval(1) = mark_upper_triangular (result.schur_matrix ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
364 retval(0) = result.unitary_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
365 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
366 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
367 } |
2928 | 368 } |
369 | |
370 return retval; | |
371 } | |
372 | |
373 /* | |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
374 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
375 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
376 %! a = [1, 2, 3; 4, 5, 9; 7, 8, 6]; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
377 %! [u, s] = schur (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
378 %! assert(u' * a * u, s, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
379 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
380 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
381 %! a = single([1, 2, 3; 4, 5, 9; 7, 8, 6]); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
382 %! [u, s] = schur (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
383 %! assert(u' * a * u, s, sqrt (eps('single'))); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
384 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
385 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
386 %! fail("schur ([1, 2; 3, 4], 2)","warning"); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
387 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
388 %!error <Invalid call to schur.*> schur (); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
389 %!error schur ([1, 2, 3; 4, 5, 6]); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
390 |
2928 | 391 */ |
10822 | 392 |
393 DEFUN_DLD (rsf2csf, args, nargout, | |
394 "-*- texinfo -*-\n\ | |
395 @deftypefn {Function File} {[@var{U}, @var{T}] =} rsf2csf (@var{UR}, @var{TR})\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
396 Convert a real, upper quasi-triangular Schur@tie{}form @var{TR} to a complex,\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
397 upper triangular Schur@tie{}form @var{T}.\n\ |
10822 | 398 \n\ |
399 Note that the following relations hold: \n\ | |
400 \n\ | |
401 @code{@var{UR} * @var{TR} * @var{UR}' = @var{U} * @var{T} * @var{U}'} and\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
402 @code{@var{U}' * @var{U}} is the identity matrix I.\n\ |
10822 | 403 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
404 Note also that @var{U} and @var{T} are not unique.\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
405 @seealso{schur}\n\ |
10822 | 406 @end deftypefn") |
407 { | |
408 octave_value_list retval; | |
409 | |
410 if (args.length () == 2 && nargout <= 2) | |
411 { | |
412 if (! args(0).is_numeric_type ()) | |
413 gripe_wrong_type_arg ("rsf2csf", args(0)); | |
414 else if (! args(1).is_numeric_type ()) | |
415 gripe_wrong_type_arg ("rsf2csf", args(1)); | |
416 else if (args(0).is_complex_type () || args(1).is_complex_type ()) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
417 error ("rsf2csf: UR and TR must be real matrices"); |
10822 | 418 else |
419 { | |
420 | |
421 if (args(0).is_single_type () || args(1).is_single_type ()) | |
422 { | |
423 FloatMatrix u = args(0).float_matrix_value (); | |
424 FloatMatrix t = args(1).float_matrix_value (); | |
425 if (! error_state) | |
426 { | |
427 FloatComplexSCHUR cs (FloatSCHUR (t, u)); | |
428 | |
429 retval(1) = cs.schur_matrix (); | |
430 retval(0) = cs.unitary_matrix (); | |
431 } | |
432 } | |
433 else | |
434 { | |
435 Matrix u = args(0).matrix_value (); | |
436 Matrix t = args(1).matrix_value (); | |
437 if (! error_state) | |
438 { | |
439 ComplexSCHUR cs (SCHUR (t, u)); | |
440 | |
441 retval(1) = cs.schur_matrix (); | |
442 retval(0) = cs.unitary_matrix (); | |
443 } | |
444 } | |
445 } | |
446 } | |
447 else | |
448 print_usage (); | |
449 | |
450 return retval; | |
451 } | |
452 | |
453 /* | |
454 | |
455 %!test | |
456 %! A = [1, 1, 1, 2; 1, 2, 1, 1; 1, 1, 3, 1; -2, 1, 1, 1]; | |
457 %! [u, t] = schur (A); | |
458 %! [U, T] = rsf2csf (u, t); | |
459 %! assert (norm (u * t * u' - U * T * U'), 0, 1e-12) | |
460 %! assert (norm (A - U * T * U'), 0, 1e-12) | |
461 | |
462 %!test | |
463 %! A = rand (10); | |
464 %! [u, t] = schur (A); | |
465 %! [U, T] = rsf2csf (u, t); | |
466 %! assert (norm (tril (T, -1)), 0) | |
467 %! assert (norm (U * U'), 1, 1e-14) | |
468 | |
469 */ |