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 "dbleAEPBAL.h" |
1847
|
35 #include "f77-fcn.h" |
457
|
36 |
|
37 extern "C" |
|
38 { |
1253
|
39 int F77_FCN (dgebal, DGEBAL) (const char*, const int&, double*, |
|
40 const int&, int&, int&, double*, |
|
41 int&, long, long); |
457
|
42 |
1253
|
43 int F77_FCN (dgebak, DGEBAK) (const char*, const char*, const int&, |
|
44 const int&, const int&, double*, |
|
45 const int&, double*, const int&, |
|
46 int&, long, long); |
457
|
47 } |
|
48 |
|
49 int |
1730
|
50 AEPBALANCE::init (const Matrix& a, const string& balance_job) |
457
|
51 { |
|
52 int a_nc = a.cols (); |
1730
|
53 |
457
|
54 if (a.rows () != a_nc) |
|
55 { |
|
56 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); |
|
57 return -1; |
|
58 } |
|
59 |
|
60 int n = a_nc; |
|
61 |
1360
|
62 // Parameters for balance call. |
457
|
63 |
|
64 int info; |
|
65 int ilo; |
|
66 int ihi; |
|
67 double *scale = new double [n]; |
|
68 |
1360
|
69 // Copy matrix into local structure. |
457
|
70 |
|
71 balanced_mat = a; |
|
72 |
1730
|
73 char bal_job = balance_job[0]; |
|
74 |
|
75 F77_FCN (dgebal, DGEBAL) (&bal_job, n, |
1253
|
76 balanced_mat.fortran_vec (), n, ilo, ihi, |
|
77 scale, info, 1L, 1L); |
457
|
78 |
1360
|
79 // Initialize balancing matrix to identity. |
457
|
80 |
|
81 balancing_mat = Matrix (n, n, 0.0); |
|
82 for (int i = 0; i < n; i++) |
|
83 balancing_mat.elem (i ,i) = 1.0; |
|
84 |
1730
|
85 F77_FCN (dgebak, DGEBAK) (&bal_job, "R", n, ilo, ihi, scale, n, |
1253
|
86 balancing_mat.fortran_vec (), n, info, 1L, |
|
87 1L); |
457
|
88 |
|
89 delete [] scale; |
|
90 |
|
91 return info; |
|
92 } |
|
93 |
|
94 /* |
|
95 ;;; Local Variables: *** |
|
96 ;;; mode: C++ *** |
|
97 ;;; page-delimiter: "^/\\*" *** |
|
98 ;;; End: *** |
|
99 */ |