Mercurial > hg > octave-nkf
annotate liboctave/CmplxSCHUR.cc @ 10314:07ebe522dac2
untabify liboctave C++ sources
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:23:32 -0500 |
parents | 4c0cdbe0acca |
children | 12884915a8e4 |
rev | line source |
---|---|
457 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004, |
8920 | 4 2005, 2007, 2008 John W. Eaton |
457 | 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. | |
457 | 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/>. | |
457 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
1192 | 25 #include <config.h> |
457 | 26 #endif |
27 | |
28 #include "CmplxSCHUR.h" | |
1847 | 29 #include "f77-fcn.h" |
457 | 30 #include "lo-error.h" |
31 | |
32 extern "C" | |
33 { | |
4552 | 34 F77_RET_T |
35 F77_FUNC (zgeesx, ZGEESX) (F77_CONST_CHAR_ARG_DECL, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
36 F77_CONST_CHAR_ARG_DECL, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
37 ComplexSCHUR::select_function, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
38 F77_CONST_CHAR_ARG_DECL, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
39 const octave_idx_type&, Complex*, const octave_idx_type&, octave_idx_type&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
40 Complex*, Complex*, const octave_idx_type&, double&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
41 double&, Complex*, const octave_idx_type&, double*, octave_idx_type*, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
42 octave_idx_type& |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
43 F77_CHAR_ARG_LEN_DECL |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
44 F77_CHAR_ARG_LEN_DECL |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
45 F77_CHAR_ARG_LEN_DECL); |
457 | 46 } |
47 | |
5275 | 48 static octave_idx_type |
1929 | 49 select_ana (const Complex& a) |
457 | 50 { |
1251 | 51 return a.real () < 0.0; |
457 | 52 } |
53 | |
5275 | 54 static octave_idx_type |
1929 | 55 select_dig (const Complex& a) |
457 | 56 { |
1251 | 57 return (abs (a) < 1.0); |
457 | 58 } |
59 | |
5275 | 60 octave_idx_type |
5008 | 61 ComplexSCHUR::init (const ComplexMatrix& a, const std::string& ord, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
62 bool calc_unitary) |
457 | 63 { |
5275 | 64 octave_idx_type a_nr = a.rows (); |
65 octave_idx_type a_nc = a.cols (); | |
1929 | 66 |
457 | 67 if (a_nr != a_nc) |
68 { | |
69 (*current_liboctave_error_handler) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
70 ("ComplexSCHUR requires square matrix"); |
457 | 71 return -1; |
72 } | |
73 | |
3334 | 74 // Workspace requirements may need to be fixed if any of the |
75 // following change. | |
76 | |
5008 | 77 char jobvs; |
1930 | 78 char sense = 'N'; |
79 char sort = 'N'; | |
1756 | 80 |
5008 | 81 if (calc_unitary) |
82 jobvs = 'V'; | |
83 else | |
84 jobvs = 'N'; | |
85 | |
1756 | 86 char ord_char = ord.empty () ? 'U' : ord[0]; |
87 | |
88 if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd') | |
1930 | 89 sort = 'S'; |
457 | 90 |
1929 | 91 if (ord_char == 'A' || ord_char == 'a') |
92 selector = select_ana; | |
93 else if (ord_char == 'D' || ord_char == 'd') | |
94 selector = select_dig; | |
1930 | 95 else |
96 selector = 0; | |
457 | 97 |
5275 | 98 octave_idx_type n = a_nc; |
99 octave_idx_type lwork = 8 * n; | |
100 octave_idx_type info; | |
101 octave_idx_type sdim; | |
457 | 102 double rconde; |
103 double rcondv; | |
104 | |
1929 | 105 schur_mat = a; |
5008 | 106 if (calc_unitary) |
107 unitary_mat.resize (n, n); | |
1929 | 108 |
109 Complex *s = schur_mat.fortran_vec (); | |
110 Complex *q = unitary_mat.fortran_vec (); | |
111 | |
112 Array<double> rwork (n); | |
113 double *prwork = rwork.fortran_vec (); | |
114 | |
115 Array<Complex> w (n); | |
116 Complex *pw = w.fortran_vec (); | |
117 | |
118 Array<Complex> work (lwork); | |
119 Complex *pwork = work.fortran_vec (); | |
457 | 120 |
3334 | 121 // BWORK is not referenced for non-ordered Schur. |
5275 | 122 Array<octave_idx_type> bwork ((ord_char == 'N' || ord_char == 'n') ? 0 : n); |
123 octave_idx_type *pbwork = bwork.fortran_vec (); | |
457 | 124 |
4552 | 125 F77_XFCN (zgeesx, ZGEESX, (F77_CONST_CHAR_ARG2 (&jobvs, 1), |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
126 F77_CONST_CHAR_ARG2 (&sort, 1), |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
127 selector, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
128 F77_CONST_CHAR_ARG2 (&sense, 1), |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
129 n, s, n, sdim, pw, q, n, rconde, rcondv, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
130 pwork, lwork, prwork, pbwork, info |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
131 F77_CHAR_ARG_LEN (1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
132 F77_CHAR_ARG_LEN (1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
133 F77_CHAR_ARG_LEN (1))); |
457 | 134 |
135 return info; | |
136 } |