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