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