GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
sparse-lu.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1998-2025 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
46template <typename lu_type>
48{
49public:
50
51 typedef typename lu_type::element_type lu_elt_type;
52
54 : m_L (), m_U (), m_R (), m_cond (0), m_P (), m_Q () { }
55
57 sparse_lu (const lu_type& a, const Matrix& piv_thres = Matrix (),
58 bool scale = false);
59
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
67 : m_L (a.m_L), m_U (a.m_U), m_R (),
68 m_cond (a.m_cond), m_P (a.m_P), m_Q (a.m_Q)
69 { }
70
71 sparse_lu& operator = (const sparse_lu& a)
72 {
73 if (this != &a)
74 {
75 m_L = a.m_L;
76 m_U = a.m_U;
77 m_cond = a.m_cond;
78 m_P = a.m_P;
79 m_Q = a.m_Q;
80 }
81
82 return *this;
83 }
84
85 virtual ~sparse_lu () = default;
86
87 lu_type L () const { return m_L; }
88
89 lu_type U () const { return m_U; }
90
91 SparseMatrix R () const { return m_R; }
92
93 OCTAVE_API lu_type Y () const;
94
95 OCTAVE_API SparseMatrix Pc () const;
96
97 OCTAVE_API SparseMatrix Pr () const;
98
99 OCTAVE_API ColumnVector Pc_vec () const;
100
101 OCTAVE_API ColumnVector Pr_vec () const;
102
103 OCTAVE_API PermMatrix Pc_mat () const;
104
105 OCTAVE_API PermMatrix Pr_mat () const;
106
107 const octave_idx_type * row_perm () const { return m_P.data (); }
108
109 const octave_idx_type * col_perm () const { return m_Q.data (); }
110
111 double rcond () const { return m_cond; }
112
113protected:
114
115 lu_type m_L;
116 lu_type m_U;
118
119 double m_cond;
120
123};
124
125OCTAVE_END_NAMESPACE(math)
126OCTAVE_END_NAMESPACE(octave)
127
128#endif
Template for N-dimensional array classes with like-type math operators.
Definition MArray.h:61
sparse_lu(const sparse_lu &a)
Definition sparse-lu.h:66
lu_type L() const
Definition sparse-lu.h:87
lu_type m_L
Definition sparse-lu.h:115
double m_cond
Definition sparse-lu.h:119
lu_type U() const
Definition sparse-lu.h:89
MArray< octave_idx_type > m_Q
Definition sparse-lu.h:122
virtual ~sparse_lu()=default
const octave_idx_type * row_perm() const
Definition sparse-lu.h:107
SparseMatrix m_R
Definition sparse-lu.h:117
lu_type m_U
Definition sparse-lu.h:116
lu_type::element_type lu_elt_type
Definition sparse-lu.h:51
SparseMatrix R() const
Definition sparse-lu.h:91
const octave_idx_type * col_perm() const
Definition sparse-lu.h:109
MArray< octave_idx_type > m_P
Definition sparse-lu.h:121
double rcond() const
Definition sparse-lu.h:111
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void scale(Matrix &m, double x, double y, double z)
Definition graphics.cc:5731
#define OCTAVE_API
Definition main.in.cc:55