457
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
457
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
457
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1296
|
24 #pragma implementation |
|
25 #endif |
|
26 |
457
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
457
|
29 #endif |
|
30 |
1730
|
31 #include <string> |
|
32 |
457
|
33 #include "dbleAEPBAL.h" |
1847
|
34 #include "f77-fcn.h" |
457
|
35 |
|
36 extern "C" |
|
37 { |
3887
|
38 int F77_FUNC (dgebal, DGEBAL) (const char*, const int&, double*, |
1253
|
39 const int&, int&, int&, double*, |
|
40 int&, long, long); |
457
|
41 |
3887
|
42 int F77_FUNC (dgebak, DGEBAK) (const char*, const char*, const int&, |
1253
|
43 const int&, const int&, double*, |
|
44 const int&, double*, const int&, |
|
45 int&, long, long); |
457
|
46 } |
|
47 |
|
48 int |
3504
|
49 AEPBALANCE::init (const Matrix& a, const std::string& balance_job) |
457
|
50 { |
1933
|
51 int n = a.cols (); |
1730
|
52 |
1933
|
53 if (a.rows () != n) |
457
|
54 { |
|
55 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); |
|
56 return -1; |
|
57 } |
|
58 |
|
59 int info; |
|
60 int ilo; |
|
61 int ihi; |
|
62 |
1933
|
63 Array<double> scale (n); |
|
64 double *pscale = scale.fortran_vec (); |
457
|
65 |
|
66 balanced_mat = a; |
1933
|
67 double *p_balanced_mat = balanced_mat.fortran_vec (); |
1730
|
68 |
1933
|
69 char job = balance_job[0]; |
457
|
70 |
1933
|
71 F77_XFCN (dgebal, DGEBAL, (&job, n, p_balanced_mat, n, ilo, ihi, |
|
72 pscale, info, 1L, 1L)); |
457
|
73 |
1933
|
74 if (f77_exception_encountered) |
|
75 (*current_liboctave_error_handler) ("unrecoverable error in dgebal"); |
|
76 else |
|
77 { |
|
78 balancing_mat = Matrix (n, n, 0.0); |
|
79 for (int i = 0; i < n; i++) |
|
80 balancing_mat.elem (i ,i) = 1.0; |
457
|
81 |
1933
|
82 double *p_balancing_mat = balancing_mat.fortran_vec (); |
|
83 |
|
84 char side = 'R'; |
457
|
85 |
1933
|
86 F77_XFCN (dgebak, DGEBAK, (&job, &side, n, ilo, ihi, pscale, n, |
|
87 p_balancing_mat, n, info, 1L, 1L)); |
|
88 |
|
89 if (f77_exception_encountered) |
|
90 (*current_liboctave_error_handler) ("unrecoverable error in dgebak"); |
|
91 } |
457
|
92 |
|
93 return info; |
|
94 } |
|
95 |
|
96 /* |
|
97 ;;; Local Variables: *** |
|
98 ;;; mode: C++ *** |
|
99 ;;; End: *** |
|
100 */ |