457
|
1 /* |
|
2 |
1882
|
3 Copyright (C) 1996 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 |
1296
|
23 #if defined (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
457
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
457
|
29 #endif |
|
30 |
|
31 #include "CmplxLU.h" |
1847
|
32 #include "f77-fcn.h" |
457
|
33 #include "lo-error.h" |
|
34 |
1992
|
35 // Instantiate the base LU class for the types we need. |
|
36 |
|
37 #include <base-lu.h> |
|
38 #include <base-lu.cc> |
|
39 |
2049
|
40 template class base_lu <ComplexMatrix, Complex, Matrix, double>; |
1992
|
41 |
|
42 // Define the constructor for this particular derivation. |
|
43 |
457
|
44 extern "C" |
|
45 { |
1253
|
46 int F77_FCN (zgesv, ZGESV) (const int&, const int&, Complex*, |
|
47 const int&, int*, Complex*, const int&, |
|
48 int&); |
457
|
49 } |
|
50 |
|
51 ComplexLU::ComplexLU (const ComplexMatrix& a) |
|
52 { |
|
53 int a_nr = a.rows (); |
|
54 int a_nc = a.cols (); |
1919
|
55 |
457
|
56 if (a_nr == 0 || a_nc == 0 || a_nr != a_nc) |
|
57 { |
|
58 (*current_liboctave_error_handler) ("ComplexLU requires square matrix"); |
|
59 return; |
|
60 } |
|
61 |
|
62 int n = a_nr; |
|
63 |
1992
|
64 ipvt.resize (n); |
1926
|
65 int *pipvt = ipvt.fortran_vec (); |
1919
|
66 |
1992
|
67 a_fact = a; |
|
68 Complex *tmp_data = a_fact.fortran_vec (); |
1919
|
69 |
457
|
70 int info = 0; |
1365
|
71 Complex *dummy = 0; |
457
|
72 |
1926
|
73 F77_XFCN (zgesv, ZGESV, (n, 0, tmp_data, n, pipvt, dummy, n, info)); |
457
|
74 |
1919
|
75 if (f77_exception_encountered) |
|
76 (*current_liboctave_error_handler) ("unrecoverable error in zgesv"); |
|
77 else |
1992
|
78 ipvt -= 1; |
457
|
79 } |
|
80 |
|
81 /* |
|
82 ;;; Local Variables: *** |
|
83 ;;; mode: C++ *** |
|
84 ;;; End: *** |
|
85 */ |