annotate src/DLD-FUNCTIONS/schur.cc @ 10607:f7501986e42d

make schur more Matlab compatible
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 06 May 2010 09:49:36 +0200
parents d0ce5e973937
children 9c9e07f5eb1c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
1 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8517
diff changeset
3 Copyright (C) 1996, 1997, 1999, 2000, 2004, 2005, 2006, 2007, 2008, 2009
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 John W. Eaton
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
5
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
7
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
11 option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
12
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
16 for more details.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
17
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
20 <http://www.gnu.org/licenses/>.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
21
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
22 */
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
23
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
26 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
27
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28 #include <string>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
30 #include "CmplxSCHUR.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
31 #include "dbleSCHUR.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
32 #include "fCmplxSCHUR.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
33 #include "floatSCHUR.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
34
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
35 #include "defun-dld.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36 #include "error.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
37 #include "gripes.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38 #include "oct-obj.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
39 #include "utils.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
40
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
41 DEFUN_DLD (schur, args, nargout,
3548
ab7fa5a8f23f [project @ 2000-02-03 01:17:15 by jwe]
jwe
parents: 3523
diff changeset
42 "-*- texinfo -*-\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
43 @deftypefn {Loadable Function} {@var{s} =} schur (@var{a})\n\
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
44 @deftypefnx {Loadable Function} {@var{s} =} schur (@var{a}, \"complex\")\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
45 @deftypefnx {Loadable Function} {[@var{u}, @var{s}] =} schur (@var{a}, @var{opt})\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
46 @cindex Schur decomposition\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
47 The Schur decomposition is used to compute eigenvalues of a\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
48 square matrix, and has applications in the solution of algebraic\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
49 Riccati equations in control (see @code{are} and @code{dare}).\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
50 @code{schur} always returns\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
51 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
52 $S = U^T A U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
53 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
54 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
55 @code{s = u' * a * u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
56 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
57 where\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
58 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
59 $U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
60 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
61 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
62 @code{u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
63 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
64 is a unitary matrix\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
65 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
66 ($U^T U$ is identity)\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
67 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
68 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
69 (@code{u'* u} is identity)\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
70 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
71 and\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
72 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
73 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
74 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
75 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
76 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
77 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
78 is upper triangular. The eigenvalues of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
79 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
80 $A$ (and $S$)\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
81 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
82 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
83 @code{a} (and @code{s})\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
84 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
85 are the diagonal elements of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
86 @tex\n\
5555
dbdba35033a6 [project @ 2005-11-30 16:12:04 by jwe]
jwe
parents: 5307
diff changeset
87 $S$.\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
88 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
89 @ifnottex\n\
5555
dbdba35033a6 [project @ 2005-11-30 16:12:04 by jwe]
jwe
parents: 5307
diff changeset
90 @code{s}.\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
91 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
92 If the matrix\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
93 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
94 $A$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
95 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
96 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
97 @code{a}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
98 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
99 is real, then the real Schur decomposition is computed, in which the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
100 matrix\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
101 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
102 $U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
103 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
104 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
105 @code{u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
106 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
107 is orthogonal and\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
108 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
109 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
110 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
111 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
112 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
113 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
114 is block upper triangular\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
115 with blocks of size at most\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
116 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
117 $2\\times 2$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
118 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
119 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
120 @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
121 @end ifnottex\n\
3600
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3548
diff changeset
122 along the diagonal. The diagonal elements of\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
123 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
124 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
125 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
126 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
127 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
128 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
129 (or the eigenvalues of the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
130 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
131 $2\\times 2$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
132 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
133 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
134 @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
135 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
136 blocks, when\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
137 appropriate) are the eigenvalues of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
138 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
139 $A$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
140 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
141 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
142 @code{a}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
143 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
144 and\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
145 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
146 $S$.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
147 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
148 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
149 @code{s}.\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
150 @end ifnottex\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
151 \n\
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
152 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
153 \n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
154 The eigenvalues are optionally ordered along the diagonal according to\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
155 the value of @code{opt}. @code{opt = \"a\"} indicates that all\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
156 eigenvalues with negative real parts should be moved to the leading\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
157 block of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
158 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
159 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
160 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
161 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
162 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
163 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
164 (used in @code{are}), @code{opt = \"d\"} indicates that all eigenvalues\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
165 with magnitude less than one should be moved to the leading block of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
166 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
167 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
168 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
169 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
170 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
171 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
172 (used in @code{dare}), and @code{opt = \"u\"}, the default, indicates that\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
173 no ordering of eigenvalues should occur. The leading\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
174 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
175 $k$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
176 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
177 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
178 @code{k}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
179 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
180 columns of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
181 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
182 $U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
183 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
184 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
185 @code{u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
186 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
187 always span the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
188 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
189 $A$-invariant\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
190 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
191 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
192 @code{a}-invariant\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
193 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
194 subspace corresponding to the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
195 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
196 $k$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
197 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
198 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
199 @code{k}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
200 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
201 leading eigenvalues of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
202 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
203 $S$.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
204 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
205 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
206 @code{s}.\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
207 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
208 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
209 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
210 octave_value_list retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
211
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
212 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
213
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
214 if (nargin < 1 || nargin > 2 || nargout > 2)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
215 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5555
diff changeset
216 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
217 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
218 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
219
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
220 octave_value arg = args(0);
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
221
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3372
diff changeset
222 std::string ord;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
223
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
224 if (nargin == 2)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
225 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
226 ord = args(1).string_value ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
227
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
228 if (error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
229 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
230 error ("schur: expecting string as second argument");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
231 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
232 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
233 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
234
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
235 bool force_complex = false;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
236
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
237 if (ord == "complex")
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
238 {
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
239 force_complex = true;
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
240 ord = std::string ();
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
241 }
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
242 else
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
243 {
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
244 char ord_char = ord.empty () ? 'U' : ord[0];
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
245
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
246 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
247 && ord_char != 'u' && ord_char != 'a' && ord_char != 'd')
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
248 {
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
249 warning ("schur: incorrect ordered schur argument `%c'",
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
250 ord.c_str ());
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
251 return retval;
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
252 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
253 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
254
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5008
diff changeset
255 octave_idx_type nr = arg.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5008
diff changeset
256 octave_idx_type nc = arg.columns ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
257
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
258 if (nr != nc)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
259 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
260 gripe_square_matrix_required ("schur");
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
261 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
262 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
263
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
264 if (! arg.is_numeric_type ())
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
265 gripe_wrong_type_arg ("schur", arg);
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
266 else if (arg.is_single_type ())
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
267 {
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
268 if (! force_complex && arg.is_real_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
269 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
270 FloatMatrix tmp = arg.float_matrix_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
271
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
272 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
273 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
274 if (nargout == 0 || nargout == 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
275 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
276 FloatSCHUR result (tmp, ord, false);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
277 retval(0) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
278 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
279 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
280 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
281 FloatSCHUR result (tmp, ord, true);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
282 retval(1) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
283 retval(0) = result.unitary_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
284 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
285 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
286 }
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
287 else
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 FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
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 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
293
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
294 if (nargout == 0 || nargout == 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
295 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
296 FloatComplexSCHUR result (ctmp, ord, false);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
297 retval(0) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
298 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
299 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
300 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
301 FloatComplexSCHUR result (ctmp, ord, true);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
302 retval(1) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
303 retval(0) = result.unitary_matrix ();
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 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
306 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
307 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
308 else
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
309 {
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
310 if (! force_complex && arg.is_real_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
311 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
312 Matrix tmp = arg.matrix_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
313
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
314 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
315 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
316 if (nargout == 0 || nargout == 1)
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 SCHUR result (tmp, ord, false);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
319 retval(0) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
320 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
321 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
322 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
323 SCHUR result (tmp, ord, true);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
324 retval(1) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
325 retval(0) = result.unitary_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
326 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
327 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
328 }
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
329 else
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 ComplexMatrix ctmp = arg.complex_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
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 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
335
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
336 if (nargout == 0 || nargout == 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
337 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
338 ComplexSCHUR result (ctmp, ord, false);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
339 retval(0) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
340 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
341 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
342 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
343 ComplexSCHUR result (ctmp, ord, true);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
344 retval(1) = result.schur_matrix ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
345 retval(0) = result.unitary_matrix ();
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 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
348 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
349 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
350
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
351 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
352 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
353
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
354 /*
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
355
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
356 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
357 %! 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
358 %! [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
359 %! 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
360
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
361 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
362 %! 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
363 %! [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
364 %! 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
365
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
366 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
367 %! 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
368
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
369 %!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
370 %!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
371
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
372 */