comparison liboctave/numeric/sparse-lu.h @ 21146:ea9c05014809

revamp sparse LU factorization classes * sparse-lu.h, sparse-lu.cc: Rename from sparse-base-lu.h and sparse-base-lu.cc, respectively. (class sparse_lu): Rename from sparse_base_lu. Incorporate code from SparseCmplxLU and SparsedbleLU classes into the sparse_lu template. * sparse-lu-inst.cc: New file. * SparseCmplxLU.cc, SparseCmplxLU.h, SparsedbleLU.cc, SparsedbleLU.h: Delete. * lu.cc, luinc.cc, CSparse.cc, dSparse.cc, eigs-base.cc: Change all uses of SparsedbleLU and SparseCmplxLU to use new sparse_lu template class. * liboctave/numeric/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Thu, 28 Jan 2016 00:15:33 -0500
parents liboctave/numeric/sparse-base-lu.h@538b57866b90
children a223cce1daa4
comparison
equal deleted inserted replaced
21145:307096fb67e1 21146:ea9c05014809
1 /*
2
3 Copyright (C) 2004-2015 David Bateman
4 Copyright (C) 1998-2004 Andy Adler
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 3 of the License, or (at your
11 option) any 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, see
20 <http://www.gnu.org/licenses/>.
21
22 */
23
24
25 #if ! defined (octave_sparse_lu_h)
26 #define octave_sparse_lu_h 1
27
28 #include "MArray.h"
29 #include "dSparse.h"
30
31 template <typename lu_type>
32 class
33 sparse_lu
34 {
35 public:
36
37 typedef typename lu_type::element_type lu_elt_type;
38
39 sparse_lu (void)
40 : Lfact (), Ufact (), Rfact (), cond (0), P (), Q () { }
41
42 sparse_lu (const lu_type& a, const Matrix& piv_thres = Matrix (),
43 bool scale = false);
44
45 sparse_lu (const lu_type& a, const ColumnVector& Qinit,
46 const Matrix& piv_thres, bool scale = false,
47 bool FixedQ = false, double droptol = -1.0,
48 bool milu = false, bool udiag = false);
49
50 sparse_lu (const sparse_lu& a)
51 : Lfact (a.Lfact), Ufact (a.Ufact), Rfact (), cond (a.cond),
52 P (a.P), Q (a.Q)
53 { }
54
55 sparse_lu& operator = (const sparse_lu& a)
56 {
57 if (this != &a)
58 {
59 Lfact = a.Lfact;
60 Ufact = a.Ufact;
61 cond = a.cond;
62 P = a.P;
63 Q = a.Q;
64 }
65
66 return *this;
67 }
68
69 virtual ~sparse_lu (void) { }
70
71 lu_type L (void) const { return Lfact; }
72
73 lu_type U (void) const { return Ufact; }
74
75 SparseMatrix R (void) const { return Rfact; }
76
77 lu_type Y (void) const;
78
79 SparseMatrix Pc (void) const;
80
81 SparseMatrix Pr (void) const;
82
83 ColumnVector Pc_vec (void) const;
84
85 ColumnVector Pr_vec (void) const;
86
87 PermMatrix Pc_mat (void) const;
88
89 PermMatrix Pr_mat (void) const;
90
91 const octave_idx_type * row_perm (void) const { return P.fortran_vec (); }
92
93 const octave_idx_type * col_perm (void) const { return Q.fortran_vec (); }
94
95 double rcond (void) const { return cond; }
96
97 protected:
98
99 lu_type Lfact;
100 lu_type Ufact;
101 SparseMatrix Rfact;
102
103 double cond;
104
105 MArray<octave_idx_type> P;
106 MArray<octave_idx_type> Q;
107 };
108
109 #endif