Mercurial > octave-nkf
annotate src/DLD-FUNCTIONS/qz.cc @ 10350:12884915a8e4
merge MArray classes & improve Array interface
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 23 Jan 2010 21:41:03 +0100 |
parents | a217e1d74353 |
children | 3140cb7a05a1 |
rev | line source |
---|---|
3183 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, |
4 2008, 2009 A. S. Hodel | |
3183 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3183 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3183 | 21 |
22 */ | |
23 | |
24 // Generalized eigenvalue balancing via LAPACK | |
3911 | 25 |
26 // Author: A. S. Hodel <scotte@eng.auburn.edu> | |
3183 | 27 |
28 #undef DEBUG | |
29 #undef DEBUG_SORT | |
30 #undef DEBUG_EIG | |
31 | |
9786
2c279308f6ab
fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
32 #ifdef HAVE_CONFIG_H |
2c279308f6ab
fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
33 #include <config.h> |
2c279308f6ab
fix includes in some src/DLD-FUNCTIONS files
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
34 #endif |
3183 | 35 |
36 #include <cfloat> | |
4051 | 37 |
3523 | 38 #include <iostream> |
4051 | 39 #include <iomanip> |
3183 | 40 |
41 #include "CmplxQRP.h" | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
42 #include "CmplxQR.h" |
3183 | 43 #include "dbleQR.h" |
4153 | 44 #include "f77-fcn.h" |
7231 | 45 #include "lo-math.h" |
4153 | 46 #include "quit.h" |
47 | |
3183 | 48 #include "defun-dld.h" |
49 #include "error.h" | |
50 #include "gripes.h" | |
51 #include "oct-obj.h" | |
52 #include "oct-map.h" | |
53 #include "ov.h" | |
54 #include "pager.h" | |
3185 | 55 #if defined (DEBUG) || defined (DEBUG_SORT) |
3183 | 56 #include "pr-output.h" |
57 #endif | |
58 #include "symtab.h" | |
59 #include "utils.h" | |
60 #include "variables.h" | |
61 | |
5275 | 62 typedef octave_idx_type (*sort_function) (const octave_idx_type& LSIZE, const double& ALPHA, |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
63 const double& BETA, const double& S, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
64 const double& P); |
3183 | 65 |
66 extern "C" | |
67 { | |
4552 | 68 F77_RET_T |
69 F77_FUNC (dggbal, DGGBAL) (F77_CONST_CHAR_ARG_DECL, | |
10311 | 70 const octave_idx_type& N, double* A, |
71 const octave_idx_type& LDA, double* B, | |
72 const octave_idx_type& LDB, octave_idx_type& ILO, | |
73 octave_idx_type& IHI, double* LSCALE, | |
74 double* RSCALE, double* WORK, | |
75 octave_idx_type& INFO | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
76 F77_CHAR_ARG_LEN_DECL); |
3183 | 77 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
78 F77_RET_T |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
79 F77_FUNC (zggbal, ZGGBAL) (F77_CONST_CHAR_ARG_DECL, |
10311 | 80 const octave_idx_type& N, Complex* A, |
81 const octave_idx_type& LDA, Complex* B, | |
82 const octave_idx_type& LDB, octave_idx_type& ILO, | |
83 octave_idx_type& IHI, double* LSCALE, | |
84 double* RSCALE, double* WORK, | |
85 octave_idx_type& INFO | |
86 F77_CHAR_ARG_LEN_DECL); | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
87 |
4552 | 88 F77_RET_T |
89 F77_FUNC (dggbak, DGGBAK) (F77_CONST_CHAR_ARG_DECL, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
90 F77_CONST_CHAR_ARG_DECL, |
10311 | 91 const octave_idx_type& N, |
92 const octave_idx_type& ILO, | |
93 const octave_idx_type& IHI, | |
94 const double* LSCALE, const double* RSCALE, | |
95 octave_idx_type& M, double* V, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
96 const octave_idx_type& LDV, octave_idx_type& INFO |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
97 F77_CHAR_ARG_LEN_DECL |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
98 F77_CHAR_ARG_LEN_DECL); |
3183 | 99 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
100 F77_RET_T |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
101 F77_FUNC (zggbak, ZGGBAK) (F77_CONST_CHAR_ARG_DECL, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
102 F77_CONST_CHAR_ARG_DECL, |
10311 | 103 const octave_idx_type& N, |
104 const octave_idx_type& ILO, | |
105 const octave_idx_type& IHI, | |
106 const double* LSCALE, const double* RSCALE, | |
107 octave_idx_type& M, Complex* V, | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
108 const octave_idx_type& LDV, octave_idx_type& INFO |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
109 F77_CHAR_ARG_LEN_DECL |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
110 F77_CHAR_ARG_LEN_DECL); |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
111 |
4552 | 112 F77_RET_T |
113 F77_FUNC (dgghrd, DGGHRD) (F77_CONST_CHAR_ARG_DECL, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
114 F77_CONST_CHAR_ARG_DECL, |
10311 | 115 const octave_idx_type& N, |
116 const octave_idx_type& ILO, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
117 const octave_idx_type& IHI, double* A, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
118 const octave_idx_type& LDA, double* B, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
119 const octave_idx_type& LDB, double* Q, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
120 const octave_idx_type& LDQ, double* Z, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
121 const octave_idx_type& LDZ, octave_idx_type& INFO |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
122 F77_CHAR_ARG_LEN_DECL |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
123 F77_CHAR_ARG_LEN_DECL); |
3183 | 124 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
125 F77_RET_T |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
126 F77_FUNC (zgghrd, ZGGHRD) (F77_CONST_CHAR_ARG_DECL, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
127 F77_CONST_CHAR_ARG_DECL, |
10311 | 128 const octave_idx_type& N, |
129 const octave_idx_type& ILO, | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
130 const octave_idx_type& IHI, Complex* A, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
131 const octave_idx_type& LDA, Complex* B, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
132 const octave_idx_type& LDB, Complex* Q, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
133 const octave_idx_type& LDQ, Complex* Z, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
134 const octave_idx_type& LDZ, octave_idx_type& INFO |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
135 F77_CHAR_ARG_LEN_DECL |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
136 F77_CHAR_ARG_LEN_DECL); |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
137 |
4552 | 138 F77_RET_T |
139 F77_FUNC (dhgeqz, DHGEQZ) (F77_CONST_CHAR_ARG_DECL, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
140 F77_CONST_CHAR_ARG_DECL, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
141 F77_CONST_CHAR_ARG_DECL, |
10311 | 142 const octave_idx_type& N, |
143 const octave_idx_type& ILO, | |
144 const octave_idx_type& IHI, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
145 double* A, const octave_idx_type& LDA, double* B, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
146 const octave_idx_type& LDB, double* ALPHAR, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
147 double* ALPHAI, double* BETA, double* Q, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
148 const octave_idx_type& LDQ, double* Z, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
149 const octave_idx_type& LDZ, double* WORK, |
10311 | 150 const octave_idx_type& LWORK, |
151 octave_idx_type& INFO | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
152 F77_CHAR_ARG_LEN_DECL |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
153 F77_CHAR_ARG_LEN_DECL |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
154 F77_CHAR_ARG_LEN_DECL); |
3183 | 155 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
156 F77_RET_T |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
157 F77_FUNC (zhgeqz, ZHGEQZ) (F77_CONST_CHAR_ARG_DECL, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
158 F77_CONST_CHAR_ARG_DECL, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
159 F77_CONST_CHAR_ARG_DECL, |
10311 | 160 const octave_idx_type& N, |
161 const octave_idx_type& ILO, | |
162 const octave_idx_type& IHI, | |
163 Complex* A, const octave_idx_type& LDA, | |
164 Complex* B, const octave_idx_type& LDB, | |
165 Complex* ALPHA, Complex* BETA, Complex* CQ, | |
166 const octave_idx_type& LDQ, | |
167 Complex* CZ, const octave_idx_type& LDZ, | |
168 Complex* WORK, const octave_idx_type& LWORK, | |
169 double* RWORK, octave_idx_type& INFO | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
170 F77_CHAR_ARG_LEN_DECL |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
171 F77_CHAR_ARG_LEN_DECL |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
172 F77_CHAR_ARG_LEN_DECL); |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
173 |
4552 | 174 F77_RET_T |
10311 | 175 F77_FUNC (dlag2, DLAG2) (const double* A, const octave_idx_type& LDA, |
176 const double* B, const octave_idx_type& LDB, | |
177 const double& SAFMIN, double& SCALE1, | |
178 double& SCALE2, double& WR1, double& WR2, | |
179 double& WI); | |
3183 | 180 |
181 // Van Dooren's code (netlib.org: toms/590) for reordering | |
182 // GEP. Only processes Z, not Q. | |
4552 | 183 F77_RET_T |
10311 | 184 F77_FUNC (dsubsp, DSUBSP) (const octave_idx_type& NMAX, |
185 const octave_idx_type& N, double* A, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
186 double* B, double* Z, sort_function, |
10311 | 187 const double& EPS, octave_idx_type& NDIM, |
188 octave_idx_type& FAIL, octave_idx_type* IND); | |
3183 | 189 |
10311 | 190 // Documentation for DTGEVC incorrectly states that VR, VL are |
3183 | 191 // complex*16; they are declared in DTGEVC as double precision |
10311 | 192 // (probably a cut and paste problem fro ZTGEVC). |
4552 | 193 F77_RET_T |
194 F77_FUNC (dtgevc, DTGEVC) (F77_CONST_CHAR_ARG_DECL, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
195 F77_CONST_CHAR_ARG_DECL, |
10311 | 196 octave_idx_type* SELECT, |
197 const octave_idx_type& N, double* A, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
198 const octave_idx_type& LDA, double* B, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
199 const octave_idx_type& LDB, double* VL, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
200 const octave_idx_type& LDVL, double* VR, |
10311 | 201 const octave_idx_type& LDVR, |
202 const octave_idx_type& MM, octave_idx_type& M, | |
203 double* WORK, octave_idx_type& INFO | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
204 F77_CHAR_ARG_LEN_DECL |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
205 F77_CHAR_ARG_LEN_DECL); |
3183 | 206 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
207 F77_RET_T |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
208 F77_FUNC (ztgevc, ZTGEVC) (F77_CONST_CHAR_ARG_DECL, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
209 F77_CONST_CHAR_ARG_DECL, |
10311 | 210 octave_idx_type* SELECT, |
211 const octave_idx_type& N, const Complex* A, | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
212 const octave_idx_type& LDA,const Complex* B, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
213 const octave_idx_type& LDB, Complex* xVL, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
214 const octave_idx_type& LDVL, Complex* xVR, |
10311 | 215 const octave_idx_type& LDVR, |
216 const octave_idx_type& MM, octave_idx_type& M, | |
217 Complex* CWORK, double* RWORK, | |
218 octave_idx_type& INFO | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
219 F77_CHAR_ARG_LEN_DECL |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
220 F77_CHAR_ARG_LEN_DECL); |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
221 |
4552 | 222 F77_RET_T |
223 F77_FUNC (xdlamch, XDLAMCH) (F77_CONST_CHAR_ARG_DECL, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
224 double& retval |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
225 F77_CHAR_ARG_LEN_DECL); |
3185 | 226 |
4552 | 227 F77_RET_T |
228 F77_FUNC (xdlange, XDLANGE) (F77_CONST_CHAR_ARG_DECL, | |
10311 | 229 const octave_idx_type&, |
230 const octave_idx_type&, const double*, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
231 const octave_idx_type&, double*, double& |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
232 F77_CHAR_ARG_LEN_DECL); |
3183 | 233 } |
234 | |
235 // fcrhp, fin, fout, folhp: | |
236 // routines for ordering of generalized eigenvalues | |
237 // return 1 if test is passed, 0 otherwise | |
238 // fin: |lambda| < 1 | |
239 // fout: |lambda| >= 1 | |
240 // fcrhp: real(lambda) >= 0 | |
241 // folhp: real(lambda) < 0 | |
242 | |
5275 | 243 static octave_idx_type |
244 fcrhp (const octave_idx_type& lsize, const double& alpha, | |
3185 | 245 const double& beta, const double& s, const double&) |
3183 | 246 { |
3185 | 247 if (lsize == 1) |
10311 | 248 return (alpha * beta >= 0 ? 1 : -1); |
3185 | 249 else |
3183 | 250 return (s >= 0 ? 1 : -1); |
251 } | |
3185 | 252 |
5275 | 253 static octave_idx_type |
254 fin (const octave_idx_type& lsize, const double& alpha, | |
3185 | 255 const double& beta, const double&, const double& p) |
3183 | 256 { |
5275 | 257 octave_idx_type retval; |
3183 | 258 |
3185 | 259 if (lsize == 1) |
260 retval = (fabs (alpha) < fabs (beta) ? 1 : -1); | |
261 else | |
262 retval = (fabs (p) < 1 ? 1 : -1); | |
263 | |
264 #ifdef DEBUG | |
3538 | 265 std::cout << "qz: fin: retval=" << retval << std::endl; |
3185 | 266 #endif |
267 | |
3183 | 268 return retval; |
269 } | |
3185 | 270 |
5275 | 271 static octave_idx_type |
272 folhp (const octave_idx_type& lsize, const double& alpha, | |
3185 | 273 const double& beta, const double& s, const double&) |
3183 | 274 { |
3185 | 275 if (lsize == 1) |
10311 | 276 return (alpha * beta < 0 ? 1 : -1); |
3185 | 277 else |
3183 | 278 return (s < 0 ? 1 : -1); |
279 } | |
3185 | 280 |
5275 | 281 static octave_idx_type |
282 fout (const octave_idx_type& lsize, const double& alpha, | |
3185 | 283 const double& beta, const double&, const double& p) |
3183 | 284 { |
3185 | 285 if (lsize == 1) |
286 return (fabs (alpha) >= fabs (beta) ? 1 : -1); | |
287 else | |
288 return (fabs (p) >= 1 ? 1 : -1); | |
3183 | 289 } |
290 | |
291 DEFUN_DLD (qz, args, nargout, | |
3372 | 292 "-*- texinfo -*-\n\ |
293 @deftypefn {Loadable Function} {@var{lambda} =} qz (@var{a}, @var{b})\n\ | |
294 Generalized eigenvalue problem @math{A x = s B x},\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8927
diff
changeset
|
295 @var{QZ} decomposition. There are three ways to call this function:\n\ |
3372 | 296 @enumerate\n\ |
297 @item @code{lambda = qz(A,B)}\n\ | |
3185 | 298 \n\ |
5016 | 299 Computes the generalized eigenvalues\n\ |
300 @tex\n\ | |
301 $\\lambda$\n\ | |
302 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8286
diff
changeset
|
303 @ifnottex\n\ |
5016 | 304 @var{lambda}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8286
diff
changeset
|
305 @end ifnottex\n\ |
5016 | 306 of @math{(A - s B)}.\n\ |
3500 | 307 @item @code{[AA, BB, Q, Z, V, W, lambda] = qz (A, B)}\n\ |
3185 | 308 \n\ |
3372 | 309 Computes qz decomposition, generalized eigenvectors, and \n\ |
5481 | 310 generalized eigenvalues of @math{(A - sB)}\n\ |
5016 | 311 @tex\n\ |
312 $$ AV = BV{ \\rm diag }(\\lambda) $$\n\ | |
313 $$ W^T A = { \\rm diag }(\\lambda)W^T B $$\n\ | |
314 $$ AA = Q^T AZ, BB = Q^T BZ $$\n\ | |
315 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8286
diff
changeset
|
316 @ifnottex\n\ |
3372 | 317 @example\n\ |
318 @group\n\ | |
5481 | 319 \n\ |
10311 | 320 A * V = B * V * diag (lambda)\n\ |
321 W' * A = diag (lambda) * W' * B\n\ | |
322 AA = Q * A * Z, BB = Q * B * Z\n\ | |
5481 | 323 \n\ |
3372 | 324 @end group\n\ |
325 @end example\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8286
diff
changeset
|
326 @end ifnottex\n\ |
5016 | 327 with @var{Q} and @var{Z} orthogonal (unitary)= @var{I}\n\ |
3185 | 328 \n\ |
5016 | 329 @item @code{[AA,BB,Z@{, lambda@}] = qz(A,B,opt)}\n\ |
3185 | 330 \n\ |
3372 | 331 As in form [2], but allows ordering of generalized eigenpairs\n\ |
5481 | 332 for (e.g.) solution of discrete time algebraic Riccati equations.\n\ |
333 Form 3 is not available for complex matrices, and does not compute\n\ | |
334 the generalized eigenvectors @var{V}, @var{W}, nor the orthogonal matrix @var{Q}.\n\ | |
3372 | 335 @table @var\n\ |
336 @item opt\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8927
diff
changeset
|
337 for ordering eigenvalues of the GEP pencil. The leading block\n\ |
5481 | 338 of the revised pencil contains all eigenvalues that satisfy:\n\ |
3372 | 339 @table @code\n\ |
340 @item \"N\"\n\ | |
5481 | 341 = unordered (default) \n\ |
3183 | 342 \n\ |
3372 | 343 @item \"S\"\n\ |
344 = small: leading block has all |lambda| <=1 \n\ | |
3185 | 345 \n\ |
3372 | 346 @item \"B\"\n\ |
5481 | 347 = big: leading block has all |lambda| >= 1 \n\ |
3372 | 348 \n\ |
349 @item \"-\"\n\ | |
5481 | 350 = negative real part: leading block has all eigenvalues\n\ |
351 in the open left half-plane\n\ | |
3372 | 352 \n\ |
353 @item \"+\"\n\ | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
354 = non-negative real part: leading block has all eigenvalues\n\ |
5481 | 355 in the closed right half-plane\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8927
diff
changeset
|
356 @end table\n\ |
3372 | 357 @end table\n\ |
358 @end enumerate\n\ | |
3183 | 359 \n\ |
3372 | 360 Note: qz performs permutation balancing, but not scaling (see balance).\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8927
diff
changeset
|
361 Order of output arguments was selected for compatibility with @sc{matlab}\n\ |
3183 | 362 \n\ |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7520
diff
changeset
|
363 @seealso{balance, eig, schur}\n\ |
3372 | 364 @end deftypefn") |
3183 | 365 { |
366 octave_value_list retval; | |
367 int nargin = args.length (); | |
368 | |
3185 | 369 #ifdef DEBUG |
3538 | 370 std::cout << "qz: nargin = " << nargin << ", nargout = " << nargout << std::endl; |
3185 | 371 #endif |
3183 | 372 |
3185 | 373 if (nargin < 2 || nargin > 3 || nargout > 7) |
374 { | |
5823 | 375 print_usage (); |
3185 | 376 return retval; |
377 } | |
378 else if (nargin == 3 && (nargout < 3 || nargout > 4)) | |
379 { | |
3427 | 380 error ("qz: invalid number of output arguments for form [3] call"); |
3185 | 381 return retval; |
382 } | |
3183 | 383 |
3185 | 384 #ifdef DEBUG |
3538 | 385 std::cout << "qz: determine ordering option" << std::endl; |
3185 | 386 #endif |
3183 | 387 |
10311 | 388 // Determine ordering option. |
8927
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
389 volatile char ord_job = 0; |
3183 | 390 static double safmin; |
3185 | 391 |
392 if (nargin == 2) | |
8927
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
393 ord_job = 'N'; |
3185 | 394 else if (!args(2).is_string ()) |
395 { | |
396 error ("qz: argument 3 must be a string"); | |
397 return retval; | |
398 } | |
399 else | |
400 { | |
8927
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
401 std::string tmp = args(2).string_value (); |
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
402 |
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
403 if (! tmp.empty ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
404 ord_job = tmp[0]; |
3183 | 405 |
8927
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
406 if (! (ord_job == 'N' || ord_job == 'n' |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
407 || ord_job == 'S' || ord_job == 's' |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
408 || ord_job == 'B' || ord_job == 'b' |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
409 || ord_job == '+' || ord_job == '-')) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
410 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
411 error ("qz: invalid order option"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
412 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
413 } |
3185 | 414 |
415 // overflow constant required by dlag2 | |
4552 | 416 F77_FUNC (xdlamch, XDLAMCH) (F77_CONST_CHAR_ARG2 ("S", 1), |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
417 safmin |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
418 F77_CHAR_ARG_LEN (1)); |
3183 | 419 |
3185 | 420 #ifdef DEBUG_EIG |
3538 | 421 std::cout << "qz: initial value of safmin=" << setiosflags (std::ios::scientific) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
422 << safmin << std::endl; |
3185 | 423 #endif |
3183 | 424 |
10311 | 425 // Some machines (e.g., DEC alpha) get safmin = 0; |
426 // for these, use eps instead to avoid problems in dlag2. | |
3185 | 427 if (safmin == 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
428 { |
3185 | 429 #ifdef DEBUG_EIG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
430 std::cout << "qz: DANGER WILL ROBINSON: safmin is 0!" << std::endl; |
3185 | 431 #endif |
3183 | 432 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
433 F77_FUNC (xdlamch, XDLAMCH) (F77_CONST_CHAR_ARG2 ("E", 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
434 safmin |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
435 F77_CHAR_ARG_LEN (1)); |
3185 | 436 |
437 #ifdef DEBUG_EIG | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
438 std::cout << "qz: safmin set to " << setiosflags (std::ios::scientific) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
439 << safmin << std::endl; |
3185 | 440 #endif |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
441 } |
3183 | 442 } |
443 | |
3185 | 444 #ifdef DEBUG |
3538 | 445 std::cout << "qz: check argument 1" << std::endl; |
3185 | 446 #endif |
3183 | 447 |
10311 | 448 // Argument 1: check if it's o.k. dimensioned. |
5275 | 449 octave_idx_type nn = args(0).rows (); |
3185 | 450 |
451 #ifdef DEBUG | |
3531 | 452 std::cout << "argument 1 dimensions: (" << nn << "," << args(0).columns () << ")" |
3538 | 453 << std::endl; |
3185 | 454 #endif |
455 | |
456 int arg_is_empty = empty_arg ("qz", nn, args(0).columns ()); | |
457 | |
3183 | 458 if (arg_is_empty < 0) |
3185 | 459 { |
460 gripe_empty_arg ("qz: parameter 1", 0); | |
461 return retval; | |
462 } | |
3183 | 463 else if (arg_is_empty > 0) |
3185 | 464 { |
465 gripe_empty_arg ("qz: parameter 1; continuing", 0); | |
466 return octave_value_list (2, Matrix ()); | |
467 } | |
468 else if (args(0).columns () != nn) | |
469 { | |
470 gripe_square_matrix_required ("qz"); | |
471 return retval; | |
472 } | |
3183 | 473 |
10311 | 474 // Argument 1: dimensions look good; get the value. |
3183 | 475 Matrix aa; |
476 ComplexMatrix caa; | |
3185 | 477 |
478 if (args(0).is_complex_type ()) | |
3183 | 479 caa = args(0).complex_matrix_value (); |
3185 | 480 else |
3183 | 481 aa = args(0).matrix_value (); |
3185 | 482 |
483 if (error_state) | |
3183 | 484 return retval; |
485 | |
3185 | 486 #ifdef DEBUG |
3538 | 487 std::cout << "qz: check argument 2" << std::endl; |
3185 | 488 #endif |
3183 | 489 |
10311 | 490 // Extract argument 2 (bb, or cbb if complex). |
3185 | 491 if ((nn != args(1).columns ()) || (nn != args(1).rows ())) |
492 { | |
493 gripe_nonconformant (); | |
494 return retval; | |
495 } | |
496 | |
3183 | 497 Matrix bb; |
498 ComplexMatrix cbb; | |
3185 | 499 |
500 if (args(1).is_complex_type ()) | |
3183 | 501 cbb = args(1).complex_matrix_value (); |
502 else | |
503 bb = args(1).matrix_value (); | |
3185 | 504 |
505 if (error_state) | |
3183 | 506 return retval; |
507 | |
508 // Both matrices loaded, now let's check what kind of arithmetic: | |
10311 | 509 // declared volatile to avoid compiler warnings about long jumps, |
510 // vforks. | |
3185 | 511 |
10311 | 512 volatile int complex_case |
3185 | 513 = (args(0).is_complex_type () || args(1).is_complex_type ()); |
10311 | 514 |
3185 | 515 if (nargin == 3 && complex_case) |
516 { | |
517 error ("qz: cannot re-order complex qz decomposition."); | |
518 return retval; | |
519 } | |
3183 | 520 |
10311 | 521 // First, declare variables used in both the real and complex case. |
3183 | 522 Matrix QQ(nn,nn), ZZ(nn,nn), VR(nn,nn), VL(nn,nn); |
523 RowVector alphar(nn), alphai(nn), betar(nn); | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
524 ComplexRowVector xalpha(nn), xbeta(nn); |
3185 | 525 ComplexMatrix CQ(nn,nn), CZ(nn,nn), CVR(nn,nn), CVL(nn,nn); |
5275 | 526 octave_idx_type ilo, ihi, info; |
3185 | 527 char compq = (nargout >= 3 ? 'V' : 'N'); |
528 char compz = (nargout >= 4 ? 'V' : 'N'); | |
3183 | 529 |
10311 | 530 // Initialize Q, Z to identity if we need either of them. |
3185 | 531 if (compq == 'V' || compz == 'V') |
5275 | 532 for (octave_idx_type ii = 0; ii < nn; ii++) |
533 for (octave_idx_type jj = 0; jj < nn; jj++) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
534 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
535 OCTAVE_QUIT; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
536 QQ(ii,jj) = ZZ(ii,jj) = (ii == jj ? 1.0 : 0.0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
537 } |
3183 | 538 |
10311 | 539 // Always perform permutation balancing. |
4552 | 540 const char bal_job = 'P'; |
10311 | 541 RowVector lscale (nn), rscale (nn), work (6 * nn), rwork (nn); |
3183 | 542 |
3185 | 543 if (complex_case) |
544 { | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
545 #ifdef DEBUG |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
546 if (compq == 'V') |
10311 | 547 std::cout << "qz: performing balancing; CQ=" << std::endl << CQ << std::endl; |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
548 #endif |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
549 if (args(0).is_real_type ()) |
10311 | 550 caa = ComplexMatrix (aa); |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
551 |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
552 if (args(1).is_real_type ()) |
10311 | 553 cbb = ComplexMatrix (bb); |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
554 |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
555 if (compq == 'V') |
10311 | 556 CQ = ComplexMatrix (QQ); |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
557 |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
558 if (compz == 'V') |
10311 | 559 CZ = ComplexMatrix (ZZ); |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
560 |
10311 | 561 F77_XFCN (zggbal, ZGGBAL, |
562 (F77_CONST_CHAR_ARG2 (&bal_job, 1), | |
563 nn, caa.fortran_vec (), nn, cbb.fortran_vec (), | |
564 nn, ilo, ihi, lscale.fortran_vec (), | |
565 rscale.fortran_vec (), work.fortran_vec (), info | |
566 F77_CHAR_ARG_LEN (1))); | |
3185 | 567 } |
3183 | 568 else |
3185 | 569 { |
570 #ifdef DEBUG | |
571 if (compq == 'V') | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
572 std::cout << "qz: performing balancing; QQ=" << std::endl << QQ << std::endl; |
3185 | 573 #endif |
3183 | 574 |
3185 | 575 F77_XFCN (dggbal, DGGBAL, |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
576 (F77_CONST_CHAR_ARG2 (&bal_job, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
577 nn, aa.fortran_vec (), nn, bb.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
578 nn, ilo, ihi, lscale.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
579 rscale.fortran_vec (), work.fortran_vec (), info |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
580 F77_CHAR_ARG_LEN (1))); |
3185 | 581 } |
3183 | 582 |
583 // Since we just want the balancing matrices, we can use dggbal | |
10311 | 584 // for both the real and complex cases; left first |
3185 | 585 |
10311 | 586 #if 0 |
587 if (compq == 'V') | |
3185 | 588 { |
589 F77_XFCN (dggbak, DGGBAK, | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
590 (F77_CONST_CHAR_ARG2 (&bal_job, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
591 F77_CONST_CHAR_ARG2 ("L", 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
592 nn, ilo, ihi, lscale.data (), rscale.data (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
593 nn, QQ.fortran_vec (), nn, info |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
594 F77_CHAR_ARG_LEN (1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
595 F77_CHAR_ARG_LEN (1))); |
3183 | 596 |
3185 | 597 #ifdef DEBUG |
598 if (compq == 'V') | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
599 std::cout << "qz: balancing done; QQ=" << std::endl << QQ << std::endl; |
3185 | 600 #endif |
3183 | 601 } |
602 | |
603 // then right | |
3185 | 604 if (compz == 'V') |
605 { | |
4552 | 606 F77_XFCN (dggbak, DGGBAK, |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
607 (F77_CONST_CHAR_ARG2 (&bal_job, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
608 F77_CONST_CHAR_ARG2 ("R", 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
609 nn, ilo, ihi, lscale.data (), rscale.data (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
610 nn, ZZ.fortran_vec (), nn, info |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
611 F77_CHAR_ARG_LEN (1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
612 F77_CHAR_ARG_LEN (1))); |
3183 | 613 |
3185 | 614 #ifdef DEBUG |
615 if (compz == 'V') | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
616 std::cout << "qz: balancing done; ZZ=" << std::endl << ZZ << std::endl; |
3185 | 617 #endif |
10311 | 618 } |
619 #endif | |
3183 | 620 |
621 static char qz_job; | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
622 qz_job = (nargout < 2 ? 'E' : 'S'); |
3185 | 623 |
3183 | 624 if (complex_case) |
3185 | 625 { |
10311 | 626 // Complex case. |
627 | |
628 // The QR decomposition of cbb. | |
629 ComplexQR cbqr (cbb); | |
630 // The R matrix of QR decomposition for cbb. | |
631 cbb = cbqr.R (); | |
632 // (Q*)caa for following work. | |
633 caa = (cbqr.Q ().hermitian ()) * caa; | |
634 CQ = CQ * cbqr.Q (); | |
635 | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
636 F77_XFCN (zgghrd, ZGGHRD, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
637 (F77_CONST_CHAR_ARG2 (&compq, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
638 F77_CONST_CHAR_ARG2 (&compz, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
639 nn, ilo, ihi, caa.fortran_vec (), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
640 nn, cbb.fortran_vec (), nn, CQ.fortran_vec (), nn, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
641 CZ.fortran_vec (), nn, info |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
642 F77_CHAR_ARG_LEN (1) |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
643 F77_CHAR_ARG_LEN (1))); |
10311 | 644 |
645 ComplexRowVector cwork (1 * nn); | |
646 | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
647 F77_XFCN (zhgeqz, ZHGEQZ, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
648 (F77_CONST_CHAR_ARG2 (&qz_job, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
649 F77_CONST_CHAR_ARG2 (&compq, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
650 F77_CONST_CHAR_ARG2 (&compz, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
651 nn, ilo, ihi, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
652 caa.fortran_vec (), nn, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
653 cbb.fortran_vec (),nn, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
654 xalpha.fortran_vec (), xbeta.fortran_vec (), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
655 CQ.fortran_vec (), nn, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
656 CZ.fortran_vec (), nn, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
657 cwork.fortran_vec (), nn, rwork.fortran_vec (), info |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
658 F77_CHAR_ARG_LEN (1) |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
659 F77_CHAR_ARG_LEN (1) |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
660 F77_CHAR_ARG_LEN (1))); |
3185 | 661 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
662 if (compq == 'V') |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
663 { |
10311 | 664 // Left eigenvector. |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
665 F77_XFCN (zggbak, ZGGBAK, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
666 (F77_CONST_CHAR_ARG2 (&bal_job, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
667 F77_CONST_CHAR_ARG2 ("L", 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
668 nn, ilo, ihi, lscale.data (), rscale.data (), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
669 nn, CQ.fortran_vec (), nn, info |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
670 F77_CHAR_ARG_LEN (1) |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
671 F77_CHAR_ARG_LEN (1))); |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
672 } |
3185 | 673 |
10311 | 674 // Right eigenvector. |
3185 | 675 if (compz == 'V') |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
676 { |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
677 F77_XFCN (zggbak, ZGGBAK, |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
678 (F77_CONST_CHAR_ARG2 (&bal_job, 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
679 F77_CONST_CHAR_ARG2 ("R", 1), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
680 nn, ilo, ihi, lscale.data (), rscale.data (), |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
681 nn, CZ.fortran_vec (), nn, info |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
682 F77_CHAR_ARG_LEN (1) |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
683 F77_CHAR_ARG_LEN (1))); |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
684 } |
3185 | 685 |
686 } | |
10311 | 687 else |
3185 | 688 { |
689 #ifdef DEBUG | |
3538 | 690 std::cout << "qz: peforming qr decomposition of bb" << std::endl; |
3185 | 691 #endif |
3183 | 692 |
10311 | 693 // Compute the QR factorization of bb. |
3185 | 694 QR bqr (bb); |
695 | |
696 #ifdef DEBUG | |
3538 | 697 std::cout << "qz: qr (bb) done; now peforming qz decomposition" << std::endl; |
3185 | 698 #endif |
3183 | 699 |
3185 | 700 bb = bqr.R (); |
701 | |
702 #ifdef DEBUG | |
3538 | 703 std::cout << "qz: extracted bb" << std::endl; |
3185 | 704 #endif |
3183 | 705 |
10311 | 706 aa = (bqr.Q ()).transpose () * aa; |
3185 | 707 |
708 #ifdef DEBUG | |
3538 | 709 std::cout << "qz: updated aa " << std::endl; |
710 std::cout << "bqr.Q () = " << std::endl << bqr.Q () << std::endl; | |
3183 | 711 |
3185 | 712 if (compq == 'V') |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
713 std::cout << "QQ =" << QQ << std::endl; |
3185 | 714 #endif |
3183 | 715 |
3185 | 716 if (compq == 'V') |
10311 | 717 QQ = QQ * bqr.Q (); |
3183 | 718 |
3185 | 719 #ifdef DEBUG |
3538 | 720 std::cout << "qz: precursors done..." << std::endl; |
3185 | 721 #endif |
3183 | 722 |
3185 | 723 #ifdef DEBUG |
3538 | 724 std::cout << "qz: compq = " << compq << ", compz = " << compz << std::endl; |
3185 | 725 #endif |
3183 | 726 |
10311 | 727 // Reduce to generalized hessenberg form. |
3185 | 728 F77_XFCN (dgghrd, DGGHRD, |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
729 (F77_CONST_CHAR_ARG2 (&compq, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
730 F77_CONST_CHAR_ARG2 (&compz, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
731 nn, ilo, ihi, aa.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
732 nn, bb.fortran_vec (), nn, QQ.fortran_vec (), nn, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
733 ZZ.fortran_vec (), nn, info |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
734 F77_CHAR_ARG_LEN (1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
735 F77_CHAR_ARG_LEN (1))); |
3183 | 736 |
10311 | 737 // Check if just computing generalized eigenvalues or if we're |
738 // actually computing the decomposition. | |
3183 | 739 |
10311 | 740 // Reduce to generalized Schur form. |
3185 | 741 F77_XFCN (dhgeqz, DHGEQZ, |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
742 (F77_CONST_CHAR_ARG2 (&qz_job, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
743 F77_CONST_CHAR_ARG2 (&compq, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
744 F77_CONST_CHAR_ARG2 (&compz, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
745 nn, ilo, ihi, aa.fortran_vec (), nn, bb.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
746 nn, alphar.fortran_vec (), alphai.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
747 betar.fortran_vec (), QQ.fortran_vec (), nn, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
748 ZZ.fortran_vec (), nn, work.fortran_vec (), nn, info |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
749 F77_CHAR_ARG_LEN (1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
750 F77_CHAR_ARG_LEN (1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
751 F77_CHAR_ARG_LEN (1))); |
10311 | 752 |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
753 if (compq == 'V') |
10311 | 754 { |
755 F77_XFCN (dggbak, DGGBAK, | |
756 (F77_CONST_CHAR_ARG2 (&bal_job, 1), | |
757 F77_CONST_CHAR_ARG2 ("L", 1), | |
758 nn, ilo, ihi, lscale.data (), rscale.data (), | |
759 nn, QQ.fortran_vec (), nn, info | |
760 F77_CHAR_ARG_LEN (1) | |
761 F77_CHAR_ARG_LEN (1))); | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
762 |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
763 #ifdef DEBUG |
10311 | 764 if (compq == 'V') |
765 std::cout << "qz: balancing done; QQ=" << std::endl << QQ << std::endl; | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
766 #endif |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
767 } |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
768 |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
769 // then right |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
770 if (compz == 'V') |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
771 { |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
772 F77_XFCN (dggbak, DGGBAK, |
10311 | 773 (F77_CONST_CHAR_ARG2 (&bal_job, 1), |
774 F77_CONST_CHAR_ARG2 ("R", 1), | |
775 nn, ilo, ihi, lscale.data (), rscale.data (), | |
776 nn, ZZ.fortran_vec (), nn, info | |
777 F77_CHAR_ARG_LEN (1) | |
778 F77_CHAR_ARG_LEN (1))); | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
779 |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
780 #ifdef DEBUG |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
781 if (compz == 'V') |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
782 std::cout << "qz: balancing done; ZZ=" << std::endl << ZZ << std::endl; |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
783 #endif |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
784 } |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
785 |
3185 | 786 } |
3183 | 787 |
10311 | 788 // Order the QZ decomposition? |
8927
d75f4ee0538d
qz.cc (Fqz): avoid maybe clobbred by vfork warning from GCC
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
789 if (! (ord_job == 'N' || ord_job == 'n')) |
3183 | 790 { |
3185 | 791 if (complex_case) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
792 { |
10311 | 793 // Probably not needed, but better be safe. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
794 error ("qz: cannot re-order complex qz decomposition."); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
795 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
796 } |
3185 | 797 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
798 { |
3185 | 799 #ifdef DEBUG_SORT |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
800 std::cout << "qz: ordering eigenvalues: ord_job = " |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
801 << ord_job << std::endl; |
3185 | 802 #endif |
3183 | 803 |
10311 | 804 // Declared static to avoid vfork/long jump compiler complaints. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
805 static sort_function sort_test; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
806 sort_test = 0; |
3183 | 807 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
808 switch (ord_job) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
809 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
810 case 'S': |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
811 case 's': |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
812 sort_test = &fin; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
813 break; |
3183 | 814 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
815 case 'B': |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
816 case 'b': |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
817 sort_test = &fout; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
818 break; |
3183 | 819 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
820 case '+': |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
821 sort_test = &fcrhp; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
822 break; |
3183 | 823 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
824 case '-': |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
825 sort_test = &folhp; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
826 break; |
3185 | 827 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
828 default: |
10311 | 829 // Invalid order option (should never happen, since we |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
830 // checked the options at the top). |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
831 panic_impossible (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
832 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
833 } |
3183 | 834 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
835 octave_idx_type ndim, fail; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
836 double inf_norm; |
3185 | 837 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
838 F77_XFCN (xdlange, XDLANGE, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
839 (F77_CONST_CHAR_ARG2 ("I", 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
840 nn, nn, aa.data (), nn, work.fortran_vec (), inf_norm |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
841 F77_CHAR_ARG_LEN (1))); |
3185 | 842 |
10311 | 843 double eps = DBL_EPSILON * inf_norm * nn; |
3185 | 844 |
845 #ifdef DEBUG_SORT | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
846 std::cout << "qz: calling dsubsp: aa=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
847 octave_print_internal (std::cout, aa, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
848 std::cout << std::endl << "bb=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
849 octave_print_internal (std::cout, bb, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
850 if (compz == 'V') |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
851 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
852 std::cout << std::endl << "ZZ=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
853 octave_print_internal (std::cout, ZZ, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
854 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
855 std::cout << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
856 std::cout << "alphar = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
857 octave_print_internal (std::cout, (Matrix) alphar, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
858 std::cout << std::endl << "alphai = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
859 octave_print_internal (std::cout, (Matrix) alphai, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
860 std::cout << std::endl << "beta = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
861 octave_print_internal (std::cout, (Matrix) betar, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
862 std::cout << std::endl; |
3185 | 863 #endif |
864 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10311
diff
changeset
|
865 Array<octave_idx_type> ind (nn, 1); |
3550 | 866 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
867 F77_XFCN (dsubsp, DSUBSP, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
868 (nn, nn, aa.fortran_vec (), bb.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
869 ZZ.fortran_vec (), sort_test, eps, ndim, fail, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
870 ind.fortran_vec ())); |
3185 | 871 |
872 #ifdef DEBUG | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
873 std::cout << "qz: back from dsubsp: aa=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
874 octave_print_internal (std::cout, aa, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
875 std::cout << std::endl << "bb=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
876 octave_print_internal (std::cout, bb, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
877 if (compz == 'V') |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
878 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
879 std::cout << std::endl << "ZZ=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
880 octave_print_internal (std::cout, ZZ, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
881 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
882 std::cout << std::endl; |
3185 | 883 #endif |
884 | |
10311 | 885 // Manually update alphar, alphai, betar. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
886 static int jj; |
3185 | 887 |
10311 | 888 jj = 0; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
889 while (jj < nn) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
890 { |
3185 | 891 #ifdef DEBUG_EIG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
892 std::cout << "computing gen eig #" << jj << std::endl; |
3185 | 893 #endif |
894 | |
10311 | 895 // Number of zeros in this block. |
896 static int zcnt; | |
3185 | 897 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
898 if (jj == (nn-1)) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
899 zcnt = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
900 else if (aa(jj+1,jj) == 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
901 zcnt = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
902 else zcnt = 2; |
3185 | 903 |
10311 | 904 if (zcnt == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
905 { |
10311 | 906 // Real zero. |
3185 | 907 #ifdef DEBUG_EIG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
908 std::cout << " single gen eig:" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
909 std::cout << " alphar(" << jj << ") = " << aa(jj,jj) << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
910 std::cout << " betar( " << jj << ") = " << bb(jj,jj) << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
911 std::cout << " alphai(" << jj << ") = 0" << std::endl; |
3185 | 912 #endif |
913 | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
914 alphar(jj) = aa(jj,jj); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
915 alphai(jj) = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
916 betar(jj) = bb(jj,jj); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
917 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
918 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
919 { |
10311 | 920 // Complex conjugate pair. |
3185 | 921 #ifdef DEBUG_EIG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
922 std::cout << "qz: calling dlag2:" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
923 std::cout << "safmin=" |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
924 << setiosflags (std::ios::scientific) << safmin << std::endl; |
3185 | 925 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
926 for (int idr = jj; idr <= jj+1; idr++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
927 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
928 for (int idc = jj; idc <= jj+1; idc++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
929 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
930 std::cout << "aa(" << idr << "," << idc << ")=" |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
931 << aa(idr,idc) << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
932 std::cout << "bb(" << idr << "," << idc << ")=" |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
933 << bb(idr,idc) << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
934 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
935 } |
3185 | 936 #endif |
937 | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
938 // FIXME -- probably should be using |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
939 // fortran_vec instead of &aa(jj,jj) here. |
4566 | 940 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
941 double scale1, scale2, wr1, wr2, wi; |
10311 | 942 const double *aa_ptr = aa.data () + jj * nn + jj; |
943 const double *bb_ptr = bb.data () + jj * nn + jj; | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
944 F77_XFCN (dlag2, DLAG2, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
945 (aa_ptr, nn, bb_ptr, nn, safmin, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
946 scale1, scale2, wr1, wr2, wi)); |
3185 | 947 |
948 #ifdef DEBUG_EIG | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
949 std::cout << "dlag2 returns: scale1=" << scale1 |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
950 << "\tscale2=" << scale2 << std::endl |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
951 << "\twr1=" << wr1 << "\twr2=" << wr2 |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
952 << "\twi=" << wi << std::endl; |
3185 | 953 #endif |
954 | |
10311 | 955 // Just to be safe, check if it's a real pair. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
956 if (wi == 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
957 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
958 alphar(jj) = wr1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
959 alphai(jj) = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
960 betar(jj) = scale1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
961 alphar(jj+1) = wr2; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
962 alphai(jj+1) = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
963 betar(jj+1) = scale2; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
964 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
965 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
966 { |
10311 | 967 alphar(jj) = alphar(jj+1) = wr1; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
968 alphai(jj) = -(alphai(jj+1) = wi); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
969 betar(jj) = betar(jj+1) = scale1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
970 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
971 } |
3185 | 972 |
10311 | 973 // Advance past this block. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
974 jj += zcnt; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
975 } |
3185 | 976 |
977 #ifdef DEBUG_SORT | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
978 std::cout << "qz: back from dsubsp: aa=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
979 octave_print_internal (std::cout, aa, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
980 std::cout << std::endl << "bb=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
981 octave_print_internal (std::cout, bb, 0); |
3185 | 982 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
983 if (compz == 'V') |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
984 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
985 std::cout << std::endl << "ZZ=" << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
986 octave_print_internal (std::cout, ZZ, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
987 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
988 std::cout << std::endl << "qz: ndim=" << ndim << std::endl |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
989 << "fail=" << fail << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
990 std::cout << "alphar = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
991 octave_print_internal (std::cout, (Matrix) alphar, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
992 std::cout << std::endl << "alphai = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
993 octave_print_internal (std::cout, (Matrix) alphai, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
994 std::cout << std::endl << "beta = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
995 octave_print_internal (std::cout, (Matrix) betar, 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
996 std::cout << std::endl; |
3185 | 997 #endif |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
998 } |
3183 | 999 } |
3185 | 1000 |
10311 | 1001 // Compute generalized eigenvalues? |
3183 | 1002 ComplexColumnVector gev; |
3185 | 1003 |
1004 if (nargout < 2 || nargout == 7 || (nargin == 3 && nargout == 4)) | |
3183 | 1005 { |
3185 | 1006 if (complex_case) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1007 { |
10311 | 1008 int cnt = 0; |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1009 |
10311 | 1010 for (int ii = 0; ii < nn; ii++) |
1011 cnt++; | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1012 |
10311 | 1013 ComplexColumnVector tmp (cnt); |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1014 |
10311 | 1015 cnt = 0; |
1016 for (int ii = 0; ii < nn; ii++) | |
1017 tmp(cnt++) = xalpha(ii) / xbeta(ii); | |
1018 | |
1019 gev = tmp; | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1020 } |
3185 | 1021 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1022 { |
3185 | 1023 #ifdef DEBUG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1024 std::cout << "qz: computing generalized eigenvalues" << std::endl; |
3185 | 1025 #endif |
3183 | 1026 |
10311 | 1027 // Return finite generalized eigenvalues. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1028 int cnt = 0; |
3185 | 1029 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1030 for (int ii = 0; ii < nn; ii++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1031 if (betar(ii) != 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1032 cnt++; |
3185 | 1033 |
10311 | 1034 ComplexColumnVector tmp (cnt); |
3185 | 1035 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1036 cnt = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1037 for (int ii = 0; ii < nn; ii++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1038 if (betar(ii) != 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1039 tmp(cnt++) = Complex(alphar(ii), alphai(ii))/betar(ii); |
10311 | 1040 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1041 gev = tmp; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1042 } |
3183 | 1043 } |
1044 | |
10311 | 1045 // Right, left eigenvector matrices. |
3185 | 1046 if (nargout >= 5) |
3183 | 1047 { |
10311 | 1048 // Which side to compute? |
1049 char side = (nargout == 5 ? 'R' : 'B'); | |
1050 // Compute all of them and backtransform | |
1051 char howmny = 'B'; | |
1052 // Dummy pointer; select is not used. | |
1053 octave_idx_type *select = 0; | |
3185 | 1054 |
1055 if (complex_case) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1056 { |
10311 | 1057 CVL = CQ; |
1058 CVR = CZ; | |
1059 ComplexRowVector cwork2 (2 * nn); | |
1060 RowVector rwork2 (8 * nn); | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1061 octave_idx_type m; |
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1062 |
10311 | 1063 F77_XFCN (ztgevc, ZTGEVC, |
1064 (F77_CONST_CHAR_ARG2 (&side, 1), | |
1065 F77_CONST_CHAR_ARG2 (&howmny, 1), | |
1066 select, nn, caa.fortran_vec (), nn, cbb.fortran_vec (), | |
1067 nn, CVL.fortran_vec (), nn, CVR.fortran_vec (), nn, nn, | |
1068 m, cwork2.fortran_vec (), rwork2.fortran_vec (), info | |
1069 F77_CHAR_ARG_LEN (1) | |
1070 F77_CHAR_ARG_LEN (1))); | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1071 } |
3185 | 1072 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1073 { |
3185 | 1074 #ifdef DEBUG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1075 std::cout << "qz: computing generalized eigenvectors" << std::endl; |
3185 | 1076 #endif |
1077 | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1078 VL = QQ; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1079 VR = ZZ; |
10311 | 1080 octave_idx_type m; |
1081 | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1082 F77_XFCN (dtgevc, DTGEVC, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1083 (F77_CONST_CHAR_ARG2 (&side, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1084 F77_CONST_CHAR_ARG2 (&howmny, 1), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1085 select, nn, aa.fortran_vec (), nn, bb.fortran_vec (), |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1086 nn, VL.fortran_vec (), nn, VR.fortran_vec (), nn, nn, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1087 m, work.fortran_vec (), info |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1088 F77_CHAR_ARG_LEN (1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1089 F77_CHAR_ARG_LEN (1))); |
3185 | 1090 |
10311 | 1091 // Now construct the complex form of VV, WW. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1092 int jj = 0; |
3185 | 1093 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1094 while (jj < nn) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1095 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1096 OCTAVE_QUIT; |
4153 | 1097 |
10311 | 1098 // See if real or complex eigenvalue. |
1099 | |
1100 // Column increment; assume complex eigenvalue. | |
1101 int cinc = 2; | |
3185 | 1102 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1103 if (jj == (nn-1)) |
10311 | 1104 // Single column. |
1105 cinc = 1; | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1106 else if (aa(jj+1,jj) == 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1107 cinc = 1; |
3185 | 1108 |
10311 | 1109 // Now copy the eigenvector (s) to CVR, CVL. |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1110 if (cinc == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1111 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1112 for (int ii = 0; ii < nn; ii++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1113 CVR(ii,jj) = VR(ii,jj); |
3185 | 1114 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1115 if (side == 'B') |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1116 for (int ii = 0; ii < nn; ii++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1117 CVL(ii,jj) = VL(ii,jj); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1118 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1119 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1120 { |
10311 | 1121 // Double column; complex vector. |
3185 | 1122 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1123 for (int ii = 0; ii < nn; ii++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1124 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1125 CVR(ii,jj) = Complex (VR(ii,jj), VR(ii,jj+1)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1126 CVR(ii,jj+1) = Complex (VR(ii,jj), -VR(ii,jj+1)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1127 } |
3183 | 1128 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1129 if (side == 'B') |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1130 for (int ii = 0; ii < nn; ii++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1131 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1132 CVL(ii,jj) = Complex (VL(ii,jj), VL(ii,jj+1)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1133 CVL(ii,jj+1) = Complex (VL(ii,jj), -VL(ii,jj+1)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1134 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1135 } |
3185 | 1136 |
10311 | 1137 // Advance to next eigenvectors (if any). |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1138 jj += cinc; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1139 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1140 } |
3183 | 1141 } |
3185 | 1142 |
1143 switch (nargout) | |
1144 { | |
1145 case 7: | |
1146 retval(6) = gev; | |
1147 | |
10311 | 1148 case 6: |
1149 // Return eigenvectors. | |
3185 | 1150 retval(5) = CVL; |
1151 | |
10311 | 1152 case 5: |
1153 // Return eigenvectors. | |
3185 | 1154 retval(4) = CVR; |
1155 | |
1156 case 4: | |
1157 if (nargin == 3) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1158 { |
3185 | 1159 #ifdef DEBUG |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1160 std::cout << "qz: sort: retval(3) = gev = " << std::endl; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1161 octave_print_internal (std::cout, gev); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1162 std::cout << std::endl; |
3185 | 1163 #endif |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1164 retval(3) = gev; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9786
diff
changeset
|
1165 } |
3185 | 1166 else |
10311 | 1167 { |
1168 if (complex_case) | |
1169 retval(3) = CZ; | |
1170 else | |
1171 retval(3) = ZZ; | |
1172 } | |
3185 | 1173 |
1174 case 3: | |
1175 if (nargin == 3) | |
10311 | 1176 retval(2) = CZ; |
3185 | 1177 else |
10311 | 1178 { |
1179 if (complex_case) | |
1180 retval(2) = CQ.hermitian (); | |
1181 else | |
1182 retval(2) = QQ.transpose (); | |
1183 } | |
1184 | |
3185 | 1185 case 2: |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1186 { |
10311 | 1187 if (complex_case) |
1188 { | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1189 #ifdef DEBUG |
10311 | 1190 std::cout << "qz: retval (1) = cbb = " << std::endl; |
1191 octave_print_internal (std::cout, cbb, 0); | |
1192 std::cout << std::endl << "qz: retval(0) = caa = " <<std::endl; | |
1193 octave_print_internal (std::cout, caa, 0); | |
1194 std::cout << std::endl; | |
1195 #endif | |
1196 retval(1) = cbb; | |
1197 retval(0) = caa; | |
1198 } | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1199 else |
10311 | 1200 { |
3185 | 1201 #ifdef DEBUG |
10311 | 1202 std::cout << "qz: retval (1) = bb = " << std::endl; |
1203 octave_print_internal (std::cout, bb, 0); | |
1204 std::cout << std::endl << "qz: retval(0) = aa = " <<std::endl; | |
1205 octave_print_internal (std::cout, aa, 0); | |
1206 std::cout << std::endl; | |
3185 | 1207 #endif |
10311 | 1208 retval(1) = bb; |
1209 retval(0) = aa; | |
1210 } | |
1211 } | |
1212 break; | |
10307
4e4270ab70d6
support complex case in qz
Jyh-miin Lin <jyhmiinlin@gmail.com>
parents:
10155
diff
changeset
|
1213 |
3185 | 1214 |
1215 case 1: | |
1216 case 0: | |
1217 #ifdef DEBUG | |
3538 | 1218 std::cout << "qz: retval(0) = gev = " << gev << std::endl; |
3185 | 1219 #endif |
1220 retval(0) = gev; | |
1221 break; | |
1222 | |
1223 default: | |
1224 error ("qz: too many return arguments."); | |
1225 break; | |
3183 | 1226 } |
1227 | |
3185 | 1228 #ifdef DEBUG |
3538 | 1229 std::cout << "qz: exiting (at long last)" << std::endl; |
3185 | 1230 #endif |
3183 | 1231 |
1232 return retval; | |
1233 } |