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