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 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1296
|
24 #pragma implementation |
|
25 #endif |
|
26 |
457
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
457
|
29 #endif |
|
30 |
1730
|
31 #include <string> |
|
32 |
457
|
33 #include "CmplxAEPBAL.h" |
|
34 #include "dMatrix.h" |
1847
|
35 #include "f77-fcn.h" |
457
|
36 |
|
37 extern "C" |
|
38 { |
4552
|
39 F77_RET_T |
|
40 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL, |
|
41 const int&, Complex*, const int&, int&, |
|
42 int&, double*, int& |
|
43 F77_CHAR_ARG_LEN_DECL); |
457
|
44 |
4552
|
45 F77_RET_T |
|
46 F77_FUNC (zgebak, ZGEBAK) (F77_CONST_CHAR_ARG_DECL, |
|
47 F77_CONST_CHAR_ARG_DECL, |
|
48 const int&, const int&, const int&, double*, |
|
49 const int&, Complex*, const int&, int& |
|
50 F77_CHAR_ARG_LEN_DECL |
|
51 F77_CHAR_ARG_LEN_DECL); |
457
|
52 } |
|
53 |
|
54 int |
3504
|
55 ComplexAEPBALANCE::init (const ComplexMatrix& a, |
|
56 const std::string& balance_job) |
457
|
57 { |
1933
|
58 int n = a.cols (); |
457
|
59 |
1933
|
60 if (a.rows () != n) |
1730
|
61 { |
|
62 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); |
|
63 return -1; |
|
64 } |
|
65 |
457
|
66 int info; |
|
67 int ilo; |
|
68 int ihi; |
|
69 |
1933
|
70 Array<double> scale (n); |
|
71 double *pscale = scale.fortran_vec (); |
457
|
72 |
|
73 balanced_mat = a; |
1933
|
74 Complex *p_balanced_mat = balanced_mat.fortran_vec (); |
1730
|
75 |
1933
|
76 char job = balance_job[0]; |
457
|
77 |
4552
|
78 F77_XFCN (zgebal, ZGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), |
|
79 n, p_balanced_mat, n, ilo, ihi, |
|
80 pscale, info |
|
81 F77_CHAR_ARG_LEN (1))); |
457
|
82 |
1933
|
83 if (f77_exception_encountered) |
|
84 (*current_liboctave_error_handler) ("unrecoverable error in zgebal"); |
|
85 else |
|
86 { |
3585
|
87 balancing_mat = ComplexMatrix (n, n, 0.0); |
1933
|
88 for (int i = 0; i < n; i++) |
|
89 balancing_mat.elem (i, i) = 1.0; |
457
|
90 |
1933
|
91 Complex *p_balancing_mat = balancing_mat.fortran_vec (); |
|
92 |
|
93 char side = 'R'; |
457
|
94 |
4552
|
95 F77_XFCN (zgebak, ZGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
|
96 F77_CONST_CHAR_ARG2 (&side, 1), |
|
97 n, ilo, ihi, pscale, n, |
|
98 p_balancing_mat, n, info |
|
99 F77_CHAR_ARG_LEN (1) |
|
100 F77_CHAR_ARG_LEN (1))); |
1933
|
101 |
|
102 if (f77_exception_encountered) |
|
103 (*current_liboctave_error_handler) ("unrecoverable error in zgebak"); |
|
104 } |
457
|
105 |
|
106 return info; |
|
107 } |
|
108 |
|
109 /* |
|
110 ;;; Local Variables: *** |
|
111 ;;; mode: C++ *** |
|
112 ;;; End: *** |
|
113 */ |