GNU Octave 11.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-2026 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
39
40// If the sparse matrix classes become templated on the element type
41// (i.e., sparse_matrix<double>), then it might be best to make the
42// template parameter of this class also be the element type instead
43// of the matrix type.
44
45template <typename lu_type>
47{
48public:
49
50 typedef typename lu_type::element_type lu_elt_type;
51
53 : m_L (), m_U (), m_R (), m_cond (0), m_P (), m_Q () { }
54
56 sparse_lu (const lu_type& a, const Matrix& piv_thres = Matrix (),
57 bool scale = false);
58
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 : m_L (a.m_L), m_U (a.m_U), m_R (),
67 m_cond (a.m_cond), m_P (a.m_P), m_Q (a.m_Q)
68 { }
69
70 sparse_lu& operator = (const sparse_lu& a)
71 {
72 if (this != &a)
73 {
74 m_L = a.m_L;
75 m_U = a.m_U;
76 m_cond = a.m_cond;
77 m_P = a.m_P;
78 m_Q = a.m_Q;
79 }
80
81 return *this;
82 }
83
84 virtual ~sparse_lu () = default;
85
86 lu_type L () const { return m_L; }
87
88 lu_type U () const { return m_U; }
89
90 SparseMatrix R () const { return m_R; }
91
92 OCTAVE_API lu_type Y () const;
93
94 OCTAVE_API SparseMatrix Pc () const;
95
96 OCTAVE_API SparseMatrix Pr () const;
97
98 OCTAVE_API ColumnVector Pc_vec () const;
99
100 OCTAVE_API ColumnVector Pr_vec () const;
101
102 OCTAVE_API PermMatrix Pc_mat () const;
103
104 OCTAVE_API PermMatrix Pr_mat () const;
105
106 const octave_idx_type * row_perm () const { return m_P.data (); }
107
108 const octave_idx_type * col_perm () const { return m_Q.data (); }
109
110 double rcond () const { return m_cond; }
111
112protected:
113
114 lu_type m_L;
115 lu_type m_U;
117
118 double m_cond;
119
122};
123
124OCTAVE_END_NAMESPACE(math)
125OCTAVE_END_NAMESPACE(octave)
126
127#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:65
lu_type L() const
Definition sparse-lu.h:86
lu_type m_L
Definition sparse-lu.h:114
double m_cond
Definition sparse-lu.h:118
lu_type U() const
Definition sparse-lu.h:88
MArray< octave_idx_type > m_Q
Definition sparse-lu.h:121
virtual ~sparse_lu()=default
const octave_idx_type * row_perm() const
Definition sparse-lu.h:106
SparseMatrix m_R
Definition sparse-lu.h:116
lu_type m_U
Definition sparse-lu.h:115
lu_type::element_type lu_elt_type
Definition sparse-lu.h:50
SparseMatrix R() const
Definition sparse-lu.h:90
const octave_idx_type * col_perm() const
Definition sparse-lu.h:108
MArray< octave_idx_type > m_P
Definition sparse-lu.h:120
double rcond() const
Definition sparse-lu.h:110
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void scale(Matrix &m, double x, double y, double z)
Definition graphics.cc:5741
#define OCTAVE_API
Definition main.in.cc:55