Mercurial > octave
annotate liboctave/numeric/aepbalance.cc @ 22317:6ca3acf5fad8
move some new numeric classes to namespace octave::math
* aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc,
gepbalance.h, hess.cc, hess.h, lu.cc, lu.h, qr.cc, qr.h, qrp.cc,
qrp.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h,
sparse-dmsolve.cc,sparse-lu.cc, sparse-lu.h, sparse-qr.cc,
sparse-qr.h, svd.cc, svd.h: Move classes to namespace octave::math.
* __luinc__.cc, __qp__.cc, balance.cc, hess.cc, lu.cc, qz.cc,
schur.cc, sqrtm.cc, svd.cc, chol.cc, dmperm.cc, qr.cc, lex.h,
CMatrix.cc, CSparse.cc, dMatrix.cc, dSparse.cc, fCMatrix.cc,
fMatrix.cc, eigs-base.cc, oct-norm.cc: Update for new namespaces.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 16 Aug 2016 15:48:22 -0400 |
parents | 407c66ae1e20 |
children | 93b3cdd36854 |
rev | line source |
---|---|
457 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
3 Copyright (C) 1994-2015 John W. Eaton |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
4 Copyright (C) 2008 Jaroslav Hajek |
457 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
457 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
457 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21268
diff
changeset
|
25 # include "config.h" |
457 | 26 #endif |
27 | |
1730 | 28 #include <string> |
29 | |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
30 #include "CColVector.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
31 #include "CMatrix.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
32 #include "aepbalance.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
33 #include "dColVector.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
34 #include "dMatrix.h" |
1847 | 35 #include "f77-fcn.h" |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
36 #include "fCColVector.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
37 #include "fCMatrix.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
38 #include "fColVector.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
39 #include "fMatrix.h" |
457 | 40 |
41 extern "C" | |
42 { | |
4552 | 43 F77_RET_T |
44 F77_FUNC (dgebal, DGEBAL) (F77_CONST_CHAR_ARG_DECL, | |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
45 const F77_INT&, F77_DBLE*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
46 const F77_INT&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
47 F77_INT&, F77_DBLE*, F77_INT& |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
48 F77_CHAR_ARG_LEN_DECL); |
457 | 49 |
4552 | 50 F77_RET_T |
51 F77_FUNC (dgebak, DGEBAK) (F77_CONST_CHAR_ARG_DECL, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
52 F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
54 const F77_INT&, const F77_DBLE*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 const F77_INT&, F77_DBLE*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 const F77_INT&, F77_INT& |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
57 F77_CHAR_ARG_LEN_DECL |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
58 F77_CHAR_ARG_LEN_DECL); |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
59 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
60 F77_RET_T |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
61 F77_FUNC (sgebal, SGEBAL) (F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
62 const F77_INT&, F77_REAL*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 const F77_INT&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 F77_INT&, F77_REAL*, F77_INT& |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
65 F77_CHAR_ARG_LEN_DECL); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
66 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
67 F77_RET_T |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
68 F77_FUNC (sgebak, SGEBAK) (F77_CONST_CHAR_ARG_DECL, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
69 F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
70 const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 const F77_INT&, const F77_REAL*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 const F77_INT&, F77_REAL*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 const F77_INT&, F77_INT& |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
74 F77_CHAR_ARG_LEN_DECL |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
75 F77_CHAR_ARG_LEN_DECL); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
76 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
77 F77_RET_T |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
78 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 const F77_INT&, F77_DBLE_CMPLX*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
80 const F77_INT&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
81 F77_INT&, F77_DBLE*, F77_INT& |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
82 F77_CHAR_ARG_LEN_DECL); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
83 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
84 F77_RET_T |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
85 F77_FUNC (zgebak, ZGEBAK) (F77_CONST_CHAR_ARG_DECL, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
86 F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
88 const F77_INT&, const F77_DBLE*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
89 const F77_INT&, F77_DBLE_CMPLX*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 const F77_INT&, F77_INT& |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
91 F77_CHAR_ARG_LEN_DECL |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
92 F77_CHAR_ARG_LEN_DECL); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
93 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
94 F77_RET_T |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
95 F77_FUNC (cgebal, CGEBAL) (F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 const F77_INT&, F77_CMPLX*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
97 const F77_INT&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 F77_INT&, F77_REAL*, F77_INT& |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
99 F77_CHAR_ARG_LEN_DECL); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
100 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
101 F77_RET_T |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
102 F77_FUNC (cgebak, CGEBAK) (F77_CONST_CHAR_ARG_DECL, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
103 F77_CONST_CHAR_ARG_DECL, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
105 const F77_INT&, const F77_REAL*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
106 const F77_INT&, F77_CMPLX*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
107 const F77_INT&, F77_INT& |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
108 F77_CHAR_ARG_LEN_DECL |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
109 F77_CHAR_ARG_LEN_DECL); |
457 | 110 } |
111 | |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
112 static inline char |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
113 get_job (bool noperm, bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
114 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
115 return noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B'); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
116 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
117 |
22317
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
118 namespace octave |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
119 { |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
120 namespace math |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
121 { |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
122 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
123 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
124 aepbalance<Matrix>::aepbalance (const Matrix& a, bool noperm, bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
125 : balanced_mat (a), scale (), ilo (), ihi (), job (get_job (noperm, noscal)) |
457 | 126 { |
5275 | 127 octave_idx_type n = a.cols (); |
1730 | 128 |
1933 | 129 if (a.rows () != n) |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
130 (*current_liboctave_error_handler) ("aepbalance: requires square matrix"); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
131 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
132 scale = ColumnVector (n); |
457 | 133 |
5275 | 134 octave_idx_type info; |
457 | 135 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
136 F77_XFCN (dgebal, DGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), n, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
137 balanced_mat.fortran_vec (), n, ilo, ihi, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
138 scale.fortran_vec (), info |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
139 F77_CHAR_ARG_LEN (1))); |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
140 } |
457 | 141 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
142 template <> |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
143 Matrix |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
144 aepbalance<Matrix>::balancing_matrix (void) const |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
145 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
146 octave_idx_type n = balanced_mat.rows (); |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
147 Matrix balancing_mat (n, n, 0.0); |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
148 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
|
149 balancing_mat.elem (i ,i) = 1.0; |
457 | 150 |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
151 octave_idx_type info; |
1933 | 152 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
153 char side = 'R'; |
457 | 154 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
155 F77_XFCN (dgebak, DGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
156 F77_CONST_CHAR_ARG2 (&side, 1), |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
157 n, ilo, ihi, scale.data (), n, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
158 balancing_mat.fortran_vec (), n, info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
159 F77_CHAR_ARG_LEN (1) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
160 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
161 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
162 return balancing_mat; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
163 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
164 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
165 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
166 aepbalance<FloatMatrix>::aepbalance (const FloatMatrix& a, bool noperm, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
167 bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
168 : balanced_mat (a), scale (), ilo (), ihi (), job (get_job (noperm, noscal)) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
169 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
170 octave_idx_type n = a.cols (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
171 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
172 if (a.rows () != n) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
173 (*current_liboctave_error_handler) ("aepbalance: requires square matrix"); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
174 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
175 scale = FloatColumnVector (n); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
176 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
177 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
178 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
179 F77_XFCN (sgebal, SGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), n, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
180 balanced_mat.fortran_vec (), n, ilo, ihi, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
181 scale.fortran_vec (), info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
182 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
183 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
184 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
185 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
186 FloatMatrix |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
187 aepbalance<FloatMatrix>::balancing_matrix (void) const |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
188 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
189 octave_idx_type n = balanced_mat.rows (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
190 FloatMatrix balancing_mat (n, n, 0.0); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
191 for (octave_idx_type i = 0; i < n; i++) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
192 balancing_mat.elem (i ,i) = 1.0; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
193 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
194 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
195 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
196 char side = 'R'; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
197 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
198 F77_XFCN (sgebak, SGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
199 F77_CONST_CHAR_ARG2 (&side, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
200 n, ilo, ihi, scale.data (), n, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
201 balancing_mat.fortran_vec (), n, info |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
202 F77_CHAR_ARG_LEN (1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
203 F77_CHAR_ARG_LEN (1))); |
457 | 204 |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
205 return balancing_mat; |
457 | 206 } |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
207 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
208 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
209 aepbalance<ComplexMatrix>::aepbalance (const ComplexMatrix& a, bool noperm, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
210 bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
211 : balanced_mat (a), scale (), ilo (), ihi (), job (get_job (noperm, noscal)) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
212 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
213 octave_idx_type n = a.cols (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
214 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
215 if (a.rows () != n) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
216 (*current_liboctave_error_handler) ("aepbalance: requires square matrix"); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
217 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
218 scale = ColumnVector (n); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
219 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
220 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
221 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
222 F77_XFCN (zgebal, ZGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), n, |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
223 F77_DBLE_CMPLX_ARG (balanced_mat.fortran_vec ()), n, ilo, ihi, |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
224 scale.fortran_vec (), info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
225 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
226 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
227 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
228 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
229 ComplexMatrix |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
230 aepbalance<ComplexMatrix>::balancing_matrix (void) const |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
231 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
232 octave_idx_type n = balanced_mat.rows (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
233 ComplexMatrix balancing_mat (n, n, 0.0); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
234 for (octave_idx_type i = 0; i < n; i++) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
235 balancing_mat.elem (i, i) = 1.0; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
236 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
237 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
238 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
239 char side = 'R'; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
240 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
241 F77_XFCN (zgebak, ZGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
242 F77_CONST_CHAR_ARG2 (&side, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
243 n, ilo, ihi, scale.data (), n, |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
244 F77_DBLE_CMPLX_ARG (balancing_mat.fortran_vec ()), n, info |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
245 F77_CHAR_ARG_LEN (1) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
246 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
247 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
248 return balancing_mat; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
249 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
250 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
251 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
252 aepbalance<FloatComplexMatrix>::aepbalance (const FloatComplexMatrix& a, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
253 bool noperm, bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
254 : balanced_mat (a), scale (), ilo (), ihi (), job (get_job (noperm, noscal)) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
255 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
256 octave_idx_type n = a.cols (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
257 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
258 if (a.rows () != n) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
259 (*current_liboctave_error_handler) ("aepbalance: requires square matrix"); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
260 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
261 scale = FloatColumnVector (n); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
262 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
263 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
264 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
265 F77_XFCN (cgebal, CGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), n, |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
266 F77_CMPLX_ARG (balanced_mat.fortran_vec ()), n, ilo, ihi, |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
267 scale.fortran_vec (), info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
268 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
269 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
270 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
271 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
272 FloatComplexMatrix |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
273 aepbalance<FloatComplexMatrix>::balancing_matrix (void) const |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
274 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
275 octave_idx_type n = balanced_mat.rows (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
276 FloatComplexMatrix balancing_mat (n, n, 0.0); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
277 for (octave_idx_type i = 0; i < n; i++) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
278 balancing_mat.elem (i, i) = 1.0; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
279 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
280 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
281 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
282 char side = 'R'; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
283 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
284 F77_XFCN (cgebak, CGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
285 F77_CONST_CHAR_ARG2 (&side, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
286 n, ilo, ihi, scale.data (), n, |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
287 F77_CMPLX_ARG (balancing_mat.fortran_vec ()), n, info |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
288 F77_CHAR_ARG_LEN (1) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
289 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
290 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
291 return balancing_mat; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
292 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
293 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
294 // Instantiations we need. |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
295 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
296 template class aepbalance<Matrix>; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
297 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
298 template class aepbalance<FloatMatrix>; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
299 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
300 template class aepbalance<ComplexMatrix>; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
301 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
302 template class aepbalance<FloatComplexMatrix>; |
22317
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
303 |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
304 } |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
305 } |