GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
sparse-qr.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2005-2022 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_qr_h)
27#define octave_sparse_qr_h 1
28
29#include "octave-config.h"
30
31#include <memory>
32
33#include "oct-cmplx.h"
34#include "MArray-fwd.h"
35#include "mx-fwd.h"
36
37namespace 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 SPARSE_T>
47 class
49 {
50 public:
51
52 OCTAVE_API sparse_qr (void);
53
54#if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
55 // order = 7 selects SPQR default ordering
56 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 7);
57#else
58 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 0);
59#endif
60
61 sparse_qr (const sparse_qr& a) = default;
62
63 ~sparse_qr (void) = default;
64
65 sparse_qr& operator = (const sparse_qr& a) = default;
66
67 OCTAVE_API bool ok (void) const;
68
69 OCTAVE_API ColumnVector E (void) const;
70
71 // constructs permutation matrix from permutation vector rep -> E()
72 OCTAVE_API SparseMatrix E_MAT () const;
73
74 OCTAVE_API SPARSE_T V (void) const;
75
76 OCTAVE_API ColumnVector Pinv (void) const;
77
78 OCTAVE_API ColumnVector P (void) const;
79
80 OCTAVE_API SPARSE_T R (bool econ = false) const;
81
82 OCTAVE_API typename SPARSE_T::dense_matrix_type
83 C (const typename SPARSE_T::dense_matrix_type& b, bool econ = false) const;
84
85 OCTAVE_API typename SPARSE_T::dense_matrix_type
86 Q (bool econ = false) const;
87
88 template <typename RHS_T, typename RET_T>
89 static OCTAVE_API RET_T
90 solve (const SPARSE_T& a, const RHS_T& b,
91 octave_idx_type& info);
92
93 private:
94
95 template <typename RHS_T, typename RET_T>
96 static OCTAVE_API RET_T
97 min2norm_solve (const SPARSE_T& a, const RHS_T& b,
98 octave_idx_type& info, int order);
99
100 template <typename RHS_T, typename RET_T>
101 OCTAVE_API RET_T
102 tall_solve (const RHS_T& b, octave_idx_type& info) const;
103
104 template <typename RHS_T, typename RET_T>
105 OCTAVE_API RET_T
106 wide_solve (const RHS_T& b, octave_idx_type& info) const;
107
108 //--------
109 class sparse_qr_rep;
110
111 std::shared_ptr<sparse_qr_rep> m_rep;
112 };
113
114#if defined (__clang__) || defined (_WIN32)
115 // extern instantiations with set visibility/export/import attribute
116
117 extern template class OCTAVE_API sparse_qr<SparseMatrix>;
118
119 extern template class OCTAVE_API sparse_qr<SparseComplexMatrix>;
120#endif
121
122 // Provide qrsolve for backward compatibility.
123
124 extern OCTAVE_API Matrix
125 qrsolve (const SparseMatrix& a, const MArray<double>& b,
126 octave_idx_type& info);
127
129 qrsolve (const SparseMatrix& a, const SparseMatrix& b,
130 octave_idx_type& info);
131
133 qrsolve (const SparseMatrix& a, const MArray<Complex>& b,
134 octave_idx_type& info);
135
137 qrsolve (const SparseMatrix& a, const SparseComplexMatrix& b,
138 octave_idx_type& info);
139
141 qrsolve (const SparseComplexMatrix& a, const MArray<double>& b,
142 octave_idx_type& info);
143
145 qrsolve (const SparseComplexMatrix& a, const SparseMatrix& b,
146 octave_idx_type& info);
147
149 qrsolve (const SparseComplexMatrix& a, const MArray<Complex>& b,
150 octave_idx_type& info);
151
154 octave_idx_type& info);
155
158 }
159}
160
161#endif
#define C(a, b)
Definition: Faddeeva.cc:259
Definition: dMatrix.h:42
OCTAVE_API RET_T wide_solve(const RHS_T &b, octave_idx_type &info) const
sparse_qr(const sparse_qr &a)=default
static OCTAVE_API RET_T solve(const SPARSE_T &a, const RHS_T &b, octave_idx_type &info)
OCTAVE_API RET_T tall_solve(const RHS_T &b, octave_idx_type &info) const
~sparse_qr(void)=default
static OCTAVE_API RET_T min2norm_solve(const SPARSE_T &a, const RHS_T &b, octave_idx_type &info, int order)
std::shared_ptr< sparse_qr_rep > m_rep
Definition: sparse-qr.h:111
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
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
#define OCTAVE_API
Definition: main.in.cc:55
sparse_qr< SparseComplexMatrix > SparseComplexQR
Definition: sparse-qr.h:157
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)
Definition: sparse-qr.cc:3288
sparse_qr< SparseMatrix > SparseQR
Definition: sparse-qr.h:156