GNU Octave  6.2.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-2021 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 "oct-cmplx.h"
32 
33 class Matrix;
34 class ComplexMatrix;
36 class SparseMatrix;
37 class ColumnVector;
38 template <typename T> class MArray;
39 
40 namespace octave
41 {
42  namespace math
43  {
44  // If the sparse matrix classes become templated on the element type
45  // (i.e., sparse_matrix<double>), then it might be best to make the
46  // template parameter of this class also be the element type instead
47  // of the matrix type.
48 
49  template <typename SPARSE_T>
50  class
51  sparse_qr
52  {
53  public:
54 
55  sparse_qr (void);
56 
57  sparse_qr (const SPARSE_T& a, int order = 0);
58 
59  sparse_qr (const sparse_qr& a);
60 
61  ~sparse_qr (void);
62 
63  sparse_qr& operator = (const sparse_qr& a);
64 
65  bool ok (void) const;
66 
67  SPARSE_T V (void) const;
68 
69  ColumnVector Pinv (void) const;
70 
71  ColumnVector P (void) const;
72 
73  SPARSE_T R (bool econ = false) const;
74 
75  typename SPARSE_T::dense_matrix_type
76  C (const typename SPARSE_T::dense_matrix_type& b) const;
77 
78  typename SPARSE_T::dense_matrix_type
79  Q (void) const;
80 
81  template <typename RHS_T, typename RET_T>
82  static RET_T
83  solve (const SPARSE_T& a, const RHS_T& b,
84  octave_idx_type& info);
85 
86  private:
87 
88  class sparse_qr_rep;
89 
91 
92  template <typename RHS_T, typename RET_T>
93  RET_T
94  tall_solve (const RHS_T& b, octave_idx_type& info) const;
95 
96  template <typename RHS_T, typename RET_T>
97  RET_T
98  wide_solve (const RHS_T& b, octave_idx_type& info) const;
99  };
100 
101  // Provide qrsolve for backward compatibility.
102 
103  extern Matrix
104  qrsolve (const SparseMatrix& a, const MArray<double>& b,
105  octave_idx_type& info);
106 
107  extern SparseMatrix
108  qrsolve (const SparseMatrix& a, const SparseMatrix& b,
109  octave_idx_type& info);
110 
111  extern ComplexMatrix
112  qrsolve (const SparseMatrix& a, const MArray<Complex>& b,
113  octave_idx_type& info);
114 
115  extern SparseComplexMatrix
116  qrsolve (const SparseMatrix& a, const SparseComplexMatrix& b,
117  octave_idx_type& info);
118 
119  extern ComplexMatrix
120  qrsolve (const SparseComplexMatrix& a, const MArray<double>& b,
121  octave_idx_type& info);
122 
123  extern SparseComplexMatrix
124  qrsolve (const SparseComplexMatrix& a, const SparseMatrix& b,
125  octave_idx_type& info);
126 
127  extern ComplexMatrix
128  qrsolve (const SparseComplexMatrix& a, const MArray<Complex>& b,
129  octave_idx_type& info);
130 
131  extern SparseComplexMatrix
132  qrsolve (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
133  octave_idx_type& info);
134 
137  }
138 }
139 
140 #endif
#define C(a, b)
Definition: Faddeeva.cc:246
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:63
Definition: dMatrix.h:42
sparse_qr_rep * rep
Definition: sparse-qr.h:88
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
sparse_qr< SparseComplexMatrix > SparseComplexQR
Definition: sparse-qr.h:136
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)
Definition: sparse-qr.cc:2299
sparse_qr< SparseMatrix > SparseQR
Definition: sparse-qr.h:135