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