457
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
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 |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
457
|
21 |
|
22 */ |
|
23 |
1296
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
457
|
28 #ifdef HAVE_CONFIG_H |
1192
|
29 #include <config.h> |
457
|
30 #endif |
|
31 |
1730
|
32 #include <string> |
|
33 |
457
|
34 #include "CmplxAEPBAL.h" |
|
35 #include "dMatrix.h" |
1847
|
36 #include "f77-fcn.h" |
457
|
37 |
|
38 extern "C" |
|
39 { |
1253
|
40 int F77_FCN (zgebal, ZGEBAL) (const char*, const int&, Complex*, |
|
41 const int&, int&, int&, double*, int&, |
|
42 long, long); |
457
|
43 |
1253
|
44 int F77_FCN (zgebak, ZGEBAK) (const char*, const char*, const int&, |
|
45 const int&, const int&, double*, const |
|
46 int&, Complex*, const int&, int&, |
|
47 long, long); |
457
|
48 } |
|
49 |
|
50 int |
1730
|
51 ComplexAEPBALANCE::init (const ComplexMatrix& a, const string& balance_job) |
457
|
52 { |
1730
|
53 int a_nc = a.cols (); |
457
|
54 |
1730
|
55 if (a.rows () != a_nc) |
|
56 { |
|
57 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); |
|
58 return -1; |
|
59 } |
|
60 |
|
61 int n = a_nc; |
457
|
62 |
1360
|
63 // Parameters for balance call. |
457
|
64 |
|
65 int info; |
|
66 int ilo; |
|
67 int ihi; |
|
68 double *scale = new double [n]; |
|
69 |
1360
|
70 // Copy matrix into local structure. |
457
|
71 |
|
72 balanced_mat = a; |
|
73 |
1730
|
74 char bal_job = balance_job[0]; |
|
75 |
|
76 F77_FCN (zgebal, ZGEBAL) (&bal_job, n, |
1253
|
77 balanced_mat.fortran_vec (), n, ilo, ihi, |
|
78 scale, info, 1L, 1L); |
457
|
79 |
1360
|
80 // Initialize balancing matrix to identity. |
457
|
81 |
|
82 balancing_mat = Matrix (n, n, 0.0); |
|
83 for (int i = 0; i < n; i++) |
|
84 balancing_mat (i, i) = 1.0; |
|
85 |
1730
|
86 F77_FCN (zgebak, ZGEBAK) (&bal_job, "R", n, ilo, ihi, scale, n, |
1253
|
87 balancing_mat.fortran_vec (), n, info, 1L, |
|
88 1L); |
457
|
89 |
|
90 delete [] scale; |
|
91 |
|
92 return info; |
|
93 } |
|
94 |
|
95 /* |
|
96 ;;; Local Variables: *** |
|
97 ;;; mode: C++ *** |
|
98 ;;; page-delimiter: "^/\\*" *** |
|
99 ;;; End: *** |
|
100 */ |