457
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
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 |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
|
26 #endif |
|
27 |
|
28 #include "CmplxCHOL.h" |
|
29 #include "mx-inlines.cc" |
|
30 #include "lo-error.h" |
|
31 #include "f77-uscore.h" |
|
32 |
|
33 extern "C" |
|
34 { |
|
35 int F77_FCN (zpotrf) (const char*, const int*, Complex*, const int*, |
|
36 int*, long); |
|
37 } |
|
38 |
|
39 int |
|
40 ComplexCHOL::init (const ComplexMatrix& a) |
|
41 { |
|
42 int a_nr = a.rows (); |
|
43 int a_nc = a.cols (); |
|
44 if (a_nr != a_nc) |
|
45 { |
|
46 (*current_liboctave_error_handler) |
|
47 ("ComplexCHOL requires square matrix"); |
|
48 return -1; |
|
49 } |
|
50 |
|
51 char uplo = 'U'; |
|
52 |
|
53 int n = a_nc; |
|
54 int info; |
|
55 |
|
56 Complex *h = dup (a.data (), a.length ()); |
|
57 |
|
58 F77_FCN (zpotrf) (&uplo, &n, h, &n, &info, 1L); |
|
59 |
|
60 chol_mat = ComplexMatrix (h, n, n); |
|
61 |
|
62 // If someone thinks of a more graceful way of doing this (or faster for |
|
63 // that matter :-)), please let me know! |
|
64 |
|
65 if (n > 1) |
|
66 for (int j = 0; j < a_nc; j++) |
|
67 for (int i = j+1; i < a_nr; i++) |
|
68 chol_mat.elem (i, j) = 0.0; |
|
69 |
|
70 return info; |
|
71 } |
|
72 |
|
73 /* |
|
74 ;;; Local Variables: *** |
|
75 ;;; mode: C++ *** |
|
76 ;;; page-delimiter: "^/\\*" *** |
|
77 ;;; End: *** |
|
78 */ |