GNU Octave  4.4.1
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) 2016-2018 John W. Eaton
4 Copyright (C) 2005-2018 David Bateman
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_sparse_qr_h)
25 #define octave_sparse_qr_h 1
26 
27 #include "octave-config.h"
28 
29 class Matrix;
30 class ComplexMatrix;
32 class SparseMatrix;
33 class ColumnVector;
34 template <typename T> class MArray;
35 
36 namespace octave
37 {
38  namespace math
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 
45  template <typename SPARSE_T>
46  class
47  sparse_qr
48  {
49  public:
50 
51  sparse_qr (void);
52 
53  sparse_qr (const SPARSE_T& a, int order = 0);
54 
55  sparse_qr (const sparse_qr& a);
56 
57  ~sparse_qr (void);
58 
59  sparse_qr& operator = (const sparse_qr& a);
60 
61  bool ok (void) const;
62 
63  SPARSE_T V (void) const;
64 
65  ColumnVector Pinv (void) const;
66 
67  ColumnVector P (void) const;
68 
69  SPARSE_T R (bool econ = false) const;
70 
71  typename SPARSE_T::dense_matrix_type
72  C (const typename SPARSE_T::dense_matrix_type& b) const;
73 
74  typename SPARSE_T::dense_matrix_type
75  Q (void) const;
76 
77  template <typename RHS_T, typename RET_T>
78  static RET_T
79  solve (const SPARSE_T& a, const RHS_T& b,
80  octave_idx_type& info);
81 
82  private:
83 
85 
87 
88  template <typename RHS_T, typename RET_T>
89  RET_T
90  tall_solve (const RHS_T& b, octave_idx_type& info) const;
91 
92  template <typename RHS_T, typename RET_T>
93  RET_T
94  wide_solve (const RHS_T& b, octave_idx_type& info) const;
95  };
96 
97  // Provide qrsolve for backward compatibility.
98 
99  extern Matrix
100  qrsolve (const SparseMatrix& a, const MArray<double>& b,
101  octave_idx_type& info);
102 
103  extern SparseMatrix
104  qrsolve (const SparseMatrix& a, const SparseMatrix& b,
105  octave_idx_type& info);
106 
107  extern ComplexMatrix
108  qrsolve (const SparseMatrix& a, const MArray<Complex>& b,
109  octave_idx_type& info);
110 
111  extern SparseComplexMatrix
112  qrsolve (const SparseMatrix& a, const SparseComplexMatrix& b,
113  octave_idx_type& info);
114 
115  extern ComplexMatrix
116  qrsolve (const SparseComplexMatrix& a, const MArray<double>& b,
117  octave_idx_type& info);
118 
119  extern SparseComplexMatrix
120  qrsolve (const SparseComplexMatrix& a, const SparseMatrix& b,
121  octave_idx_type& info);
122 
123  extern ComplexMatrix
125  octave_idx_type& info);
126 
127  extern SparseComplexMatrix
129  octave_idx_type& info);
130 
133  }
134 }
135 
136 #endif
sparse_qr< SparseComplexMatrix > SparseComplexQR
Definition: sparse-qr.h:132
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:32
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)
Definition: sparse-qr.cc:2301
#define C(a, b)
Definition: Faddeeva.cc:246
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
Definition: dMatrix.h:36
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
sparse_qr_rep * rep
Definition: sparse-qr.h:84
b
Definition: cellfun.cc:400
sparse_qr< SparseMatrix > SparseQR
Definition: sparse-qr.h:131