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 |
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
457
|
25 #endif |
|
26 |
1730
|
27 #include <string> |
|
28 |
457
|
29 #include "dbleAEPBAL.h" |
1847
|
30 #include "f77-fcn.h" |
457
|
31 |
|
32 extern "C" |
|
33 { |
4552
|
34 F77_RET_T |
|
35 F77_FUNC (dgebal, DGEBAL) (F77_CONST_CHAR_ARG_DECL, |
|
36 const int&, double*, const int&, int&, |
|
37 int&, double*, int& |
|
38 F77_CHAR_ARG_LEN_DECL); |
457
|
39 |
4552
|
40 F77_RET_T |
|
41 F77_FUNC (dgebak, DGEBAK) (F77_CONST_CHAR_ARG_DECL, |
|
42 F77_CONST_CHAR_ARG_DECL, |
|
43 const int&, const int&, const int&, double*, |
|
44 const int&, double*, const int&, int& |
|
45 F77_CHAR_ARG_LEN_DECL |
|
46 F77_CHAR_ARG_LEN_DECL); |
457
|
47 } |
|
48 |
|
49 int |
3504
|
50 AEPBALANCE::init (const Matrix& a, const std::string& balance_job) |
457
|
51 { |
1933
|
52 int n = a.cols (); |
1730
|
53 |
1933
|
54 if (a.rows () != n) |
457
|
55 { |
|
56 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); |
|
57 return -1; |
|
58 } |
|
59 |
|
60 int info; |
|
61 int ilo; |
|
62 int ihi; |
|
63 |
1933
|
64 Array<double> scale (n); |
|
65 double *pscale = scale.fortran_vec (); |
457
|
66 |
|
67 balanced_mat = a; |
1933
|
68 double *p_balanced_mat = balanced_mat.fortran_vec (); |
1730
|
69 |
1933
|
70 char job = balance_job[0]; |
457
|
71 |
4552
|
72 F77_XFCN (dgebal, DGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), |
|
73 n, p_balanced_mat, n, ilo, ihi, pscale, info |
|
74 F77_CHAR_ARG_LEN (1))); |
457
|
75 |
1933
|
76 if (f77_exception_encountered) |
|
77 (*current_liboctave_error_handler) ("unrecoverable error in dgebal"); |
|
78 else |
|
79 { |
|
80 balancing_mat = Matrix (n, n, 0.0); |
|
81 for (int i = 0; i < n; i++) |
|
82 balancing_mat.elem (i ,i) = 1.0; |
457
|
83 |
1933
|
84 double *p_balancing_mat = balancing_mat.fortran_vec (); |
|
85 |
|
86 char side = 'R'; |
457
|
87 |
4552
|
88 F77_XFCN (dgebak, DGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
|
89 F77_CONST_CHAR_ARG2 (&side, 1), |
|
90 n, ilo, ihi, pscale, n, |
|
91 p_balancing_mat, n, info |
|
92 F77_CHAR_ARG_LEN (1) |
|
93 F77_CHAR_ARG_LEN (1))); |
1933
|
94 |
|
95 if (f77_exception_encountered) |
|
96 (*current_liboctave_error_handler) ("unrecoverable error in dgebak"); |
|
97 } |
457
|
98 |
|
99 return info; |
|
100 } |
|
101 |
|
102 /* |
|
103 ;;; Local Variables: *** |
|
104 ;;; mode: C++ *** |
|
105 ;;; End: *** |
|
106 */ |