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 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1296
|
24 #pragma implementation |
|
25 #endif |
|
26 |
457
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
457
|
29 #endif |
|
30 |
|
31 #include "CmplxCHOL.h" |
1847
|
32 #include "f77-fcn.h" |
457
|
33 #include "lo-error.h" |
|
34 |
|
35 extern "C" |
|
36 { |
4552
|
37 F77_RET_T |
|
38 F77_FUNC (zpotrf, ZPOTRF) (F77_CONST_CHAR_ARG_DECL, |
|
39 const int&, Complex*, const int&, int& |
|
40 F77_CHAR_ARG_LEN_DECL); |
457
|
41 } |
|
42 |
|
43 int |
|
44 ComplexCHOL::init (const ComplexMatrix& a) |
|
45 { |
|
46 int a_nr = a.rows (); |
|
47 int a_nc = a.cols (); |
|
48 |
1944
|
49 if (a_nr != a_nc) |
|
50 { |
|
51 (*current_liboctave_error_handler) |
|
52 ("ComplexCHOL requires square matrix"); |
|
53 return -1; |
|
54 } |
457
|
55 |
1944
|
56 int n = a_nc; |
|
57 int info; |
|
58 |
|
59 chol_mat = a; |
|
60 Complex *h = chol_mat.fortran_vec (); |
457
|
61 |
4552
|
62 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info |
|
63 F77_CHAR_ARG_LEN (1))); |
457
|
64 |
1944
|
65 if (f77_exception_encountered) |
|
66 (*current_liboctave_error_handler) ("unrecoverable error in zpotrf"); |
|
67 else |
|
68 { |
|
69 // If someone thinks of a more graceful way of doing this (or |
|
70 // faster for that matter :-)), please let me know! |
457
|
71 |
1944
|
72 if (n > 1) |
|
73 for (int j = 0; j < a_nc; j++) |
|
74 for (int i = j+1; i < a_nr; i++) |
|
75 chol_mat.elem (i, j) = 0.0; |
|
76 } |
|
77 |
|
78 return info; |
457
|
79 } |
|
80 |
|
81 /* |
|
82 ;;; Local Variables: *** |
|
83 ;;; mode: C++ *** |
|
84 ;;; End: *** |
|
85 */ |