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