Mercurial > hg > octave-nkf
annotate liboctave/fCmplxHESS.cc @ 15283:a95432e7309c stable release-3-6-3
Version 3.6.3 released.
* configure.ac (AC_INIT): Version is now 3.6.3.
(OCTAVE_RELEASE_DATE): Now 2012-09-04.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 04 Sep 2012 13:17:13 -0400 |
parents | 72c96de7a403 |
children |
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 |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 1994-2012 John W. Eaton |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 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
|
8 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
|
9 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
|
10 option) any later version. |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 for more details. |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 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
|
18 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
|
19 <http://www.gnu.org/licenses/>. |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
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 #ifdef HAVE_CONFIG_H |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 #include <config.h> |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include "fCmplxHESS.h" |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include "f77-fcn.h" |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include "lo-error.h" |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 extern "C" |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 { |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 F77_RET_T |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 F77_FUNC (cgebal, CGEBAL) (F77_CONST_CHAR_ARG_DECL, |
11495 | 35 const octave_idx_type&, FloatComplex*, |
36 const octave_idx_type&, octave_idx_type&, | |
37 octave_idx_type&, float*, octave_idx_type& | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
38 F77_CHAR_ARG_LEN_DECL); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
39 |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 F77_RET_T |
11495 | 41 F77_FUNC (cgehrd, CGEHRD) (const octave_idx_type&, const octave_idx_type&, |
42 const octave_idx_type&, FloatComplex*, | |
43 const octave_idx_type&, FloatComplex*, | |
44 FloatComplex*, const octave_idx_type&, | |
45 octave_idx_type&); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
46 |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 F77_RET_T |
11495 | 48 F77_FUNC (cunghr, CUNGHR) (const octave_idx_type&, const octave_idx_type&, |
49 const octave_idx_type&, FloatComplex*, | |
50 const octave_idx_type&, FloatComplex*, | |
51 FloatComplex*, const octave_idx_type&, | |
52 octave_idx_type&); | |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 F77_RET_T |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 F77_FUNC (cgebak, CGEBAK) (F77_CONST_CHAR_ARG_DECL, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
56 F77_CONST_CHAR_ARG_DECL, |
11495 | 57 const octave_idx_type&, const octave_idx_type&, |
58 const octave_idx_type&, float*, | |
59 const octave_idx_type&, FloatComplex*, | |
60 const octave_idx_type&, octave_idx_type& | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
61 F77_CHAR_ARG_LEN_DECL |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
62 F77_CHAR_ARG_LEN_DECL); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 } |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 octave_idx_type |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 FloatComplexHESS::init (const FloatComplexMatrix& a) |
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 octave_idx_type a_nr = a.rows (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 octave_idx_type a_nc = a.cols (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 if (a_nr != a_nc) |
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 (*current_liboctave_error_handler) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
74 ("FloatComplexHESS requires square matrix"); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 return -1; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 } |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 char job = 'N'; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 char side = 'R'; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 octave_idx_type n = a_nc; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 octave_idx_type lwork = 32 * n; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 octave_idx_type info; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 octave_idx_type ilo; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 octave_idx_type ihi; |
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 hess_mat = a; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 FloatComplex *h = hess_mat.fortran_vec (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 Array<float> scale (dim_vector (n, 1)); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 float *pscale = scale.fortran_vec (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 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
|
94 n, h, n, ilo, ihi, pscale, info |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
95 F77_CHAR_ARG_LEN (1))); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
97 Array<FloatComplex> tau (dim_vector (n-1, 1)); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 FloatComplex *ptau = tau.fortran_vec (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
100 Array<FloatComplex> work (dim_vector (lwork, 1)); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 FloatComplex *pwork = work.fortran_vec (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 F77_XFCN (cgehrd, CGEHRD, (n, ilo, ihi, h, n, ptau, pwork, lwork, info)); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 unitary_hess_mat = hess_mat; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 FloatComplex *z = unitary_hess_mat.fortran_vec (); |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 F77_XFCN (cunghr, CUNGHR, (n, ilo, ihi, z, n, ptau, pwork, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
109 lwork, info)); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 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
|
112 F77_CONST_CHAR_ARG2 (&side, 1), |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
113 n, ilo, ihi, pscale, n, z, n, info |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
114 F77_CHAR_ARG_LEN (1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
115 F77_CHAR_ARG_LEN (1))); |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 // If someone thinks of a more graceful way of |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 // doing this (or faster for that matter :-)), |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 // please let me know! |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 if (n > 2) |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 for (octave_idx_type j = 0; j < a_nc; j++) |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 for (octave_idx_type i = j+2; i < a_nr; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
124 hess_mat.elem (i, j) = 0; |
7792
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 return info; |
39c1026191e9
add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 } |