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 |
1192
|
25 #include <config.h> |
457
|
26 #endif |
|
27 |
|
28 #include "dbleCHOL.h" |
|
29 #include "mx-inlines.cc" |
|
30 #include "lo-error.h" |
|
31 #include "f77-uscore.h" |
|
32 |
|
33 extern "C" |
|
34 { |
1251
|
35 int F77_FCN (dpotrf) (const char*, const int&, double*, const int&, |
|
36 int&, long); |
457
|
37 } |
|
38 |
|
39 int |
|
40 CHOL::init (const Matrix& 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) ("CHOL requires square matrix"); |
|
47 return -1; |
|
48 } |
|
49 |
|
50 int n = a_nc; |
|
51 int info; |
|
52 |
|
53 double *h = dup (a.data (), a.length ()); |
|
54 |
1251
|
55 F77_FCN (dpotrf) ("U", n, h, n, info, 1L); |
457
|
56 |
|
57 chol_mat = Matrix (h, n, n); |
|
58 |
|
59 // If someone thinks of a more graceful way of doing this (or faster for |
|
60 // that matter :-)), please let me know! |
|
61 |
|
62 if (n > 1) |
|
63 for (int j = 0; j < a_nc; j++) |
|
64 for (int i = j+1; i < a_nr; i++) |
|
65 chol_mat.elem (i, j) = 0.0; |
|
66 |
|
67 return info; |
|
68 } |
|
69 |
|
70 /* |
|
71 ;;; Local Variables: *** |
|
72 ;;; mode: C++ *** |
|
73 ;;; page-delimiter: "^/\\*" *** |
|
74 ;;; End: *** |
|
75 */ |