GNU Octave  8.1.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-2023 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 "mx-fwd.h"
32 
33 #include "MArray.h"
34 #include "dMatrix.h"
35 #include "dSparse.h"
36 
38 
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
50 {
51 public:
52 
53  typedef typename lu_type::element_type lu_elt_type;
54 
55  sparse_lu (void)
56  : m_L (), m_U (), m_R (), m_cond (0), m_P (), m_Q () { }
57 
59  sparse_lu (const lu_type& a, const Matrix& piv_thres = Matrix (),
60  bool scale = false);
61 
63  sparse_lu (const lu_type& a, const ColumnVector& Qinit,
64  const Matrix& piv_thres, bool scale = false,
65  bool FixedQ = false, double droptol = -1.0,
66  bool milu = false, bool udiag = false);
67 
68  sparse_lu (const sparse_lu& a)
69  : m_L (a.m_L), m_U (a.m_U), m_R (),
70  m_cond (a.m_cond), m_P (a.m_P), m_Q (a.m_Q)
71  { }
72 
73  sparse_lu& operator = (const sparse_lu& a)
74  {
75  if (this != &a)
76  {
77  m_L = a.m_L;
78  m_U = a.m_U;
79  m_cond = a.m_cond;
80  m_P = a.m_P;
81  m_Q = a.m_Q;
82  }
83 
84  return *this;
85  }
86 
87  virtual ~sparse_lu (void) = default;
88 
89  lu_type L (void) const { return m_L; }
90 
91  lu_type U (void) const { return m_U; }
92 
93  SparseMatrix R (void) const { return m_R; }
94 
95  OCTAVE_API lu_type Y (void) const;
96 
97  OCTAVE_API SparseMatrix Pc (void) const;
98 
99  OCTAVE_API SparseMatrix Pr (void) const;
100 
101  OCTAVE_API ColumnVector Pc_vec (void) const;
102 
103  OCTAVE_API ColumnVector Pr_vec (void) const;
104 
105  OCTAVE_API PermMatrix Pc_mat (void) const;
106 
107  OCTAVE_API PermMatrix Pr_mat (void) const;
108 
109  const octave_idx_type * row_perm (void) const { return m_P.data (); }
110 
111  const octave_idx_type * col_perm (void) const { return m_Q.data (); }
112 
113  double rcond (void) const { return m_cond; }
114 
115 protected:
116 
117  lu_type m_L;
118  lu_type m_U;
120 
121  double m_cond;
122 
125 };
126 
129 
130 #endif
OCTAVE_END_NAMESPACE(octave)
Definition: dMatrix.h:42
sparse_lu(void)
Definition: sparse-lu.h:55
sparse_lu(const sparse_lu &a)
Definition: sparse-lu.h:68
double rcond(void) const
Definition: sparse-lu.h:113
const octave_idx_type * row_perm(void) const
Definition: sparse-lu.h:109
lu_type m_L
Definition: sparse-lu.h:117
double m_cond
Definition: sparse-lu.h:121
MArray< octave_idx_type > m_Q
Definition: sparse-lu.h:124
SparseMatrix R(void) const
Definition: sparse-lu.h:93
SparseMatrix m_R
Definition: sparse-lu.h:119
lu_type m_U
Definition: sparse-lu.h:118
const octave_idx_type * col_perm(void) const
Definition: sparse-lu.h:111
lu_type::element_type lu_elt_type
Definition: sparse-lu.h:53
lu_type L(void) const
Definition: sparse-lu.h:89
virtual ~sparse_lu(void)=default
MArray< octave_idx_type > m_P
Definition: sparse-lu.h:123
lu_type U(void) const
Definition: sparse-lu.h:91
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void scale(Matrix &m, double x, double y, double z)
Definition: graphics.cc:5851
#define OCTAVE_API
Definition: main.in.cc:55