GNU Octave 10.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-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_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
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 SPARSE_T>
48{
49public:
50
52
53#if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
54 // order = 7 selects SPQR default ordering
55 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 7);
56#elif defined (HAVE_CXSPARSE)
57 // order = 3 selects CXSparse default ordering
58 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 3);
59#else
60 OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 0);
61#endif
62
63 sparse_qr (const sparse_qr& a) = default;
64
65 ~sparse_qr () = default;
66
67 sparse_qr& operator = (const sparse_qr& a) = default;
68
69 OCTAVE_API bool ok () const;
70
71 OCTAVE_API ColumnVector E () const;
72
73 // constructs permutation matrix from permutation vector rep -> E()
75
76 OCTAVE_API SPARSE_T V () const;
77
79
80 OCTAVE_API ColumnVector P () const;
81
82 OCTAVE_API SPARSE_T R (bool econ = false) const;
83
84 OCTAVE_API typename SPARSE_T::dense_matrix_type
85 C (const typename SPARSE_T::dense_matrix_type& b, bool econ = false) const;
86
87 OCTAVE_API typename SPARSE_T::dense_matrix_type
88 Q (bool econ = false) const;
89
90 template <typename RHS_T, typename RET_T>
91 static OCTAVE_API RET_T
92 solve (const SPARSE_T& a, const RHS_T& b,
93 octave_idx_type& info);
94
95private:
96
97 template <typename RHS_T, typename RET_T>
98 static OCTAVE_API RET_T
99 min2norm_solve (const SPARSE_T& a, const RHS_T& b,
100 octave_idx_type& info, int order);
101
102 template <typename RHS_T, typename RET_T>
103 OCTAVE_API RET_T
104 tall_solve (const RHS_T& b, octave_idx_type& info) const;
105
106 template <typename RHS_T, typename RET_T>
107 OCTAVE_API RET_T
108 wide_solve (const RHS_T& b, octave_idx_type& info) const;
109
110 //--------
111 class sparse_qr_rep;
112
113 std::shared_ptr<sparse_qr_rep> m_rep;
114};
115
116// extern instantiations with set visibility/export/import attribute
117
118extern template class OCTAVE_EXTERN_TEMPLATE_API sparse_qr<SparseMatrix>;
119
120extern template class OCTAVE_EXTERN_TEMPLATE_API sparse_qr<SparseComplexMatrix>;
121
122// Provide qrsolve for backward compatibility.
123
124extern OCTAVE_API Matrix
125qrsolve (const SparseMatrix& a, const MArray<double>& b,
126 octave_idx_type& info);
127
129qrsolve (const SparseMatrix& a, const SparseMatrix& b,
130 octave_idx_type& info);
131
133qrsolve (const SparseMatrix& a, const MArray<Complex>& b,
134 octave_idx_type& info);
135
137qrsolve (const SparseMatrix& a, const SparseComplexMatrix& b,
138 octave_idx_type& info);
139
141qrsolve (const SparseComplexMatrix& a, const MArray<double>& b,
142 octave_idx_type& info);
143
145qrsolve (const SparseComplexMatrix& a, const SparseMatrix& b,
146 octave_idx_type& info);
147
150 octave_idx_type& info);
151
154 octave_idx_type& info);
155
158
159OCTAVE_END_NAMESPACE(math)
160OCTAVE_END_NAMESPACE(octave)
161
162#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:157
sparse_qr< SparseMatrix > SparseQR
Definition sparse-qr.h:156
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)