Mercurial > octave
annotate liboctave/numeric/aepbalance.cc @ 22322:93b3cdd36854
move most f77 function decls to separate header files
* liboctave/numeric/lo-amos-proto.h,
liboctave/numeric/lo-arpack-proto.h,
liboctave/numeric/lo-blas-proto.h,
liboctave/numeric/lo-fftpack-proto.h,
liboctave/numeric/lo-lapack-proto.h,
liboctave/numeric/lo-qrupdate-proto.h,
liboctave/numeric/lo-ranlib-proto.h,
liboctave/numeric/lo-slatec-proto.h: New files.
* liboctave/numeric/module.mk: Update.
* __pchip_deriv__.cc, dot.cc, interpreter.cc, ordschur.cc, qz.cc,
CColVector.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc,
dColVector.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc,
fCColVector.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc,
fColVector.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, EIG.cc,
aepbalance.cc, chol.cc, eigs-base.cc, fEIG.cc, gepbalance.cc, gsvd.cc,
hess.cc, lo-specfun.cc, lu.cc, oct-rand.cc, qr.cc, qrp.cc,
randpoisson.cc, schur.cc, sparse-qr.cc, svd.cc:
Use new header files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Aug 2016 00:18:08 -0400 |
parents | 6ca3acf5fad8 |
children | bac0d6f07a3e |
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" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
35 #include "fCColVector.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
36 #include "fCMatrix.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
37 #include "fColVector.h" |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
38 #include "fMatrix.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22317
diff
changeset
|
39 #include "lo-lapack-proto.h" |
457 | 40 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
41 static inline char |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
42 get_job (bool noperm, bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
43 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
44 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
|
45 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
46 |
22317
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
47 namespace octave |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
48 { |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
49 namespace math |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
50 { |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
51 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
52 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
53 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
|
54 : balanced_mat (a), scale (), ilo (), ihi (), job (get_job (noperm, noscal)) |
457 | 55 { |
5275 | 56 octave_idx_type n = a.cols (); |
1730 | 57 |
1933 | 58 if (a.rows () != n) |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
59 (*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
|
60 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
61 scale = ColumnVector (n); |
457 | 62 |
5275 | 63 octave_idx_type info; |
457 | 64 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
65 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
|
66 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
|
67 scale.fortran_vec (), info |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
68 F77_CHAR_ARG_LEN (1))); |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
69 } |
457 | 70 |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
71 template <> |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
72 Matrix |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
73 aepbalance<Matrix>::balancing_matrix (void) const |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
74 { |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
75 octave_idx_type n = balanced_mat.rows (); |
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
76 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
|
77 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
|
78 balancing_mat.elem (i ,i) = 1.0; |
457 | 79 |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
80 octave_idx_type info; |
1933 | 81 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
82 char side = 'R'; |
457 | 83 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
84 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
|
85 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
|
86 n, ilo, ihi, scale.data (), n, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
87 balancing_mat.fortran_vec (), n, info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
88 F77_CHAR_ARG_LEN (1) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
89 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
90 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
91 return balancing_mat; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
92 } |
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 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
95 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
|
96 bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
97 : 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
|
98 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
99 octave_idx_type n = a.cols (); |
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 if (a.rows () != n) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
102 (*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
|
103 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
104 scale = FloatColumnVector (n); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
105 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
106 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
107 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
108 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
|
109 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
|
110 scale.fortran_vec (), info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
111 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
112 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
113 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
114 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
115 FloatMatrix |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
116 aepbalance<FloatMatrix>::balancing_matrix (void) const |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
117 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
123 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
124 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
125 char side = 'R'; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
126 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
127 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
|
128 F77_CONST_CHAR_ARG2 (&side, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
129 n, ilo, ihi, scale.data (), n, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
130 balancing_mat.fortran_vec (), n, info |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
131 F77_CHAR_ARG_LEN (1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
132 F77_CHAR_ARG_LEN (1))); |
457 | 133 |
8386
a5e080076778
make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7482
diff
changeset
|
134 return balancing_mat; |
457 | 135 } |
21268
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
136 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
137 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
138 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
|
139 bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
140 : 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
|
141 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
142 octave_idx_type n = a.cols (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
143 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
144 if (a.rows () != n) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
145 (*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
|
146 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
147 scale = ColumnVector (n); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
148 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
149 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
150 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
151 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
|
152 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
|
153 scale.fortran_vec (), info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
154 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
155 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
156 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
157 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
158 ComplexMatrix |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
159 aepbalance<ComplexMatrix>::balancing_matrix (void) const |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
160 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 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
|
165 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
166 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
167 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
168 char side = 'R'; |
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 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
|
171 F77_CONST_CHAR_ARG2 (&side, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
172 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
|
173 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
|
174 F77_CHAR_ARG_LEN (1) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
175 F77_CHAR_ARG_LEN (1))); |
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 return balancing_mat; |
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 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
180 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
181 aepbalance<FloatComplexMatrix>::aepbalance (const FloatComplexMatrix& a, |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
182 bool noperm, bool noscal) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
183 : 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
|
184 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
185 octave_idx_type n = a.cols (); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
186 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
187 if (a.rows () != n) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
188 (*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
|
189 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
190 scale = FloatColumnVector (n); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
191 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
192 octave_idx_type info; |
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 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
|
195 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
|
196 scale.fortran_vec (), info |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
197 F77_CHAR_ARG_LEN (1))); |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
198 } |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
199 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
200 template <> |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
201 FloatComplexMatrix |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
202 aepbalance<FloatComplexMatrix>::balancing_matrix (void) const |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
203 { |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
209 octave_idx_type info; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
210 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
211 char side = 'R'; |
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 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
|
214 F77_CONST_CHAR_ARG2 (&side, 1), |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
215 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
|
216 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
|
217 F77_CHAR_ARG_LEN (1) |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
218 F77_CHAR_ARG_LEN (1))); |
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 return balancing_mat; |
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 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
223 // Instantiations we need. |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
224 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
225 template class aepbalance<Matrix>; |
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 template class aepbalance<FloatMatrix>; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
228 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
229 template class aepbalance<ComplexMatrix>; |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
230 |
f08ae27289e4
better use of templates for balance classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
231 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
|
232 |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
233 } |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
234 } |