457
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
457
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
457
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
457
|
25 #endif |
|
26 |
1730
|
27 #include <string> |
|
28 |
457
|
29 #include "CmplxAEPBAL.h" |
|
30 #include "dMatrix.h" |
1847
|
31 #include "f77-fcn.h" |
457
|
32 |
|
33 extern "C" |
|
34 { |
4552
|
35 F77_RET_T |
|
36 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL, |
|
37 const int&, Complex*, const int&, int&, |
|
38 int&, double*, int& |
|
39 F77_CHAR_ARG_LEN_DECL); |
457
|
40 |
4552
|
41 F77_RET_T |
|
42 F77_FUNC (zgebak, ZGEBAK) (F77_CONST_CHAR_ARG_DECL, |
|
43 F77_CONST_CHAR_ARG_DECL, |
|
44 const int&, const int&, const int&, double*, |
|
45 const int&, Complex*, const int&, int& |
|
46 F77_CHAR_ARG_LEN_DECL |
|
47 F77_CHAR_ARG_LEN_DECL); |
457
|
48 } |
|
49 |
|
50 int |
3504
|
51 ComplexAEPBALANCE::init (const ComplexMatrix& a, |
|
52 const std::string& balance_job) |
457
|
53 { |
1933
|
54 int n = a.cols (); |
457
|
55 |
1933
|
56 if (a.rows () != n) |
1730
|
57 { |
|
58 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); |
|
59 return -1; |
|
60 } |
|
61 |
457
|
62 int info; |
|
63 int ilo; |
|
64 int ihi; |
|
65 |
1933
|
66 Array<double> scale (n); |
|
67 double *pscale = scale.fortran_vec (); |
457
|
68 |
|
69 balanced_mat = a; |
1933
|
70 Complex *p_balanced_mat = balanced_mat.fortran_vec (); |
1730
|
71 |
1933
|
72 char job = balance_job[0]; |
457
|
73 |
4552
|
74 F77_XFCN (zgebal, ZGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), |
|
75 n, p_balanced_mat, n, ilo, ihi, |
|
76 pscale, info |
|
77 F77_CHAR_ARG_LEN (1))); |
457
|
78 |
1933
|
79 if (f77_exception_encountered) |
|
80 (*current_liboctave_error_handler) ("unrecoverable error in zgebal"); |
|
81 else |
|
82 { |
3585
|
83 balancing_mat = ComplexMatrix (n, n, 0.0); |
1933
|
84 for (int i = 0; i < n; i++) |
|
85 balancing_mat.elem (i, i) = 1.0; |
457
|
86 |
1933
|
87 Complex *p_balancing_mat = balancing_mat.fortran_vec (); |
|
88 |
|
89 char side = 'R'; |
457
|
90 |
4552
|
91 F77_XFCN (zgebak, ZGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
|
92 F77_CONST_CHAR_ARG2 (&side, 1), |
|
93 n, ilo, ihi, pscale, n, |
|
94 p_balancing_mat, n, info |
|
95 F77_CHAR_ARG_LEN (1) |
|
96 F77_CHAR_ARG_LEN (1))); |
1933
|
97 |
|
98 if (f77_exception_encountered) |
|
99 (*current_liboctave_error_handler) ("unrecoverable error in zgebak"); |
|
100 } |
457
|
101 |
|
102 return info; |
|
103 } |
|
104 |
|
105 /* |
|
106 ;;; Local Variables: *** |
|
107 ;;; mode: C++ *** |
|
108 ;;; End: *** |
|
109 */ |