annotate src/DLD-FUNCTIONS/schur.cc @ 10822:23d2378512a0

implement rsf2csf
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 27 Jul 2010 11:26:43 +0200
parents 9c9e07f5eb1c
children 1e6664326d32
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
10617
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
41 template <class Matrix>
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
42 static octave_value
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
43 mark_upper_triangular (const Matrix& a)
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
44 {
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
45 octave_value retval = a;
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
46
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
47 octave_idx_type n = a.rows ();
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
48 assert (a.columns () == n);
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
49
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
50 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
51
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
52 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
53 if (a(i,i) == zero)
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
54 return retval;
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
55
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
56 retval.matrix_type (MatrixType::Upper);
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
57
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
58 return retval;
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
59 }
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
60
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
61 DEFUN_DLD (schur, args, nargout,
3548
ab7fa5a8f23f [project @ 2000-02-03 01:17:15 by jwe]
jwe
parents: 3523
diff changeset
62 "-*- texinfo -*-\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
63 @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
64 @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
65 @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
66 @cindex Schur decomposition\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
67 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
68 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
69 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
70 @code{schur} always returns\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
71 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
72 $S = U^T A U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
73 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
74 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
75 @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
76 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
77 where\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
78 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
79 $U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
80 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
81 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
82 @code{u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
83 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
84 is a unitary matrix\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
85 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
86 ($U^T U$ is identity)\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
87 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
88 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
89 (@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
90 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
91 and\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
92 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
93 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
94 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
95 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
96 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
97 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
98 is upper triangular. The eigenvalues of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
99 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
100 $A$ (and $S$)\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
101 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
102 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
103 @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
104 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
105 are the diagonal elements of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
106 @tex\n\
5555
dbdba35033a6 [project @ 2005-11-30 16:12:04 by jwe]
jwe
parents: 5307
diff changeset
107 $S$.\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
108 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
109 @ifnottex\n\
5555
dbdba35033a6 [project @ 2005-11-30 16:12:04 by jwe]
jwe
parents: 5307
diff changeset
110 @code{s}.\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
111 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
112 If the matrix\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
113 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
114 $A$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
115 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
116 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
117 @code{a}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
118 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
119 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
120 matrix\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
121 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
122 $U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
123 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
124 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
125 @code{u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
126 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
127 is orthogonal and\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
128 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
129 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
130 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
131 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
132 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
133 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
134 is block upper triangular\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
135 with blocks of size at most\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
136 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
137 $2\\times 2$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
138 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
139 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
140 @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
141 @end ifnottex\n\
3600
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3548
diff changeset
142 along the diagonal. The diagonal elements of\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
143 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
144 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
145 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
146 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
147 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
148 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
149 (or the eigenvalues of the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
150 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
151 $2\\times 2$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
152 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
153 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
154 @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
155 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
156 blocks, when\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
157 appropriate) are the eigenvalues 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 $A$\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{a}\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 and\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
165 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
166 $S$.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
167 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
168 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
169 @code{s}.\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
170 @end ifnottex\n\
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
171 \n\
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
172 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
173 \n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
174 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
175 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
176 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
177 block of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
178 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
179 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
180 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
181 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
182 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
183 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
184 (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
185 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
186 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
187 $S$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
188 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
189 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
190 @code{s}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
191 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
192 (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
193 no ordering of eigenvalues should occur. The leading\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
194 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
195 $k$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
196 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
197 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
198 @code{k}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
199 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
200 columns of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
201 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
202 $U$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
203 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
204 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
205 @code{u}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
206 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
207 always span the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
208 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
209 $A$-invariant\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
210 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
211 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
212 @code{a}-invariant\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
213 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
214 subspace corresponding to the\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
215 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
216 $k$\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
217 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
218 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
219 @code{k}\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
220 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
221 leading eigenvalues of\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
222 @tex\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
223 $S$.\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
224 @end tex\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
225 @ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
226 @code{s}.\n\
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7814
diff changeset
227 @end ifnottex\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3014
diff changeset
228 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
229 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
230 octave_value_list retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
231
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
232 int nargin = args.length ();
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 if (nargin < 1 || nargin > 2 || nargout > 2)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
235 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5555
diff changeset
236 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
237 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
238 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
239
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
240 octave_value arg = args(0);
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
241
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3372
diff changeset
242 std::string ord;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
243
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
244 if (nargin == 2)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
245 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
246 ord = args(1).string_value ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
247
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
248 if (error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
249 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
250 error ("schur: expecting string as second argument");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
251 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
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
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
255 bool force_complex = false;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
256
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
257 if (ord == "complex")
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
258 {
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
259 force_complex = true;
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
260 ord = std::string ();
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
261 }
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
262 else
2928
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 char ord_char = ord.empty () ? 'U' : ord[0];
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
265
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
266 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
267 && ord_char != 'u' && ord_char != 'a' && ord_char != 'd')
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
268 {
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
269 warning ("schur: incorrect ordered schur argument `%c'",
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
270 ord.c_str ());
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
271 return retval;
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
272 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
273 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
274
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5008
diff changeset
275 octave_idx_type nr = arg.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5008
diff changeset
276 octave_idx_type nc = arg.columns ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
277
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
278 if (nr != nc)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
279 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
280 gripe_square_matrix_required ("schur");
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
281 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
282 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
283
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
284 if (! arg.is_numeric_type ())
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
285 gripe_wrong_type_arg ("schur", arg);
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
286 else if (arg.is_single_type ())
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
287 {
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
288 if (! force_complex && arg.is_real_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
289 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
290 FloatMatrix tmp = arg.float_matrix_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
291
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
292 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
293 {
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 FloatSCHUR result (tmp, 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 FloatSCHUR result (tmp, 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 }
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
307 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
308 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
309 FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
310
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
311 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
312 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
313
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
314 if (nargout == 0 || nargout == 1)
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 FloatComplexSCHUR result (ctmp, ord, false);
10617
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
317 retval(0) = mark_upper_triangular (result.schur_matrix ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
318 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
319 else
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 FloatComplexSCHUR result (ctmp, ord, true);
10617
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
322 retval(1) = mark_upper_triangular (result.schur_matrix ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
323 retval(0) = result.unitary_matrix ();
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 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
326 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
327 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
328 else
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
329 {
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
330 if (! force_complex && arg.is_real_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
331 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
332 Matrix tmp = arg.matrix_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
333
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
334 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
335 {
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 SCHUR result (tmp, 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 SCHUR result (tmp, 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 }
10607
f7501986e42d make schur more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10155
diff changeset
349 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
350 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
351 ComplexMatrix ctmp = arg.complex_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
352
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
353 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
354 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
355
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
356 if (nargout == 0 || nargout == 1)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
357 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
358 ComplexSCHUR result (ctmp, ord, false);
10617
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
359 retval(0) = mark_upper_triangular (result.schur_matrix ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
360 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
361 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
362 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
363 ComplexSCHUR result (ctmp, ord, true);
10617
9c9e07f5eb1c make schur mark triangular matrices on output
Jaroslav Hajek <highegg@gmail.com>
parents: 10607
diff changeset
364 retval(1) = mark_upper_triangular (result.schur_matrix ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
365 retval(0) = result.unitary_matrix ();
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 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
368 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
369 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
370
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
371 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
372 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
373
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
374 /*
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
375
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
376 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
377 %! 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
378 %! [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
379 %! 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
380
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
381 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
382 %! 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
383 %! [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
384 %! 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
385
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
386 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
387 %! 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
388
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
389 %!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
390 %!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
391
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
392 */
10822
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
393
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
394 DEFUN_DLD (rsf2csf, args, nargout,
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
395 "-*- texinfo -*-\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
396 @deftypefn {Function File} {[@var{U}, @var{T}] =} rsf2csf (@var{UR}, @var{TR})\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
397 Converts a real, upper quasi-triangular Schur form @var{TR} to a complex,\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
398 upper triangular Schur form @var{T}.\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
399 \n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
400 Note that the following relations hold: \n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
401 \n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
402 @code{@var{UR} * @var{TR} * @var{UR}' = @var{U} * @var{T} * @var{U}'} and\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
403 @code{@var{U}' * @var{U}} is identity.\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
404 \n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
405 Note also that U and T are not unique.\n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
406 \n\
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
407 @end deftypefn")
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
408 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
409 octave_value_list retval;
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
410
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
411 if (args.length () == 2 && nargout <= 2)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
412 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
413 if (! args(0).is_numeric_type ())
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
414 gripe_wrong_type_arg ("rsf2csf", args(0));
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
415 else if (! args(1).is_numeric_type ())
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
416 gripe_wrong_type_arg ("rsf2csf", args(1));
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
417 else if (args(0).is_complex_type () || args(1).is_complex_type ())
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
418 error ("rsf2csf: both matrices should be real");
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
419 else
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
420 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
421
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
422 if (args(0).is_single_type () || args(1).is_single_type ())
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
423 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
424 FloatMatrix u = args(0).float_matrix_value ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
425 FloatMatrix t = args(1).float_matrix_value ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
426 if (! error_state)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
427 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
428 FloatComplexSCHUR cs (FloatSCHUR (t, u));
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
429
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
430 retval(1) = cs.schur_matrix ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
431 retval(0) = cs.unitary_matrix ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
432 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
433 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
434 else
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
435 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
436 Matrix u = args(0).matrix_value ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
437 Matrix t = args(1).matrix_value ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
438 if (! error_state)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
439 {
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
440 ComplexSCHUR cs (SCHUR (t, u));
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
441
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
442 retval(1) = cs.schur_matrix ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
443 retval(0) = cs.unitary_matrix ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
444 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
445 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
446 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
447 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
448 else
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
449 print_usage ();
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
450
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
451 return retval;
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
452 }
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
453
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
454 /*
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
455
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
456 %!test
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
457 %! A = [1, 1, 1, 2; 1, 2, 1, 1; 1, 1, 3, 1; -2, 1, 1, 1];
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
458 %! [u, t] = schur (A);
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
459 %! [U, T] = rsf2csf (u, t);
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
460 %! assert (norm (u * t * u' - U * T * U'), 0, 1e-12)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
461 %! assert (norm (A - U * T * U'), 0, 1e-12)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
462
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
463 %!test
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
464 %! A = rand (10);
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
465 %! [u, t] = schur (A);
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
466 %! [U, T] = rsf2csf (u, t);
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
467 %! assert (norm (tril (T, -1)), 0)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
468 %! assert (norm (U * U'), 1, 1e-14)
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
469
23d2378512a0 implement rsf2csf
Jaroslav Hajek <highegg@gmail.com>
parents: 10617
diff changeset
470 */