Mercurial > hg > octave-nkf
annotate liboctave/CmplxHESS.cc @ 7786:37ff0c21c17d
load-path.cc (load_path::initialize): include separator when appending sys_path
author | Kim Hansen |
---|---|
date | Tue, 20 May 2008 16:49:02 -0400 |
parents | 29980c6b8604 |
children | eb63fbe60fab |
rev | line source |
---|---|
457 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2002, 2003, 2004, 2005, 2007 |
4 John W. Eaton | |
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 | |
24 #ifdef HAVE_CONFIG_H | |
1192 | 25 #include <config.h> |
457 | 26 #endif |
27 | |
28 #include "CmplxHESS.h" | |
1847 | 29 #include "f77-fcn.h" |
457 | 30 #include "lo-error.h" |
31 | |
32 extern "C" | |
33 { | |
4552 | 34 F77_RET_T |
35 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL, | |
5275 | 36 const octave_idx_type&, Complex*, const octave_idx_type&, |
37 octave_idx_type&, octave_idx_type&, double*, octave_idx_type& | |
4552 | 38 F77_CHAR_ARG_LEN_DECL); |
457 | 39 |
4552 | 40 F77_RET_T |
5275 | 41 F77_FUNC (zgehrd, ZGEHRD) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, |
42 Complex*, const octave_idx_type&, Complex*, | |
43 Complex*, const octave_idx_type&, octave_idx_type&); | |
1251 | 44 |
4552 | 45 F77_RET_T |
5275 | 46 F77_FUNC (zunghr, ZUNGHR) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, |
47 Complex*, const octave_idx_type&, Complex*, | |
48 Complex*, const octave_idx_type&, octave_idx_type&); | |
457 | 49 |
4552 | 50 F77_RET_T |
51 F77_FUNC (zgebak, ZGEBAK) (F77_CONST_CHAR_ARG_DECL, | |
52 F77_CONST_CHAR_ARG_DECL, | |
5275 | 53 const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, double*, |
54 const octave_idx_type&, Complex*, const octave_idx_type&, octave_idx_type& | |
4552 | 55 F77_CHAR_ARG_LEN_DECL |
56 F77_CHAR_ARG_LEN_DECL); | |
457 | 57 } |
58 | |
5275 | 59 octave_idx_type |
457 | 60 ComplexHESS::init (const ComplexMatrix& a) |
61 { | |
5275 | 62 octave_idx_type a_nr = a.rows (); |
63 octave_idx_type a_nc = a.cols (); | |
1932 | 64 |
65 if (a_nr != a_nc) | |
66 { | |
67 (*current_liboctave_error_handler) | |
68 ("ComplexHESS requires square matrix"); | |
69 return -1; | |
70 } | |
457 | 71 |
1932 | 72 char job = 'N'; |
73 char side = 'R'; | |
74 | |
5275 | 75 octave_idx_type n = a_nc; |
76 octave_idx_type lwork = 32 * n; | |
77 octave_idx_type info; | |
78 octave_idx_type ilo; | |
79 octave_idx_type ihi; | |
457 | 80 |
1932 | 81 hess_mat = a; |
82 Complex *h = hess_mat.fortran_vec (); | |
457 | 83 |
1932 | 84 Array<double> scale (n); |
85 double *pscale = scale.fortran_vec (); | |
86 | |
4552 | 87 F77_XFCN (zgebal, ZGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), |
88 n, h, n, ilo, ihi, pscale, info | |
89 F77_CHAR_ARG_LEN (1))); | |
457 | 90 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
91 Array<Complex> tau (n-1); |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
92 Complex *ptau = tau.fortran_vec (); |
457 | 93 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
94 Array<Complex> work (lwork); |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
95 Complex *pwork = work.fortran_vec (); |
457 | 96 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
97 F77_XFCN (zgehrd, ZGEHRD, (n, ilo, ihi, h, n, ptau, pwork, lwork, info)); |
457 | 98 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
99 unitary_hess_mat = hess_mat; |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
100 Complex *z = unitary_hess_mat.fortran_vec (); |
457 | 101 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
102 F77_XFCN (zunghr, ZUNGHR, (n, ilo, ihi, z, n, ptau, pwork, |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
103 lwork, info)); |
457 | 104 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
105 F77_XFCN (zgebak, ZGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1), |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
106 F77_CONST_CHAR_ARG2 (&side, 1), |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
107 n, ilo, ihi, pscale, n, z, n, info |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
108 F77_CHAR_ARG_LEN (1) |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
109 F77_CHAR_ARG_LEN (1))); |
457 | 110 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
111 // If someone thinks of a more graceful way of |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
112 // doing this (or faster for that matter :-)), |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
113 // please let me know! |
457 | 114 |
7482
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
115 if (n > 2) |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
116 for (octave_idx_type j = 0; j < a_nc; j++) |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
117 for (octave_idx_type i = j+2; i < a_nr; i++) |
29980c6b8604
don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
118 hess_mat.elem (i, j) = 0; |
457 | 119 |
1932 | 120 return info; |
457 | 121 } |
122 | |
123 /* | |
124 ;;; Local Variables: *** | |
125 ;;; mode: C++ *** | |
126 ;;; End: *** | |
127 */ |