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