annotate liboctave/numeric/fCmplxAEPBAL.cc @ 21136:7cac4e7458f2

maint: clean up code around calls to current_liboctave_error_handler. Remove statements after call to handler that are no longer reachable. Place input validation first and immediately call handler if necessary. Change if/error_handler/else to if/error_handler and re-indent code. * Array-util.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MArray.cc, PermMatrix.cc, Sparse.cc, Sparse.h, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc, CmplxQR.cc, CmplxSCHUR.cc, CmplxSVD.cc, DASPK.cc, EIG.cc, LSODE.cc, Quad.cc, SparseCmplxCHOL.cc, SparseCmplxLU.cc, SparseCmplxQR.cc, SparseQR.cc, SparsedbleCHOL.cc, SparsedbleLU.cc, base-lu.cc, bsxfun-defs.cc, dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc, fCmplxCHOL.cc, fCmplxLU.cc, fCmplxQR.cc, fCmplxSCHUR.cc, fEIG.cc, floatAEPBAL.cc, floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc, floatSCHUR.cc, floatSVD.cc, lo-specfun.cc, oct-fftw.cc, oct-rand.cc, oct-spparms.cc, sparse-base-chol.cc, sparse-dmsolve.cc, file-ops.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-syscalls.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, lo-ieee.cc, lo-regexp.cc, oct-base64.cc, oct-shlib.cc, pathsearch.cc, singleton-cleanup.cc, sparse-util.cc, unwind-prot.cc: Remove statements after call to handler that are no longer reachable. Place input validation first and immediately call handler if necessary. Change if/error_handler/else to if/error_handler and re-indent code.
author Rik <rik@octave.org>
date Sat, 23 Jan 2016 13:52:03 -0800
parents 4197fc428c7d
children f7121e111991
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
3 Copyright (C) 1994-2015 John W. Eaton
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
4 Copyright (C) 2008 Jaroslav Hajek
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 This file is part of Octave.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 option) any later version.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 for more details.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 */
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #include <config.h>
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #endif
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <string>
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "fCmplxAEPBAL.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "fMatrix.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "f77-fcn.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 extern "C"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
37 F77_FUNC (cgebal, CGEBAL) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
38 const octave_idx_type&, FloatComplex*,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
39 const octave_idx_type&, octave_idx_type&,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
40 octave_idx_type&, float*, octave_idx_type&
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
41 F77_CHAR_ARG_LEN_DECL);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
42
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
44 F77_FUNC (cgebak, CGEBAK) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
45 F77_CONST_CHAR_ARG_DECL,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
46 const octave_idx_type&, const octave_idx_type&,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
47 const octave_idx_type&, const float*,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
48 const octave_idx_type&, FloatComplex*,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
49 const octave_idx_type&, octave_idx_type&
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
50 F77_CHAR_ARG_LEN_DECL
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 10314
diff changeset
51 F77_CHAR_ARG_LEN_DECL);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
54 FloatComplexAEPBALANCE::FloatComplexAEPBALANCE (const FloatComplexMatrix& a,
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
55 bool noperm, bool noscal)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
56 : base_aepbal<FloatComplexMatrix, FloatColumnVector> ()
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 octave_idx_type n = a.cols ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 if (a.rows () != n)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 19697
diff changeset
61 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 octave_idx_type info;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
65 scale = FloatColumnVector (n);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 float *pscale = scale.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 balanced_mat = a;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 FloatComplex *p_balanced_mat = balanced_mat.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
71 job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B');
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 F77_XFCN (cgebal, CGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
74 n, p_balanced_mat, n, ilo, ihi,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
75 pscale, info
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
76 F77_CHAR_ARG_LEN (1)));
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
77 }
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
79 FloatComplexMatrix
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
80 FloatComplexAEPBALANCE::balancing_matrix (void) const
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
81 {
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
82 octave_idx_type n = balanced_mat.rows ();
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
83 FloatComplexMatrix balancing_mat (n, n, 0.0);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 for (octave_idx_type i = 0; i < n; i++)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 balancing_mat.elem (i, i) = 1.0;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 FloatComplex *p_balancing_mat = balancing_mat.fortran_vec ();
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
88 const float *pscale = scale.fortran_vec ();
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
89
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
90 octave_idx_type info;
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 char side = 'R';
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 F77_XFCN (cgebak, CGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
95 F77_CONST_CHAR_ARG2 (&side, 1),
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
96 n, ilo, ihi, pscale, n,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
97 p_balancing_mat, n, info
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
98 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
99 F77_CHAR_ARG_LEN (1)));
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7792
diff changeset
101 return balancing_mat;
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 }