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 |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
457
|
26 #endif |
|
27 |
|
28 #include "CmplxAEPBAL.h" |
|
29 #include "dMatrix.h" |
|
30 #include "f77-uscore.h" |
|
31 |
|
32 extern "C" |
|
33 { |
|
34 int F77_FCN (zgebal) (const char*, const int*, Complex*, const int*, |
|
35 int*, int*, double*, int*, long, long); |
|
36 |
|
37 int F77_FCN (zgebak) (const char*, const char*, const int*, const int*, |
|
38 const int*, double*, const int*, Complex*, |
|
39 const int*, int*, long, long); |
|
40 } |
|
41 |
|
42 int |
|
43 ComplexAEPBALANCE::init (const ComplexMatrix& a, const char *balance_job) |
|
44 { |
|
45 |
|
46 int n = a.cols (); |
|
47 |
|
48 // Parameters for balance call. |
|
49 |
|
50 int info; |
|
51 int ilo; |
|
52 int ihi; |
|
53 double *scale = new double [n]; |
|
54 |
|
55 // Copy matrix into local structure. |
|
56 |
|
57 balanced_mat = a; |
|
58 |
|
59 F77_FCN (zgebal) (balance_job, &n, balanced_mat.fortran_vec (), |
|
60 &n, &ilo, &ihi, scale, &info, 1L, 1L); |
|
61 |
|
62 // Initialize balancing matrix to identity. |
|
63 |
|
64 balancing_mat = Matrix (n, n, 0.0); |
|
65 for (int i = 0; i < n; i++) |
|
66 balancing_mat (i, i) = 1.0; |
|
67 |
|
68 F77_FCN (zgebak) (balance_job, "R", &n, &ilo, &ihi, scale, &n, |
|
69 balancing_mat.fortran_vec (), &n, &info, 1L, 1L); |
|
70 |
|
71 delete [] scale; |
|
72 |
|
73 return info; |
|
74 } |
|
75 |
|
76 /* |
|
77 ;;; Local Variables: *** |
|
78 ;;; mode: C++ *** |
|
79 ;;; page-delimiter: "^/\\*" *** |
|
80 ;;; End: *** |
|
81 */ |