GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
sparse-lu.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2018 John W. Eaton
4 Copyright (C) 2004-2018 David Bateman
5 Copyright (C) 1998-2004 Andy Adler
6 
7 This file is part of Octave.
8 
9 Octave is free software: you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <https://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if ! defined (octave_sparse_lu_h)
26 #define octave_sparse_lu_h 1
27 
28 #include "octave-config.h"
29 
30 #include "MArray.h"
31 #include "dMatrix.h"
32 #include "dSparse.h"
33 
34 class ColumnVector;
35 class PermMatrix;
36 
37 namespace octave
38 {
39  namespace math
40  {
41  // If the sparse matrix classes become templated on the element type
42  // (i.e., sparse_matrix<double>), then it might be best to make the
43  // template parameter of this class also be the element type instead
44  // of the matrix type.
45 
46  template <typename lu_type>
47  class
48  sparse_lu
49  {
50  public:
51 
52  typedef typename lu_type::element_type lu_elt_type;
53 
54  sparse_lu (void)
55  : Lfact (), Ufact (), Rfact (), cond (0), P (), Q () { }
56 
57  sparse_lu (const lu_type& a, const Matrix& piv_thres = Matrix (),
58  bool scale = false);
59 
60  sparse_lu (const lu_type& a, const ColumnVector& Qinit,
61  const Matrix& piv_thres, bool scale = false,
62  bool FixedQ = false, double droptol = -1.0,
63  bool milu = false, bool udiag = false);
64 
66  : Lfact (a.Lfact), Ufact (a.Ufact), Rfact (), cond (a.cond),
67  P (a.P), Q (a.Q)
68  { }
69 
70  sparse_lu& operator = (const sparse_lu& a)
71  {
72  if (this != &a)
73  {
74  Lfact = a.Lfact;
75  Ufact = a.Ufact;
76  cond = a.cond;
77  P = a.P;
78  Q = a.Q;
79  }
80 
81  return *this;
82  }
83 
84  virtual ~sparse_lu (void) = default;
85 
86  lu_type L (void) const { return Lfact; }
87 
88  lu_type U (void) const { return Ufact; }
89 
90  SparseMatrix R (void) const { return Rfact; }
91 
92  lu_type Y (void) const;
93 
94  SparseMatrix Pc (void) const;
95 
96  SparseMatrix Pr (void) const;
97 
98  ColumnVector Pc_vec (void) const;
99 
100  ColumnVector Pr_vec (void) const;
101 
102  PermMatrix Pc_mat (void) const;
103 
104  PermMatrix Pr_mat (void) const;
105 
106  const octave_idx_type * row_perm (void) const { return P.fortran_vec (); }
107 
108  const octave_idx_type * col_perm (void) const { return Q.fortran_vec (); }
109 
110  double rcond (void) const { return cond; }
111 
112  protected:
113 
114  lu_type Lfact;
115  lu_type Ufact;
117 
118  double cond;
119 
122  };
123  }
124 }
125 
126 #endif
lu_type U(void) const
Definition: sparse-lu.h:88
lu_type::element_type lu_elt_type
Definition: sparse-lu.h:52
MArray< octave_idx_type > Q
Definition: sparse-lu.h:121
SparseMatrix R(void) const
Definition: sparse-lu.h:90
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
double rcond(void) const
Definition: sparse-lu.h:110
Definition: dMatrix.h:36
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Q
SparseMatrix Rfact
Definition: sparse-lu.h:116
sparse_lu(const sparse_lu &a)
Definition: sparse-lu.h:65
void scale(Matrix &m, double x, double y, double z)
Definition: graphics.cc:5442
const octave_idx_type * row_perm(void) const
Definition: sparse-lu.h:106
const octave_idx_type * col_perm(void) const
Definition: sparse-lu.h:108
MArray< octave_idx_type > P
Definition: sparse-lu.h:120
lu_type L(void) const
Definition: sparse-lu.h:86