GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
sparse-qr.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2005-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_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
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 SPARSE_T>
47{
48public:
49
51
52#if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
53 // order = 7 selects SPQR default ordering
54 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 7);
55#elif defined (HAVE_CXSPARSE)
56 // order = 3 selects CXSparse default ordering
57 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 3);
58#else
59 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 0);
60#endif
61
62 sparse_qr (const sparse_qr& a) = default;
63
64 ~sparse_qr () = default;
65
66 sparse_qr& operator = (const sparse_qr& a) = default;
67
68 OCTAVE_API bool ok () const;
69
70 OCTAVE_API ColumnVector E () const;
71
72 // constructs permutation matrix from permutation vector rep -> E()
74
75 OCTAVE_API SPARSE_T V () const;
76
78
79 OCTAVE_API ColumnVector P () const;
80
81 OCTAVE_API SPARSE_T R (bool econ = false) const;
82
83 OCTAVE_API typename SPARSE_T::dense_matrix_type
84 C (const typename SPARSE_T::dense_matrix_type& b, bool econ = false) const;
85
86 OCTAVE_API typename SPARSE_T::dense_matrix_type
87 Q (bool econ = false) const;
88
89 template <typename RHS_T, typename RET_T>
90 static OCTAVE_API RET_T
91 solve (const SPARSE_T& a, const RHS_T& b,
92 octave_idx_type& info);
93
94private:
95
96 template <typename RHS_T, typename RET_T>
97 static OCTAVE_API RET_T
98 min2norm_solve (const SPARSE_T& a, const RHS_T& b,
99 octave_idx_type& info, int order);
100
101 template <typename RHS_T, typename RET_T>
102 OCTAVE_API RET_T
103 tall_solve (const RHS_T& b, octave_idx_type& info) const;
104
105 template <typename RHS_T, typename RET_T>
106 OCTAVE_API RET_T
107 wide_solve (const RHS_T& b, octave_idx_type& info) const;
108
109 //--------
110 class sparse_qr_rep;
111
112 std::shared_ptr<sparse_qr_rep> m_rep;
113};
114
115// extern instantiations with set visibility/export/import attribute
116
117extern template class OCTAVE_EXTERN_TEMPLATE_API sparse_qr<SparseMatrix>;
118
119extern template class OCTAVE_EXTERN_TEMPLATE_API sparse_qr<SparseComplexMatrix>;
120
121// Provide qrsolve for backward compatibility.
122
123extern OCTAVE_API Matrix
124qrsolve (const SparseMatrix& a, const MArray<double>& b,
125 octave_idx_type& info);
126
128qrsolve (const SparseMatrix& a, const SparseMatrix& b,
129 octave_idx_type& info);
130
132qrsolve (const SparseMatrix& a, const MArray<Complex>& b,
133 octave_idx_type& info);
134
136qrsolve (const SparseMatrix& a, const SparseComplexMatrix& b,
137 octave_idx_type& info);
138
140qrsolve (const SparseComplexMatrix& a, const MArray<double>& b,
141 octave_idx_type& info);
142
144qrsolve (const SparseComplexMatrix& a, const SparseMatrix& b,
145 octave_idx_type& info);
146
149 octave_idx_type& info);
150
153 octave_idx_type& info);
154
157
158OCTAVE_END_NAMESPACE(math)
159OCTAVE_END_NAMESPACE(octave)
160
161#endif
#define C(a, b)
Definition Faddeeva.cc:256
Template for N-dimensional array classes with like-type math operators.
Definition MArray.h:61
ColumnVector E() const
SPARSE_T R(bool econ=false) const
SparseMatrix E_MAT() const
sparse_qr & operator=(const sparse_qr &a)=default
bool ok() const
sparse_qr(const sparse_qr &a)=default
static RET_T solve(const SPARSE_T &a, const RHS_T &b, octave_idx_type &info)
~sparse_qr()=default
SPARSE_T V() const
ColumnVector Pinv() const
ColumnVector P() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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
#define OCTAVE_API
Definition main.in.cc:55
sparse_qr< SparseComplexMatrix > SparseComplexQR
Definition sparse-qr.h:156
sparse_qr< SparseMatrix > SparseQR
Definition sparse-qr.h:155
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)