annotate liboctave/CmplxAEPBAL.cc @ 11518:141b3fb5cef7

style fixes
author John W. Eaton <jwe@octave.org>
date Thu, 13 Jan 2011 16:52:30 -0500
parents 07ebe522dac2
children fd0a3ac60b0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
1 /*
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, 2005,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 2007 John W. Eaton
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
5 Copyright (C) 2008 Jaroslav Hajek
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
6
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
8
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
12 option) any later version.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
13
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
17 for more details.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
18
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
21 <http://www.gnu.org/licenses/>.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
22
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
23 */
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
24
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1011
diff changeset
26 #include <config.h>
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
27 #endif
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
28
1730
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
29 #include <string>
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
30
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
31 #include "CmplxAEPBAL.h"
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
32 #include "dMatrix.h"
1847
2ffe49eb95a5 [project @ 1996-02-03 12:47:55 by jwe]
jwe
parents: 1730
diff changeset
33 #include "f77-fcn.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
34
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
35 extern "C"
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
36 {
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
37 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
38 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
39 const octave_idx_type&, Complex*,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
40 const octave_idx_type&, octave_idx_type&,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
41 octave_idx_type&, double*, octave_idx_type&
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
42 F77_CHAR_ARG_LEN_DECL);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
43
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
44 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
45 F77_FUNC (zgebak, ZGEBAK) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
46 F77_CONST_CHAR_ARG_DECL,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
47 const octave_idx_type&, const octave_idx_type&,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
48 const octave_idx_type&, const double*,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
49 const octave_idx_type&, Complex*,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
50 const octave_idx_type&, octave_idx_type&
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
51 F77_CHAR_ARG_LEN_DECL
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
52 F77_CHAR_ARG_LEN_DECL);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
53 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
54
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
55 ComplexAEPBALANCE::ComplexAEPBALANCE (const ComplexMatrix& a,
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
56 bool noperm, bool noscal)
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
57 : base_aepbal<ComplexMatrix, ColumnVector> ()
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
58 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
59 octave_idx_type n = a.cols ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
60
1933
333923894848 [project @ 1996-02-12 03:07:39 by jwe]
jwe
parents: 1882
diff changeset
61 if (a.rows () != n)
1730
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
62 {
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
63 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
64 return;
1730
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
65 }
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
66
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
67 octave_idx_type info;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
68
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
69 scale = ColumnVector (n);
1933
333923894848 [project @ 1996-02-12 03:07:39 by jwe]
jwe
parents: 1882
diff changeset
70 double *pscale = scale.fortran_vec ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
71
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
72 balanced_mat = a;
1933
333923894848 [project @ 1996-02-12 03:07:39 by jwe]
jwe
parents: 1882
diff changeset
73 Complex *p_balanced_mat = balanced_mat.fortran_vec ();
1730
a744f4d0ba59 [project @ 1996-01-09 12:16:29 by jwe]
jwe
parents: 1360
diff changeset
74
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
75 job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B');
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
76
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
77 F77_XFCN (zgebal, ZGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
78 n, p_balanced_mat, n, ilo, ihi,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
79 pscale, info
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
80 F77_CHAR_ARG_LEN (1)));
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
81 }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
82
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
83 ComplexMatrix
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
84 ComplexAEPBALANCE::balancing_matrix (void) const
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
85 {
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
86 octave_idx_type n = balanced_mat.rows ();
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
87 ComplexMatrix balancing_mat (n, n, 0.0);
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
88 for (octave_idx_type i = 0; i < n; i++)
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
89 balancing_mat.elem (i, i) = 1.0;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
90
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
91 Complex *p_balancing_mat = balancing_mat.fortran_vec ();
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
92 const double *pscale = scale.fortran_vec ();
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
93
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
94 octave_idx_type info;
1933
333923894848 [project @ 1996-02-12 03:07:39 by jwe]
jwe
parents: 1882
diff changeset
95
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
96 char side = 'R';
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
97
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
98 F77_XFCN (zgebak, ZGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
99 F77_CONST_CHAR_ARG2 (&side, 1),
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
100 n, ilo, ihi, pscale, n,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
101 p_balancing_mat, n, info
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
102 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
103 F77_CHAR_ARG_LEN (1)));
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
104
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
105 return balancing_mat;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
106 }