457
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
457
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
457
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
457
|
25 #endif |
|
26 |
|
27 #include "CmplxCHOL.h" |
1847
|
28 #include "f77-fcn.h" |
457
|
29 #include "lo-error.h" |
|
30 |
|
31 extern "C" |
|
32 { |
4552
|
33 F77_RET_T |
|
34 F77_FUNC (zpotrf, ZPOTRF) (F77_CONST_CHAR_ARG_DECL, |
|
35 const int&, Complex*, const int&, int& |
|
36 F77_CHAR_ARG_LEN_DECL); |
457
|
37 } |
|
38 |
|
39 int |
|
40 ComplexCHOL::init (const ComplexMatrix& a) |
|
41 { |
|
42 int a_nr = a.rows (); |
|
43 int a_nc = a.cols (); |
|
44 |
1944
|
45 if (a_nr != a_nc) |
|
46 { |
|
47 (*current_liboctave_error_handler) |
|
48 ("ComplexCHOL requires square matrix"); |
|
49 return -1; |
|
50 } |
457
|
51 |
1944
|
52 int n = a_nc; |
|
53 int info; |
|
54 |
|
55 chol_mat = a; |
|
56 Complex *h = chol_mat.fortran_vec (); |
457
|
57 |
4552
|
58 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info |
|
59 F77_CHAR_ARG_LEN (1))); |
457
|
60 |
1944
|
61 if (f77_exception_encountered) |
|
62 (*current_liboctave_error_handler) ("unrecoverable error in zpotrf"); |
|
63 else |
|
64 { |
|
65 // If someone thinks of a more graceful way of doing this (or |
|
66 // faster for that matter :-)), please let me know! |
457
|
67 |
1944
|
68 if (n > 1) |
|
69 for (int j = 0; j < a_nc; j++) |
|
70 for (int i = j+1; i < a_nr; i++) |
|
71 chol_mat.elem (i, j) = 0.0; |
|
72 } |
|
73 |
|
74 return info; |
457
|
75 } |
|
76 |
|
77 /* |
|
78 ;;; Local Variables: *** |
|
79 ;;; mode: C++ *** |
|
80 ;;; End: *** |
|
81 */ |